Skip to content

Commit

Permalink
Document options for Gnat.Jetstream.API.KV
Browse files Browse the repository at this point in the history
Also ran formatter on this file
  • Loading branch information
davydog187 committed Dec 29, 2024
1 parent 43ba8d4 commit 8a61ea7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions lib/gnat/jetstream/api/kv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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()}
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -286,19 +295,19 @@ 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} ->
{:error, reason}
end
end


@doc false
def stream_name(bucket_name) do
"#{@stream_prefix}#{bucket_name}"
Expand Down

0 comments on commit 8a61ea7

Please sign in to comment.