Skip to content

Commit b7fe3db

Browse files
committed
don't share Client.IO between clients
1 parent 568dd22 commit b7fe3db

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/telemetry/lightpanda.zig

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ const log = std.log.scoped(.telemetry);
1313
const URL = "https://telemetry.lightpanda.io";
1414

1515
pub const LightPanda = struct {
16+
loop: *Loop,
1617
uri: std.Uri,
17-
io: Client.IO,
1818
allocator: Allocator,
1919
sending_pool: std.heap.MemoryPool(Sending),
2020

2121
pub fn init(allocator: Allocator, loop: *Loop) !LightPanda {
22+
std.debug.print("{s}\n", .{@typeName(Client.IO)});
2223
return .{
24+
.loop = loop,
2325
.allocator = allocator,
24-
.io = Client.IO.init(loop),
2526
.uri = std.Uri.parse(URL) catch unreachable,
2627
.sending_pool = std.heap.MemoryPool(Sending).init(allocator),
2728
};
@@ -55,14 +56,15 @@ pub const LightPanda = struct {
5556
.ctx = undefined,
5657
.lightpanda = self,
5758
.request = undefined,
59+
.io = Client.IO.init(self.loop),
5860
.client = .{ .allocator = self.allocator },
5961
};
6062
sending.request = try sending.client.create(.POST, self.uri, .{
6163
.server_header_buffer = resp_header_buffer,
6264
});
6365
errdefer sending.request.deinit();
6466

65-
sending.ctx = try Client.Ctx.init(&self.io, &sending.request);
67+
sending.ctx = try Client.Ctx.init(&sending.io, &sending.request);
6668
errdefer sending.ctx.deinit();
6769

6870
try sending.client.async_open(
@@ -134,6 +136,7 @@ pub const LightPanda = struct {
134136
};
135137

136138
const Sending = struct {
139+
io: Client.IO,
137140
ctx: Client.Ctx,
138141
client: Client,
139142
body: []const u8,

0 commit comments

Comments
 (0)