Class: FeatureHub::Sdk::StreamingEdgeService

Inherits:
EdgeService
  • Object
show all
Defined in:
lib/feature_hub/sdk/streaming_edge_service.rb

Overview

provides a streaming service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, api_keys, edge_url, logger = nil) ⇒ StreamingEdgeService

Returns a new instance of StreamingEdgeService.



12
13
14
15
16
17
18
19
20
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 12

def initialize(repository, api_keys, edge_url, logger = nil)
  super(repository, api_keys, edge_url)

  @url = "#{edge_url}features/#{api_keys[0]}"
  @repository = repository
  @sse_client = nil
  @context = nil
  @logger = logger || FeatureHub::Sdk.default_logger
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



10
11
12
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 10

def repository
  @repository
end

#sse_clientObject (readonly)

Returns the value of attribute sse_client.



10
11
12
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 10

def sse_client
  @sse_client
end

#stoppedObject (readonly)

Returns the value of attribute stopped.



10
11
12
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 10

def stopped
  @stopped
end

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 10

def url
  @url
end

Instance Method Details

#activeObject



30
31
32
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 30

def active
  !@sse_client.nil?
end

#closeObject



34
35
36
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 34

def close
  close_connection
end

#closedObject



22
23
24
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 22

def closed
  @sse_client.nil?
end

#pollObject



26
27
28
# File 'lib/feature_hub/sdk/streaming_edge_service.rb', line 26

def poll
  start_streaming unless @sse_client || @stopped
end