diff --git a/lib/ldclient-rb/impl/data_source/polling.rb b/lib/ldclient-rb/impl/data_source/polling.rb index 13e22448..6f01138b 100644 --- a/lib/ldclient-rb/impl/data_source/polling.rb +++ b/lib/ldclient-rb/impl/data_source/polling.rb @@ -67,8 +67,11 @@ def poll error_info ) else - @ready.set # if client was waiting on us, make it stop waiting - has no effect if already set + # Publish the OFF status before releasing anyone waiting on the + # ready event, so a client that returns from start can rely on the + # data source status already reflecting the failure. stop_with_error_info error_info + @ready.set # if client was waiting on us, make it stop waiting - has no effect if already set end rescue StandardError => e Impl::Util.log_exception(@config.logger, "Exception while polling", e) diff --git a/spec/impl/data_store_spec.rb b/spec/impl/data_store_spec.rb index cce0964e..2a1a6789 100644 --- a/spec/impl/data_store_spec.rb +++ b/spec/impl/data_store_spec.rb @@ -36,25 +36,25 @@ module DataStore describe "hash" do it "constant instances are equal to themselves" do - expect(FEATURES.hash).to be FEATURES.hash - expect(SEGMENTS.hash).to be SEGMENTS.hash + expect(FEATURES.hash).to eq FEATURES.hash + expect(SEGMENTS.hash).to eq SEGMENTS.hash end it "same constructions are equal" do - expect(FEATURES.hash).to be DataKind.new(namespace: "features", priority: 1).hash - expect(DataKind.new(namespace: "features", priority: 1).hash).to be DataKind.new(namespace: "features", priority: 1).hash + expect(FEATURES.hash).to eq DataKind.new(namespace: "features", priority: 1).hash + expect(DataKind.new(namespace: "features", priority: 1).hash).to eq DataKind.new(namespace: "features", priority: 1).hash - expect(SEGMENTS.hash).to be DataKind.new(namespace: "segments", priority: 0).hash - expect(DataKind.new(namespace: "segments", priority: 0).hash).to be DataKind.new(namespace: "segments", priority: 0).hash + expect(SEGMENTS.hash).to eq DataKind.new(namespace: "segments", priority: 0).hash + expect(DataKind.new(namespace: "segments", priority: 0).hash).to eq DataKind.new(namespace: "segments", priority: 0).hash end it "distinct namespaces are not equal" do - expect(DataKind.new(namespace: "features", priority: 1).hash).not_to be DataKind.new(namespace: "segments", priority: 1).hash + expect(DataKind.new(namespace: "features", priority: 1).hash).not_to eq DataKind.new(namespace: "segments", priority: 1).hash end it "distinct priorities are not equal" do - expect(DataKind.new(namespace: "features", priority: 1).hash).not_to be DataKind.new(namespace: "features", priority: 2).hash - expect(DataKind.new(namespace: "segments", priority: 1).hash).not_to be DataKind.new(namespace: "segments", priority: 2).hash + expect(DataKind.new(namespace: "features", priority: 1).hash).not_to eq DataKind.new(namespace: "features", priority: 2).hash + expect(DataKind.new(namespace: "segments", priority: 1).hash).not_to eq DataKind.new(namespace: "segments", priority: 2).hash end end end