Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/ldclient-rb/impl/integrations/consul_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def get_internal(kind, key)
def get_all_internal(kind)
items_out = {}
prefix = kind_key(kind)
results = Diplomat::Kv.get(prefix, { recurse: true }, :return)
(results == "" ? [] : results).each do |result|
Diplomat::Kv.get_all(prefix, {}, :return).each do |result|
value = result[:value]
next if value.nil?
db_key = result[:key].to_s
Expand Down
28 changes: 28 additions & 0 deletions spec/feature_store_spec_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,34 @@ def new_version_plus(f, delta_version, attrs = {})
end
end
end

it "can read all items when a kind holds a single item" do
# A store must treat a collection of one as a collection. Some database clients
# return a single matching row on its own, rather than in a list.
ensure_stop(store_tester.create_feature_store) do |store1|
store1.init({ $things_kind => { $key1.to_sym => $thing1 } })

# A second instance reads through to the database instead of its own cache.
ensure_stop(store_tester.create_feature_store) do |store2|
expect(store2.all($things_kind)).to eq({ $key1.to_sym => $thing1 })
end
end
end

it "can read all items when the single item is a tombstone with no key" do
# This is the single-item case where the one item is also a deleted item with no
# key of its own, as happens for a one-flag project or after every flag is deleted.
ensure_stop(store_tester.create_feature_store) do |store1|
store1.init({ $things_kind => {} })
store_tester.write_raw_item($things_kind, "deleted-thing", { version: 99, deleted: true })

# A second instance reads through to the database instead of its own cache.
ensure_stop(store_tester.create_feature_store) do |store2|
expect(store2.all($things_kind)).to eq({})
expect(store2.get($things_kind, "deleted-thing")).to be_nil
end
end
end
end
end

Expand Down
Loading