Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KV watcher does not fire when key is purged #156

Open
lsxliron opened this issue Apr 19, 2024 · 0 comments · May be fixed by #157
Open

KV watcher does not fire when key is purged #156

lsxliron opened this issue Apr 19, 2024 · 0 comments · May be fixed by #157

Comments

@lsxliron
Copy link

Current Behavior

watching a bucket using Gnat.Jetstream.API.KV.watch/3 does not fire an event when a key is purged

# create a bucket
bucket = "my_bucket"

# connect
{:ok, pid} = Gnat.start_link()

# create a bucket
{:ok, _info} = Gnat.Jetstream.API.KV.create_bucket(pid, bucket, history: 10)


handler = fn action, key, value ->
  IO.puts("ACTION --> #{inspect(action)}")
  IO.puts("KEY --> #{inspect(key)}")
  IO.puts("VALUE --> #{inspect(value)}")
end

# start watching the bucket
{:ok, _pid} = Gnat.Jetstream.API.KV.watch(pid, bucket, handler)

# Put the first key
:ok = Gnat.Jetstream.API.KV.create_key(pid, bucket, "my_key_1", "my_value_1")
# output:
#   ACTION --> :key_added
#   KEY --> "my_key_1"
#   VALUE --> "my_value_1"

# delete the first key
:ok = Gnat.Jetstream.API.KV.delete_key(pid, bucket, "my_key_1")
# output:
#   ACTION --> :key_deleted
#   KEY --> "my_key_1"
#   VALUE --> ""

# put the second key
:ok = Gnat.Jetstream.API.KV.put_value(pid, bucket, "my_key_2", "my_value_2")
# output:
#   ACTION --> :key_added
#   KEY --> "my_key_2"
#   VALUE --> "my_value_2"

# purge the second key
:ok = Gnat.Jetstream.API.KV.purge_key(pid, bucket, "my_key_2")
# actual output:
#   :ok
#
# expected output:
#   ACTION --> :key_deleted
#   KEY --> "my_key_2"
#   VALUE --> ""

Expected Behavior

When a key is purged the watcher should emit the same message as if the key was deleted.

@lsxliron lsxliron linked a pull request Apr 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant