-
Notifications
You must be signed in to change notification settings - Fork 4
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
Introduce configuration options in the cluster API #137
Draft
bjosv
wants to merge
13
commits into
valkey-io:main
Choose a base branch
from
bjosv:clusterconfig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These flags will be replaced by options and can be set using these new APIs instead: - valkeyClusterConnectWithOptions - valkeyClusterAsyncConnectWithOptions Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
zuiderkwast
reviewed
Dec 6, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API looks good in general!
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Being able to set an event callback on a valkeyClusterAsyncContext removes the need to use the internal valkeyClusterContext. This is a preparation for making valkeyClusterAsyncContext opaque. Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
This allows us to set the callbacks before any connect attempt. Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Use snakecase as rest of the options and prefix with async: - async_connect_cb - async_connect_nc_cb /* non-const callback */ - async_disconnect_cb Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech>
zuiderkwast
reviewed
Dec 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The standalone API uses the options struct
valkeyOptions
to allow users to configure howlibvalkey
set up the context.This struct is used when calling
valkeyConnectWithOptions(valkeyOptions *opt)
, which returns a connected context with prepared command timeout values and so on.The current cluster API, which in inherited from the project
hiredis-vip
andhiredis-cluster
, has some similarities to the standalone API, but it does not provide a options struct and does not have the same "look and feel" as the standalone API.This PR introduces a
valkeyClusterOption
that allows a user to set all options before connecting to the cluster using:valkeyClusterContext *cc = valkeyClusterConnectWithOptions(&options)
or
valkeyClusterAsyncContext *acc = valkeyClusterAsyncConnectWithOptions(&options)
when using the async API.This options struct enables users to set the initial nodes, callbacks, timeouts, options, TLS- and event-adapters,
instead of using a wide range of
valkeyClusterSetOptionXxx
functions on avalkeyClusterContext
(even when they use async contextsvalkeyClusterAsyncContext
...).There are still options that are allowed to be configured during runtime like
valkeyClusterSetOptionTimeout
, but most other options requires a reconnect.The async cluster API will no longer require that users calls the blocking cluster API using
valkeyClusterConnect2(acc->cc)
.We now provide a new option
VALKEY_OPT_BLOCKING_INITIAL_UPDATE
to enable a blocking slotmap update after an initial connect using thevalkeyClusterAsyncConnectWithOptions
API. This will allow us to avoidacc->cc
usages and we should be able to hide thecc
in theacc
struct.All testcases are updated to use the new API and this should give a feeling how it works,
alternatively look at changes in
include/valkey/cluster.h
.The migration guide and docs are not yet updated since its a draft PR.