Class: Evervault::Http::RelayOutboundConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/evervault/http/relay_outbound_config.rb

Constant Summary collapse

DEFAULT_POLL_INTERVAL =
5
RELAY_OUTBOUND_CONFIG_API_ENDPOINT =
"v2/relay-outbound"
@@destination_domains_cache =
nil
@@poll_interval =
DEFAULT_POLL_INTERVAL
@@timer =
nil

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, request:) ⇒ RelayOutboundConfig

Returns a new instance of RelayOutboundConfig.



11
12
13
14
15
16
17
18
19
20
# File 'lib/evervault/http/relay_outbound_config.rb', line 11

def initialize(base_url:, request:)
  @base_url = base_url
  @request = request
  if @@destination_domains_cache.nil?
    get_relay_outbound_config
  end
  if @@timer.nil?
    @@timer = Evervault::Threading::RepeatedTimer.new(@@poll_interval, -> { get_relay_outbound_config })
  end
end

Class Method Details

.clear_cacheObject



33
34
35
# File 'lib/evervault/http/relay_outbound_config.rb', line 33

def self.clear_cache
  @@destination_domains_cache = nil
end

.disable_pollingObject



26
27
28
29
30
31
# File 'lib/evervault/http/relay_outbound_config.rb', line 26

def self.disable_polling
  unless @@timer.nil?
    @@timer.stop
    @@timer = nil
  end
end

Instance Method Details

#get_destination_domainsObject



22
23
24
# File 'lib/evervault/http/relay_outbound_config.rb', line 22

def get_destination_domains
  @@destination_domains_cache
end