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

Adapt to new Hammer API #56

Merged
merged 12 commits into from
Dec 6, 2024
Merged

Adapt to new Hammer API #56

merged 12 commits into from
Dec 6, 2024

Conversation

ruslandoga
Copy link

@ruslandoga ruslandoga commented Nov 25, 2023

This PR conforms to the new api introduced in ExHammer/hammer#104 and also improves performance somewhat by removing unnecessary GenServer processes and poolboy

@ruslandoga ruslandoga changed the title update redis backend to new hammer api Update Redis backend to new Hammer API Nov 14, 2024
@ruslandoga ruslandoga force-pushed the new-hammer branch 2 times, most recently from 8bdc47e to 5e12d49 Compare November 14, 2024 11:14
@ruslandoga ruslandoga marked this pull request as draft November 14, 2024 11:15
@ruslandoga ruslandoga marked this pull request as ready for review November 14, 2024 11:39
@ruslandoga ruslandoga force-pushed the new-hammer branch 6 times, most recently from aeca5b7 to 7151207 Compare November 14, 2024 14:25
.tool-versions Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
compose.yml Outdated Show resolved Hide resolved
@epinault
Copy link
Contributor

fine for an RC. for final I do want typespec. I have spent time adding them in the past to help documenting and dialyzer be more correct

@ruslandoga
Copy link
Author

The functions here are @callback implementations that already have typespecs.

@ruslandoga ruslandoga mentioned this pull request Nov 15, 2024
epinault
epinault previously approved these changes Nov 15, 2024
@epinault
Copy link
Contributor

what s the plan here? merge in master or are we gonna first release Hammer then update this to proper version and update? this is still pointing to a branch

@ruslandoga
Copy link
Author

The Hammer PR needs to be merged first. Then the backends. I described the plan in the Hammer PR.

@epinault epinault marked this pull request as ready for review December 6, 2024 23:06
@epinault epinault merged commit 69222d8 into ExHammer:master Dec 6, 2024
9 checks passed
@@ -26,7 +26,6 @@ defmodule Hammer.Redis do
prefix = Keyword.get(hammer_opts, :prefix, prefix)
timeout = Keyword.get(hammer_opts, :timeout, :infinity)

# TODO
name = module
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's unclear, maybe you should ask? :)

@@ -51,6 +53,7 @@ defmodule Hammer.Redis do
@prefix unquote(prefix)
@timeout unquote(timeout)

@spec child_spec(Keyword.t()) :: Supervisor.child_spec()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it Keyword.t here but Redis.redis_opts() in start_link? :)

@@ -59,30 +62,36 @@ defmodule Hammer.Redis do
}
end

@spec start_link(Hammer.Redis.redis_opts()) :: {:ok, Redix.connection()}
Copy link
Author

@ruslandoga ruslandoga Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This typespec is not valid. Does the connection always succeed? What if the name has already been used.

Copy link
Contributor

@epinault epinault Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. AI failed, Dialyzer did not pick it up. And I missed it too

def start_link(opts) do
opts = Keyword.put(opts, :name, @name)
Hammer.Redis.start_link(opts)
end

def hit(key, scale, limit, increment \\ 1, timeout \\ @timeout) do
Hammer.Redis.hit(@name, @prefix, key, scale, limit, increment, timeout)
Copy link
Author

@ruslandoga ruslandoga Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please return the timeout arg. It was by design :) If you disagree, let's discuss it first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems very confusing to have a callbacks /3 and /4 and a call here. /5 that don match. It feels as use a little confusing. I had it separate in prior commit but it felt this is something we could do later. I thought we could start matching the contract first and seprate the functional part already and add this later. Should have asked you with retrospect.

def start_link(opts) do
opts = Keyword.put(opts, :name, @name)
Hammer.Redis.start_link(opts)
end

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@impl here is unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting , because it s in a macros it s not needed. TIL

@ruslandoga
Copy link
Author

ruslandoga commented Dec 7, 2024

👋 @epinault

This PR was also merged prematurely :)

Please ask me first before merging my work. And also please stop adding commits to my branches. Especially the ones with dubious value :)

If you don't think we can work together like this, then I'll have to stop with my contributions.

@epinault
Copy link
Contributor

epinault commented Dec 7, 2024

As mentioned in other PR, I am happy to chat with you so we can figure a way to collaborate. there was no intention to make you feel this way. As maintainer, i am just trying to move the needle on this package as. I have a little more time lately.

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

Successfully merging this pull request may close these issues.

2 participants