mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
Redis PUB/SUB (#21728)
### What does this PR do? The goal of this PR is to introduce PUB/SUB functionality to the built-in Redis client. Based on the fact that the current Redis API does not appear to have compatibility with `io-redis` or `redis-node`, I've decided to do away with existing APIs and API compatibility with these existing libraries. I have decided to base my implementation on the [`redis-node` pub/sub API](https://github.com/redis/node-redis/blob/master/docs/pub-sub.md). ### How did you verify your code works? I've written a set of unit tests to hopefully catch the major use-cases of this feature. They all appear to pass: <img width="368" height="71" alt="image" src="https://github.com/user-attachments/assets/36527386-c8fe-47f6-b69a-a11d4b614fa0" /> #### Future Improvements I would have a lot more confidence in our Redis implementation if we tested it with a test suite running over a network which emulates a high network failure rate. There are large amounts of edge cases that are worthwhile to grab, but I think we can roll that out in a future PR. ### Future Tasks - [ ] Tests over flaky network - [ ] Use the custom private members over `_<member>`. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Dylan Conway <dylan.conway567@gmail.com> Co-authored-by: Alistair Smith <hi@alistair.sh>
This commit is contained in:
@@ -236,6 +236,15 @@ pub fn writable(this: *StringBuilder) []u8 {
|
||||
return ptr[this.len..this.cap];
|
||||
}
|
||||
|
||||
/// Transfer ownership of the underlying memory to a slice.
|
||||
///
|
||||
/// After calling this, you are responsible for freeing the underlying memory.
|
||||
/// This StringBuilder should not be used after calling this function.
|
||||
pub fn moveToSlice(this: *StringBuilder, into_slice: *[]u8) void {
|
||||
into_slice.* = this.allocatedSlice();
|
||||
this.* = .{};
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user