atproto utils for zig zat.dev
atproto sdk zig

add optional onConnect callback to JetstreamClient

exposes which host the client connected to, enabling callers to track
the current relay. follows the same comptime @hasDecl pattern as onError.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+5
+5
src/internal/streaming/jetstream.zig
··· 147 147 /// subscribe with a user-provided handler. 148 148 /// handler must implement: fn onEvent(*@TypeOf(handler), Event) void 149 149 /// optional: fn onError(*@TypeOf(handler), anyerror) void 150 + /// optional: fn onConnect(*@TypeOf(handler), []const u8) void — called with host on connect 150 151 /// blocks forever — reconnects with exponential backoff on disconnect. 151 152 /// rotates through hosts on each reconnect attempt. 152 153 pub fn subscribe(self: *JetstreamClient, handler: anytype) void { ··· 205 206 configureKeepalive(&client); 206 207 207 208 log.info("jetstream connected to {s}", .{host}); 209 + 210 + if (comptime @hasDecl(@TypeOf(handler.*), "onConnect")) { 211 + handler.onConnect(host); 212 + } 208 213 209 214 var ws_handler = WsHandler(@TypeOf(handler.*)){ 210 215 .allocator = self.allocator,