From 8a61ea73c20cbc4308b3a2c3ef8f5e2e52f15792 Mon Sep 17 00:00:00 2001 From: Dave Lucia Date: Sun, 29 Dec 2024 12:32:32 -0500 Subject: [PATCH] Document options for `Gnat.Jetstream.API.KV` Also ran formatter on this file --- lib/gnat/jetstream/api/kv.ex | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/gnat/jetstream/api/kv.ex b/lib/gnat/jetstream/api/kv.ex index 326de88..8e50c8c 100644 --- a/lib/gnat/jetstream/api/kv.ex +++ b/lib/gnat/jetstream/api/kv.ex @@ -85,9 +85,14 @@ defmodule Gnat.Jetstream.API.KV do @doc """ Create a Key in a Key/Value Bucket + ## Options + + * `:timeout` - receive timeout for the request + ## Examples iex>:ok = Jetstream.API.KV.create_key(:gnat, "my_bucket", "my_key", "my_value") + """ @spec create_key(conn :: Gnat.t(), bucket_name :: binary(), key :: binary(), value :: binary()) :: :ok | {:error, any()} @@ -233,7 +238,11 @@ defmodule Gnat.Jetstream.API.KV do end) """ def watch(conn, bucket_name, handler) do - Gnat.Jetstream.API.KV.Watcher.start_link(conn: conn, bucket_name: bucket_name, handler: handler) + Gnat.Jetstream.API.KV.Watcher.start_link( + conn: conn, + bucket_name: bucket_name, + handler: handler + ) end @doc ~S""" @@ -286,11 +295,12 @@ defmodule Gnat.Jetstream.API.KV do streams |> Enum.flat_map(fn bucket -> if is_kv_bucket_stream?(bucket) do - [bucket |> String.trim_leading(@stream_prefix)] + [bucket |> String.trim_leading(@stream_prefix)] else - [] + [] end end) + {:ok, stream_names} else {:error, reason} -> @@ -298,7 +308,6 @@ defmodule Gnat.Jetstream.API.KV do end end - @doc false def stream_name(bucket_name) do "#{@stream_prefix}#{bucket_name}"