Skip to content

t:Hammer.key/0 is term(), but all backend expect String.t() #136

Open
@Gladear

Description

@Gladear

Describe the bug

Hammer.key/0 is set to value term(), so we should be able to add any key.
However, in all backends (e.g. ETS.FixWindows, Atomic.LeakyBucket, Redis.TokenBucket), @spec of implementations require the key to be a string. More importantly, while non-binary values do work in most backends, the Redis one actually require the key to be a string, and crashes otherwise.

** Provide the following details

  • Version of the library: 7.0.1
  • Backend used: *
  • Algorithm used: *
  • Elixir version (elixir -v): N/A
  • Erlang version (erl -v): N/A
  • Operating system: N/A

Expected behavior

Should the backend work with any term? Or should the key be updated to be a string? Having any term as key can be pretty useful, but does not seem to fit all backends.

I'm open to make the required changes in a PR, but I'd rather wait a decision on the matter beforehand 😄

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions