Class: FeatureHub::Sdk::PollingEdgeService
- Inherits:
-
EdgeService
- Object
- EdgeService
- FeatureHub::Sdk::PollingEdgeService
- Defined in:
- lib/feature_hub/sdk/poll_edge_service.rb
Overview
uses a periodic polling mechanism to get updates
Instance Attribute Summary collapse
-
#api_keys ⇒ Object
readonly
Returns the value of attribute api_keys.
-
#cancel ⇒ Object
readonly
Returns the value of attribute cancel.
-
#edge_url ⇒ Object
readonly
Returns the value of attribute edge_url.
-
#etag ⇒ Object
readonly
Returns the value of attribute etag.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#sha_context ⇒ Object
readonly
Returns the value of attribute sha_context.
-
#stopped ⇒ Object
readonly
Returns the value of attribute stopped.
Instance Method Summary collapse
- #active ⇒ Object
- #close ⇒ Object
- #context_change(new_header) ⇒ Object
-
#initialize(repository, api_keys, edge_url, interval, logger = nil) ⇒ PollingEdgeService
constructor
A new instance of PollingEdgeService.
-
#poll ⇒ Object
abstract.
- #update_interval(interval) ⇒ Object
Constructor Details
#initialize(repository, api_keys, edge_url, interval, logger = nil) ⇒ PollingEdgeService
Returns a new instance of PollingEdgeService.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 15 def initialize(repository, api_keys, edge_url, interval, logger = nil) super(repository, api_keys, edge_url) @repository = repository @api_keys = api_keys @edge_url = edge_url @interval = interval @logger = logger || FeatureHub::Sdk.default_logger @task = nil @cancel = false @context = nil @etag = nil @stopped = false @sha_context = nil generate_url end |
Instance Attribute Details
#api_keys ⇒ Object (readonly)
Returns the value of attribute api_keys.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def api_keys @api_keys end |
#cancel ⇒ Object (readonly)
Returns the value of attribute cancel.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def cancel @cancel end |
#edge_url ⇒ Object (readonly)
Returns the value of attribute edge_url.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def edge_url @edge_url end |
#etag ⇒ Object (readonly)
Returns the value of attribute etag.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def etag @etag end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def interval @interval end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def repository @repository end |
#sha_context ⇒ Object (readonly)
Returns the value of attribute sha_context.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def sha_context @sha_context end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
13 14 15 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 13 def stopped @stopped end |
Instance Method Details
#active ⇒ Object
67 68 69 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 67 def active !@task.nil? end |
#close ⇒ Object
63 64 65 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 63 def close cancel_task end |
#context_change(new_header) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 50 def context_change(new_header) return if new_header == @context @context = new_header @sha_context = Digest::SHA256.hexdigest(@context) if active get_updates else poll end end |
#poll ⇒ Object
abstract
36 37 38 39 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 36 def poll @cancel = false poll_with_interval end |
#update_interval(interval) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/feature_hub/sdk/poll_edge_service.rb', line 41 def update_interval(interval) @interval = interval if @task.nil? poll else @task.execution_interval = interval end end |