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

The JetStream.API.Consumer info spec type doesn't match the actual type - lots of missing fields #76

Open
autodidaddict opened this issue Jan 17, 2023 · 1 comment

Comments

@autodidaddict
Copy link
Collaborator

While trying to use this library to obtain the pending/num_pending count for a given consumer, I noticed that information is advertised in the typespec but not made available at all in the code.

The following code is what I see from the 0.0.6 version:

defp to_info(%{"config" => config, "state" => state, "created" => created} = response) do
    with {:ok, created, _} <- DateTime.from_iso8601(created) do
      %{
        cluster: Map.get(response, "cluster"),
        config: to_stream(config),
        created: created,
        mirror: Map.get(response, "mirror"),
        sources: Map.get(response, "sources"),
        state: to_state(state)
      }
    end
  end

And from the hexdocs the info() type specification:

info() :: %{
  ack_floor: %{consumer_seq: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(), stream_seq: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()},
  cluster:
    nil
    | %{
        optional(:name) => [binary](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),
        optional(:leader) => [binary](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),
        optional(:replicas) => [
          %{
            :active => [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),
            :current => [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),
            :name => [binary](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),
            optional(:lag) => [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),
            optional(:offline) => [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()
          }
        ]
      },
  [config](https://hexdocs.pm/jetstream/Jetstream.API.Consumer.html#t:config/0): config(),
  created: [DateTime.t](https://hexdocs.pm/elixir/DateTime.html#t:t/0)(),
  delivered: %{consumer_seq: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(), stream_seq: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)()},
  name: [binary](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),
  num_ack_pending: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),
  num_pending: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),
  num_redelivered: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),
  num_waiting: [non_neg_integer](https://hexdocs.pm/elixir/typespecs.html#basic-types)(),
  push_bound: nil | [boolean](https://hexdocs.pm/elixir/typespecs.html#built-in-types)(),
  stream_name: [binary](https://hexdocs.pm/elixir/typespecs.html#built-in-types)()
}
@brandynbennett
Copy link
Collaborator

Thanks for catching this. I'm not able to work on it now, but I can review a PR if you need a fix before I can get to it

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

No branches or pull requests

2 participants