-
Notifications
You must be signed in to change notification settings - Fork 0
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
Go: Implement connect #136
Conversation
aaron-congo
commented
Mar 11, 2024
- adds lib.rs and Go logic to establish standalone and cluster connections
- adds integration test logic to setup/teardown redis servers
- adds integration tests for connect workflows
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.
Seems like this PR is too big to go to upstream why not push lib.rs first get the review on it and then push the go code?
return errors.New("close called on uninitialized or already closed client") | ||
} | ||
|
||
C.close_client(client.coreClient) |
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.
This is something in the future to think about but what happens when a client is closed and a command gets called? Assuming the pointer will be null we probably need to handle it on the rust or go side.
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.
Yeah the other clients check if the client is already closed before attempting to execute a command and throw a ClosingError if they are, so we should do something similar if coreClient is nil. Note that Shachar said ClosingError is only applicable to UDS clients (see here) so we'd return something different (probably DisconnectError)
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.
valkey-io#1077 (comment) I think it should be a closing error.
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.
What if client get closed while a command being executed? We should protect vs application crash in that case too.
My idea so far is to add one more argument to callbacks - client id. A callback submitted to rust would be a static function then, which can dispatch the response to a client if it is not closed yet or ignore vice versa.
TBD
3764973
to
0d52ffa
Compare
I think I brought up this idea before and IIRC Andrew thought they wouldn't want the lib.rs without any integration tests. The PR isn't small but it isn't massive either, I think I will just open it against upstream once this is approved and see if they ask me to split the lib.rs out |
return errors.New("close called on uninitialized or already closed client") | ||
} | ||
|
||
C.close_client(client.coreClient) |
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.
What if client get closed while a command being executed? We should protect vs application crash in that case too.
My idea so far is to add one more argument to callbacks - client id. A callback submitted to rust would be a static function then, which can dispatch the response to a client if it is not closed yet or ignore vice versa.
TBD
clusterManagerOutput := runClusterManager(suite, []string{"start", "-r", "0"}, false) | ||
|
||
suite.standalonePorts = extractPorts(suite, clusterManagerOutput) | ||
suite.T().Logf("Standalone ports = %s", fmt.Sprint(suite.standalonePorts)) |
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.
Sorry for stupid golang question - what does suite.T()
do? Where it is defined?
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.
For tests that aren't part of a test suite, you need to pass a parameter of type testing.T which provides a test context and methods for printing and logging (more info here). Here we are using a test suite, and you access testing.T via suite.T() instead of as a direct parameter. This is mentioned in Testify's docs here
go/src/lib.rs
Outdated
@@ -1,9 +1,159 @@ | |||
#![deny(unsafe_op_in_unsafe_fn)] |
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.
Move this after license header
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 Rust code exists in this PR to get tests passing but we are reviewing it under a separate PR here: https://github.com/aws/glide-for-redis/pull/1127/files
5b5add8
to
6fe92fb
Compare
@@ -140,8 +140,7 @@ func (strategy *BackoffStrategy) toProtobuf() *protobuf.ConnectionRetryStrategy | |||
} | |||
} | |||
|
|||
// RedisClientConfiguration represents the configuration settings for a Standalone Redis client. baseClientConfiguration is an | |||
// embedded struct that contains shared settings for standalone and cluster clients. | |||
// RedisClientConfiguration represents the configuration settings for a Standalone Redis client. |
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.
I realized that the final documentation does not show the unexported fields, so it doesn't make sense to mention baseClientConfiguration here
} | ||
|
||
// NewRedisClient creates a Redis client in standalone mode using the given [RedisClientConfiguration]. | ||
func NewRedisClient(config *RedisClientConfiguration) (*RedisClient, error) { |
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.
In Java this is called CreateClient, but in Go the idiom is that a function called NewRedisClient should be provided if users aren't supposed to initialize a RedisClient struct directly. Also, the Go docs normally will document exported symbols alphabetically but will place New functions immediately underneath the document for the associated struct. We lose this clarity if we call this CreateClient
033fe5d
to
c4daccd
Compare
4720d29
to
d7f10e3
Compare
Closing as this is superseded by another PR upstream (valkey-io#1937) |