Class: Spacebunny::LiveStream::Base
- Inherits:
-
Object
- Object
- Spacebunny::LiveStream::Base
- Defined in:
- lib/spacebunny/live_stream/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
-
#auto_configs(force_reload = false) ⇒ Object
readonly
Retrieve configs from APIs endpoint.
-
#auto_connection_configs ⇒ Object
readonly
Returns the value of attribute auto_connection_configs.
-
#client ⇒ Object
Returns the value of attribute client.
-
#connection_configs ⇒ Object
(also: #auto_configure)
readonly
Returns the value of attribute connection_configs.
-
#custom_connection_configs ⇒ Object
readonly
Returns the value of attribute custom_connection_configs.
-
#host ⇒ Object
Returns the value of attribute host.
-
#live_streams ⇒ Object
Returns the value of attribute live_streams.
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#log_to ⇒ Object
readonly
Returns the value of attribute log_to.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#raise_on_error ⇒ Object
Returns the value of attribute raise_on_error.
-
#secret ⇒ Object
Returns the value of attribute secret.
-
#tls ⇒ Object
readonly
Returns the value of attribute tls.
-
#tls_ca_certificates ⇒ Object
readonly
Returns the value of attribute tls_ca_certificates.
-
#tls_cert ⇒ Object
readonly
Returns the value of attribute tls_cert.
-
#tls_key ⇒ Object
readonly
Returns the value of attribute tls_key.
-
#verify_peer ⇒ Object
readonly
Returns the value of attribute verify_peer.
-
#vhost ⇒ Object
(also: #organization_id)
Returns the value of attribute vhost.
Instance Method Summary collapse
- #auto_configure? ⇒ Boolean
- #connect ⇒ Object
- #connection_options=(options) ⇒ Object
- #disconnect ⇒ Object
-
#initialize(protocol, *args) ⇒ Base
constructor
A new instance of Base.
-
#on_receive(options = {}) ⇒ Object
Stub method: must be implemented on the class responsible to handle the protocol.
Constructor Details
#initialize(protocol, *args) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/spacebunny/live_stream/base.rb', line 17 def initialize(protocol, *args) @protocol = protocol @custom_connection_configs = {} @auto_connection_configs = {} = args..deep_symbolize_keys @client = [:client] || raise(ClientRequired) @secret = [:secret] || raise(SecretRequired) @api_endpoint = [:api_endpoint] || {} @raise_on_error = [:raise_on_error] @log_to = [:log_to] || STDOUT @log_level = [:log_level] || ::Logger::ERROR @logger = [:logger] || build_logger extract_and_normalize_custom_connection_configs_from set_live_streams [:live_streams] end |
Instance Attribute Details
#api_endpoint ⇒ Object
Returns the value of attribute api_endpoint.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def api_endpoint @api_endpoint end |
#auto_configs(force_reload = false) ⇒ Object (readonly)
Retrieve configs from APIs endpoint
44 45 46 |
# File 'lib/spacebunny/live_stream/base.rb', line 44 def auto_configs @auto_configs end |
#auto_connection_configs ⇒ Object (readonly)
Returns the value of attribute auto_connection_configs.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def auto_connection_configs @auto_connection_configs end |
#client ⇒ Object
Returns the value of attribute client.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def client @client end |
#connection_configs ⇒ Object (readonly) Also known as: auto_configure
Returns the value of attribute connection_configs.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def connection_configs @connection_configs end |
#custom_connection_configs ⇒ Object (readonly)
Returns the value of attribute custom_connection_configs.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def custom_connection_configs @custom_connection_configs end |
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def host @host end |
#live_streams ⇒ Object
Returns the value of attribute live_streams.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def live_streams @live_streams end |
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def log_level @log_level end |
#log_to ⇒ Object (readonly)
Returns the value of attribute log_to.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def log_to @log_to end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def logger @logger end |
#raise_on_error ⇒ Object
Returns the value of attribute raise_on_error.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def raise_on_error @raise_on_error end |
#secret ⇒ Object
Returns the value of attribute secret.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def secret @secret end |
#tls ⇒ Object (readonly)
Returns the value of attribute tls.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def tls @tls end |
#tls_ca_certificates ⇒ Object (readonly)
Returns the value of attribute tls_ca_certificates.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def tls_ca_certificates @tls_ca_certificates end |
#tls_cert ⇒ Object (readonly)
Returns the value of attribute tls_cert.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def tls_cert @tls_cert end |
#tls_key ⇒ Object (readonly)
Returns the value of attribute tls_key.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def tls_key @tls_key end |
#verify_peer ⇒ Object (readonly)
Returns the value of attribute verify_peer.
14 15 16 |
# File 'lib/spacebunny/live_stream/base.rb', line 14 def verify_peer @verify_peer end |
#vhost ⇒ Object Also known as: organization_id
Returns the value of attribute vhost.
13 14 15 |
# File 'lib/spacebunny/live_stream/base.rb', line 13 def vhost @vhost end |
Instance Method Details
#auto_configure? ⇒ Boolean
88 89 90 |
# File 'lib/spacebunny/live_stream/base.rb', line 88 def auto_configure? @client && @secret end |
#connect ⇒ Object
68 69 70 |
# File 'lib/spacebunny/live_stream/base.rb', line 68 def connect logger.warn "connect method must be implemented on class responsibile to handle protocol '#{@protocol}'" end |
#connection_options=(options) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/spacebunny/live_stream/base.rb', line 72 def () unless .is_a? Hash raise ArgumentError, 'connection_options must be an Hash. See doc for further info' end extract_and_normalize_custom_connection_configs_from .with_indifferent_access end |
#disconnect ⇒ Object
79 80 81 |
# File 'lib/spacebunny/live_stream/base.rb', line 79 def disconnect @connection_configs = nil end |
#on_receive(options = {}) ⇒ Object
Stub method: must be implemented on the class responsible to handle the protocol
84 85 86 |
# File 'lib/spacebunny/live_stream/base.rb', line 84 def on_receive( = {}) logger.warn "on_receive method must be implemented on class responsibile to handle protocol '#{@protocol}'" end |