Skip to content

Commit

Permalink
Clean up examples in KV (#181)
Browse files Browse the repository at this point in the history
Formats them to the [conventions of ExUnit](https://hexdocs.pm/ex_unit/ExUnit.DocTest.html#module-examples)

Co-authored-by: Michael <[email protected]>
  • Loading branch information
davydog187 and mmmries authored Jan 1, 2025
1 parent d5ddb4e commit 80afa24
Showing 1 changed file with 12 additions and 12 deletions.
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

0 comments on commit 80afa24

Please sign in to comment.