-
Notifications
You must be signed in to change notification settings - Fork 3k
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 Bun.redis
- a builtin Redis client for Bun
#18812
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
this.reconnect_timer.state = .FIRED; | ||
|
||
// Increment ref to ensure 'this' stays alive throughout the function | ||
this.ref(); |
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 not necessary since reconnect already do ref/unref
const handshake_success = if (success == 1) true else false; | ||
this.ref(); | ||
defer this.deref(); | ||
if (handshake_success) { |
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.
If handshake_success
is false we need to fail this.client.failWithJSValue(this.globalObject, ssl_error.toJS(this.globalObject));
because it means the server rejected the connection
const valkey = JSC.API.Valkey.create(globalThis, &[_]JSValue{.undefined}) catch |err| { | ||
if (err != error.JSError) { | ||
_ = globalThis.throwError(err, "Failed to create Redis client") catch {}; | ||
return .zero; | ||
} | ||
return .zero; | ||
}; |
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.
const valkey = JSC.API.Valkey.create(globalThis, &[_]JSValue{.undefined}) catch |err| { | |
if (err != error.JSError) { | |
_ = globalThis.throwError(err, "Failed to create Redis client") catch {}; | |
return .zero; | |
} | |
return .zero; | |
}; | |
const valkey = JSC.API.Valkey.create(globalThis, &[_]JSValue{.undefined}) catch |err| switch (err) { | |
error.JSError => return .zero, | |
error.OutOfMemory => return global.throwOutOfMemoryValue(), | |
}; |
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.
would be nice if these getters had JSError!JSValue
return types
this.client.socket = _socket(socket); | ||
|
||
// Do not allow half-open connections | ||
socket.close(.normal); |
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.
We dont need to call close here unless we pass LIBUS_SOCKET_ALLOW_HALF_OPEN
in options when connecting because we will call the on_end and close in the sequence, but should be a no-op
thanks bro |
What does this PR do?
fixes #18112
How did you verify your code works?
There are tests. Need to setup a managed redis before the CI will pass and work on the tests some more.