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

chore: implemente User and UserRegistry classes #1693

Merged
merged 4 commits into from
Aug 15, 2023
Merged

chore: implemente User and UserRegistry classes #1693

merged 4 commits into from
Aug 15, 2023

Conversation

kostasrim
Copy link
Contributor

This PR implements the basic functionality required to build the ACL commands.

  1. This is a prototype, additional functionality will be added on separate PR's
  2. I decided against fine grain locking for Users since 99.9% of the time we will only acquiring ReadLocks. The impact on the performance of this on the hot path should be negligible.
  3. I added a very simple Unit test which I am planning on expanding on separate PR's. Since, some things might change, I don't want to strand myself changing the unit tests over and over again

Copy link
Contributor

@dranikpg dranikpg left a comment

Choose a reason for hiding this comment

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

Sorry for reviewing while not being asked for, just strolling around 😊

Comment on lines 52 to 54
inline constexpr uint32_t ACL_CATEGORY_KEYSPACE = 1ULL << 0;
inline constexpr uint32_t ACL_CATEGORY_READ = 1ULL << 1;
inline constexpr uint32_t ACL_CATEGORY_WRITE = 1ULL << 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

So you have a dedicated namespace with global constants, reminds me of an.... enum (class) ! 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but enum class does not support implicit conversions between objects and the underlying type which it would make it a nightmare to use without casting on each operation. The other idea was enum + namespace which now that I am thinking it it's a good fit!

Copy link
Contributor

Choose a reason for hiding this comment

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

You can use a typed enum like enum class AclCategory : unit32_t { ... }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but this requires explicit conversions it's used. class enums protect against it.

for example see https://godbolt.org/z/xvK5MMb4v

// when optional is empty, the special `nopass` password is implied
// password hashed with xx64
std::optional<uint64_t> password_;
uint32_t acl_categories_{0};
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe = ACL_CATEGORY_NONE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100%

Comment on lines 51 to 52
// TODO add abseil mutex attributes
mutable absl::Mutex mu_;
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually use fiber compatible mutexes (we have a Mutex in the dfly namespace re-exported from helio) to block only a single fiber instead of blocking the full thread. However most of you operations are really quick, Roman likes to use spinlocks in this case. I don't have any real data or benchmarks to judge with confidence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do that, although spinlock would be kinda worst for operations require a bit more computation (like filtering against the key-space for example, which is not a priority atm but still I want this to be easily extended in the future)

@kostasrim
Copy link
Contributor Author

Sorry for reviewing while not being asked for, just strolling around

you are always welcome 👨‍🍳

@kostasrim kostasrim merged commit e22c131 into main Aug 15, 2023
10 checks passed
@kostasrim kostasrim deleted the acl_part1 branch August 15, 2023 09:57
{"HASH", AclCat::ACL_CATEGORY_HASH},
{"STRING", AclCat::ACL_CATEGORY_STRING},
{"BITMAP", AclCat::ACL_CATEGORY_BITMAP},
{"HYPERLOG", AclCat::ACL_CATEGORY_HYPERLOGLOG},
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be HYPERLOGLOG?

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.

None yet

3 participants