diff --git a/examples/main.zig b/examples/main.zig index 3634c0f..78cea67 100644 --- a/examples/main.zig +++ b/examples/main.zig @@ -326,11 +326,13 @@ pub fn main() anyerror!void { std.process.exit(1); } + // + // Connect to the seed node + // + // Define the seed node we will connect to. We use localhost:9042. const address = net.Address.initIp4([_]u8{ 127, 0, 0, 1 }, 9042); - // Connect to the seed node - // // The struct InitOptions can be used to control some aspects of the CQL client, // such as the protocol version, if compression is enabled, etc. @@ -362,7 +364,11 @@ pub fn main() anyerror!void { }, else => return err, }; - defer connection.close(); + defer connection.deinit(); + + // + // Connection established, create the client and do the thing. + // var client = cassandra.Client.initWithConnection(allocator, &connection, .{}); defer client.deinit(); diff --git a/src/connection.zig b/src/connection.zig index ad1b745..32600c1 100644 --- a/src/connection.zig +++ b/src/connection.zig @@ -136,8 +136,9 @@ pub const Connection = struct { try self.handshake(diags); } - pub fn close(self: *Self) void { + pub fn deinit(self: *Self) void { self.socket.close(); + self.message_writer.deinit(); } fn handshake(self: *Self, diags: *InitOptions.Diagnostics) !void {