Skip to content

Support for Redis storage #3

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

Open
wants to merge 68 commits into
base: master
Choose a base branch
from

Conversation

payomdousti
Copy link

No description provided.

…anging get range to be index_jumps_before_entry..index_jumps_after_entry
…ehavor from negative pointers in redis ZRANGE.
…ince it's our only way to ensure we have the correct indices for each element.
Copy link
Owner

@maxim maxim left a comment

Choose a reason for hiding this comment

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

Hello Payom, this is excellent work. 🏆

I would love to add Redis support to this library, and you seem to have built a solid implementation. I'm sorry it took me a while to take a look, but this is quite a lot of code. If you could spare some more time on this, I would also appreciate it if you could:

  1. Clean up the commit history by squashing most of the commits into just 1-3 commits (depending on what makes sense) to be more of a clean addition of the Redis service. Please keep the commit subject under 50 characters, and combine the description of various considerations you made into a single commit message body (within 80 character line length). I.e. one way would be to go over your commits, collect various thoughts you put into them into a single summary, and make this the body of the squashed commit.

  2. Make the travis build pass.

Thank you again for contributing your work. 👍

@@ -0,0 +1,18 @@
defmodule CxLeaderboard.Application do
Copy link
Owner

Choose a reason for hiding this comment

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

Could you clarify why is the application file needed? I haven't programmed elixir for about a year now, so I might be rusty on some concepts, but if this lib worked without application, why does Redis make it necessary?

Copy link
Author

Choose a reason for hiding this comment

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

This was so we could run the redix process on boot.

@@ -38,7 +39,8 @@ defmodule CxLeaderboard.MixProject do
[
{:dialyxir, "~> 0.5", only: :dev, runtime: false},
{:benchee, "~> 0.12", only: :dev, runtime: false},
{:ex_doc, "~> 0.18", only: :dev, runtime: false}
{:ex_doc, "~> 0.18", only: :dev, runtime: false},
{:redix, ">= 0.0.0"}
Copy link
Owner

Choose a reason for hiding this comment

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

Is there any way we can make redix not a dependency unless someone wants to use Redis store?

Copy link
Author

Choose a reason for hiding this comment

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

I'm not as familiar with idiomatic elixir, but i can take a look!

@@ -0,0 +1,289 @@
defmodule CxLeaderboard.RedisStorageCase do
Copy link
Owner

Choose a reason for hiding this comment

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

Is there a reason why RedisStorageCase is needed as opposed to reusing the existing StorageCase?

Copy link
Author

Choose a reason for hiding this comment

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

yeah, so this is the tip of the iceberg with this PR, and I'm curious to get your thoughts. The Redis implementation necessitated some differences in semantics since sorting does not happen as a separate operation (it happens atomically as things are added to the sorted set). There are also some other important changes that aren't top of mind for me, but would be happy to point out once i take a closer look again.

Copy link
Author

Choose a reason for hiding this comment

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

To answer your question though, it was a clean way of pursuing this branch without breaking existing functionality. I think you're right that in the future this could go away potentially.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, I see. I'm happy to re-evaluate what we're testing for. For example, I notice you left a comment that it doesn't make sense to get a range in reverse order.

My goal here is to try and make the public interface more or less consistent, and purely Leaderboard focused, regardless of storage engine. I would rather we remove some of the not-very-useful functionality (like you did with the reverse range test) than have different storage engines provide different behavior.

Would you mind going over each alteration you had to make between this and default StorageCase, and providing some reasons why each was necessary? In the end it might make sense to clean up StorageCase to accommodate RedisStore better.

@@ -22,3 +22,6 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
cx_leaderboard-*.tar

\.idea
Copy link
Owner

Choose a reason for hiding this comment

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

Right now we don't have any editor-specific ignores in .gitignore. Do you think moving these into your personal home directory's global git ignore would be sufficient? That way you wouldn't need to ignore these files on individual projects.

## Global Leaderboards

If you want to have a global leaderboard starting at the same time as your application, and running alongside it, all you need to do is declare a worker as follows:
If you want to have a global leaderboard starting at the same time as your application, and running alongside it, all you need to do is declare a
as follows:
Copy link
Owner

Choose a reason for hiding this comment

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

Seems like this might be a typo.

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