Skip to content

Commit

Permalink
fix typespec (#89)
Browse files Browse the repository at this point in the history
* fix typespec
  • Loading branch information
epinault authored Dec 7, 2024
1 parent 69222d8 commit eb08709
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/hammer/redis.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ defmodule Hammer.Redis do
"""
# Redix does not define a type for its start options, so we define our
# own so hopefully redix will be updated to provide a type
@type redis_opts :: {:url, String.t()} | Keyword.t()
@type redis_option :: {:url, String.t()} | {:name, String.t()}
@type redis_options :: [redis_option()]

# credo:disable-for-next-line Credo.Check.Refactor.CyclomaticComplexity
defmacro __before_compile__(%{module: module}) do
Expand Down Expand Up @@ -63,36 +64,34 @@ defmodule Hammer.Redis do
}
end

@spec start_link(Hammer.Redis.redis_opts()) :: {:ok, Redix.connection()}
@spec start_link(Hammer.Redis.redis_options()) ::
{:ok, pid()} | :ignore | {:error, term()}
def start_link(opts) do
opts = Keyword.put(opts, :name, @name)
Hammer.Redis.start_link(opts)
end

@impl Hammer
def hit(key, scale, limit, increment \\ 1) do
Hammer.Redis.hit(@name, @prefix, key, scale, limit, increment, @timeout)
end

@impl Hammer
def inc(key, scale, increment \\ 1) do
Hammer.Redis.inc(@name, @prefix, key, scale, increment, @timeout)
end

@impl Hammer
def set(key, scale, count) do
Hammer.Redis.set(@name, @prefix, key, scale, count, @timeout)
end

@impl Hammer
def get(key, scale) do
Hammer.Redis.get(@name, @prefix, key, scale, @timeout)
end
end
end

@doc false
@spec start_link(Hammer.Redis.redis_opts()) :: {:ok, Redix.connection()}
@spec start_link(Hammer.Redis.redis_options()) ::
{:ok, pid()} | :ignore | {:error, term()}
def start_link(opts) do
{url, opts} = Keyword.pop(opts, :url)

Expand Down

0 comments on commit eb08709

Please sign in to comment.