Class: LaunchDarkly::Impl::Integrations::FileDataSourceImpl Private

Inherits:
Object
  • Object
show all
Defined in:
lib/ldclient-rb/impl/integrations/file_data_source.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 5.5.0

Defined Under Namespace

Classes: FileDataSourcePoller

Constant Summary collapse

@@have_listen =

This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.

To avoid pulling in 'listen' and its transitive dependencies for people who aren't using the file data source or who don't need auto-updating, we only enable auto-update if the 'listen' gem has been provided by the host app.

Since:

  • 5.5.0

false

Instance Method Summary collapse

Constructor Details

#initialize(data_store, data_source_update_sink, logger, options = {}) ⇒ FileDataSourceImpl

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FileDataSourceImpl.

Parameters:

Since:

  • 5.5.0



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ldclient-rb/impl/integrations/file_data_source.rb', line 30

def initialize(data_store, data_source_update_sink, logger, options={})
  @data_store = data_source_update_sink || data_store
  @data_source_update_sink = data_source_update_sink
  @logger = logger
  @paths = options[:paths] || []
  if @paths.is_a? String
    @paths = [ @paths ]
  end
  @auto_update = options[:auto_update]
  @use_listen = @auto_update && @@have_listen && !options[:force_polling]
  @poll_interval = options[:poll_interval] || 1
  @initialized = Concurrent::AtomicBoolean.new(false)
  @ready = Concurrent::Event.new

  @version_lock = Mutex.new
  @last_version = 1
end

Instance Method Details

#initialized?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 5.5.0



48
49
50
# File 'lib/ldclient-rb/impl/integrations/file_data_source.rb', line 48

def initialized?
  @initialized.value
end

#startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 5.5.0



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/ldclient-rb/impl/integrations/file_data_source.rb', line 52

def start
  ready = Concurrent::Event.new

  # We will return immediately regardless of whether the file load succeeded or failed -
  # the difference can be detected by checking "initialized?"
  ready.set

  load_all

  if @auto_update
    # If we're going to watch files, then the start event will be set the first time we get
    # a successful load.
    @listener = start_listener
  end

  ready
end

#stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 5.5.0



70
71
72
# File 'lib/ldclient-rb/impl/integrations/file_data_source.rb', line 70

def stop
  @listener.stop unless @listener.nil?
end