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

Clean up examples in KV #181

Merged
merged 2 commits into from
Jan 1, 2025
Merged
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
24 changes: 12 additions & 12 deletions lib/gnat/jetstream/api/kv.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>{:ok, info} = Jetstream.API.KV.create_bucket(:gnat, "my_bucket")
iex> {:ok, info} = Jetstream.API.KV.create_bucket(:gnat, "my_bucket")
"""
@spec create_bucket(conn :: Gnat.t(), bucket_name :: binary(), params :: [bucket_options()]) ::
{:ok, Stream.info()} | {:error, any()}
Expand Down Expand Up @@ -75,7 +75,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>:ok = Jetstream.API.KV.delete_bucket(:gnat, "my_bucket")
iex> :ok = Jetstream.API.KV.delete_bucket(:gnat, "my_bucket")
"""
@spec delete_bucket(conn :: Gnat.t(), bucket_name :: binary()) :: :ok | {:error, any()}
def delete_bucket(conn, bucket_name) do
Expand All @@ -87,7 +87,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>:ok = Jetstream.API.KV.create_key(:gnat, "my_bucket", "my_key", "my_value")
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 All @@ -107,7 +107,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>:ok = Jetstream.API.KV.delete_key(:gnat, "my_bucket", "my_key")
iex> :ok = Jetstream.API.KV.delete_key(:gnat, "my_bucket", "my_key")
"""
@spec delete_key(conn :: Gnat.t(), bucket_name :: binary(), key :: binary()) ::
:ok | {:error, any()}
Expand All @@ -131,7 +131,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>:ok = Jetstream.API.KV.purge_key(:gnat, "my_bucket", "my_key")
iex> :ok = Jetstream.API.KV.purge_key(:gnat, "my_bucket", "my_key")
"""
@spec purge_key(conn :: Gnat.t(), bucket_name :: binary(), key :: binary()) ::
:ok | {:error, any()}
Expand All @@ -155,7 +155,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>:ok = Jetstream.API.KV.put_value(:gnat, "my_bucket", "my_key", "my_value")
iex> :ok = Jetstream.API.KV.put_value(:gnat, "my_bucket", "my_key", "my_value")
"""
@spec put_value(conn :: Gnat.t(), bucket_name :: binary(), key :: binary(), value :: binary()) ::
:ok | {:error, any()}
Expand All @@ -175,7 +175,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>"my_value" = Jetstream.API.KV.get_value(:gnat, "my_bucket", "my_key")
iex> "my_value" = Jetstream.API.KV.get_value(:gnat, "my_bucket", "my_key")
"""
@spec get_value(conn :: Gnat.t(), bucket_name :: binary(), key :: binary()) ::
binary() | {:error, any()} | nil
Expand All @@ -193,7 +193,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>{:ok, %{"key1" => "value1"}} = Jetstream.API.KV.contents(:gnat, "my_bucket")
iex> {:ok, %{"key1" => "value1"}} = Jetstream.API.KV.contents(:gnat, "my_bucket")
"""
@spec contents(conn :: Gnat.t(), bucket_name :: binary(), domain :: nil | binary()) ::
{:ok, map()} | {:error, binary()}
Expand Down Expand Up @@ -228,9 +228,9 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>{:ok, _pid} = Jetstream.API.KV.watch(:gnat, "my_bucket", fn action, key, value ->
IO.puts("#{action} taken on #{key}")
end)
iex> {:ok, _pid} = Jetstream.API.KV.watch(:gnat, "my_bucket", fn action, key, value ->
...> IO.puts("#{action} taken on #{key}")
...> end)
"""
def watch(conn, bucket_name, handler) do
Gnat.Jetstream.API.KV.Watcher.start_link(
Expand All @@ -246,7 +246,7 @@ defmodule Gnat.Jetstream.API.KV do

## Examples

iex>:ok = Jetstream.API.KV.unwatch(pid)
iex> :ok = Jetstream.API.KV.unwatch(pid)
"""
def unwatch(pid) do
Gnat.Jetstream.API.KV.Watcher.stop(pid)
Expand Down
Loading