starting zero alloc parsing

This commit is contained in:
2026-01-07 17:26:10 -05:00
parent e2a60c9427
commit 96a3705069
6 changed files with 1001 additions and 914 deletions

View File

@@ -200,32 +200,30 @@ fn handleConnection(
var client_task = try io.concurrent(Client.start, .{ &client, io });
defer client_task.cancel(io) catch {};
// Messages are owned by the server after they are received from the client
while (client.next(server_allocator)) |msg| {
switch (msg) {
while (client.next(server_allocator)) |ctrl| {
switch (ctrl) {
.PING => {
// Respond to ping with pong.
try client.send(io, .PONG);
try client.recv_queue_write_lock.lock(io);
defer client.recv_queue_write_lock.unlock(io);
try client.send(io, "PONG\r\n");
},
.PUB => |pb| {
.PUB => {
@branchHint(.likely);
defer pb.deinit(server_allocator);
try server.publishMessage(io, server_allocator, &client, msg);
},
.HPUB => |hp| {
.HPUB => {
@branchHint(.likely);
defer hp.deinit(server_allocator);
try server.publishMessage(io, server_allocator, &client, msg);
},
.SUB => |sub| {
defer sub.deinit(server_allocator);
.SUB => {
try server.subscribe(io, server_allocator, client, id, sub);
},
.UNSUB => |unsub| {
.UNSUB => {
defer unsub.deinit(server_allocator);
try server.unsubscribe(io, server_allocator, id, unsub);
},
.CONNECT => |connect| {
.CONNECT => {
if (client.connect) |*current| {
current.deinit(server_allocator);
}