Class: LaunchDarkly::Impl::DataStore::UpdateSink

Inherits:
Object
  • Object
show all
Includes:
LaunchDarkly::Interfaces::DataStore::UpdateSink
Defined in:
lib/ldclient-rb/impl/data_store.rb

Overview

Since:

  • 5.5.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(broadcaster) ⇒ UpdateSink

Returns a new instance of UpdateSink.

Since:

  • 5.5.0



93
94
95
96
97
98
# File 'lib/ldclient-rb/impl/data_store.rb', line 93

def initialize(broadcaster)
  @broadcaster = broadcaster
  @last_status = Concurrent::AtomicReference.new(
    LaunchDarkly::Interfaces::DataStore::Status.new(true, false)
  )
end

Instance Attribute Details

#broadcasterLaunchDarkly::Impl::Broadcaster (readonly)

Returns:

  • (LaunchDarkly::Impl::Broadcaster)

Since:

  • 5.5.0



88
89
90
# File 'lib/ldclient-rb/impl/data_store.rb', line 88

def broadcaster
  @broadcaster
end

#last_statusConcurrent::AtomicReference (readonly)

Returns:

  • (Concurrent::AtomicReference)

Since:

  • 5.5.0



91
92
93
# File 'lib/ldclient-rb/impl/data_store.rb', line 91

def last_status
  @last_status
end

Instance Method Details

#update_status(status) ⇒ Object

Since:

  • 5.5.0



100
101
102
103
104
105
# File 'lib/ldclient-rb/impl/data_store.rb', line 100

def update_status(status)
  return if status.nil?

  old_status = @last_status.get_and_set(status)
  @broadcaster.broadcast(status) unless old_status == status
end