-
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
base: main
Are you sure you want to change the base?
Conversation
These flags will be replaced by options and can be set using these new APIs instead: - valkeyClusterConnectWithOptions - valkeyClusterAsyncConnectWithOptions Signed-off-by: Björn Svensson <[email protected]>
Signed-off-by: Björn Svensson <[email protected]>
Signed-off-by: Björn Svensson <[email protected]>
Signed-off-by: Björn Svensson <[email protected]>
Signed-off-by: Björn Svensson <[email protected]>
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!
/* Helper macro to initialize options. */ | ||
#define VALKEY_CLUSTER_OPTIONS_SET_ADAPTER_LIBEVENT(opts, event_base) \ | ||
do { \ | ||
(opts)->attach_fn = valkeyLibeventAttachAdapter; \ | ||
(opts)->attach_data = event_base; \ | ||
} while (0) | ||
|
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.
Why are these not static functions, like valkeyClusterLibeventAttach and others?
/* Helper macro to initialize options. */ | ||
#define VALKEY_CLUSTER_OPTIONS_SET_SSL(opts, tls_) \ | ||
do { \ | ||
(opts)->tls = tls_; \ | ||
(opts)->tls_init_fn = &valkeyInitiateTLSWithContext; \ | ||
} while (0) | ||
|
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.
Why not a function?
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.