From db136b8f807a2cb4b13bc11391b2d682604160c6 Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Thu, 5 Mar 2026 11:14:34 +0000 Subject: [PATCH] feat: add Close() to mongoClient for graceful shutdown Add io.Closer implementation to mongoClient so callers can type-assert StoreClient to io.Closer and disconnect the connection pool during graceful shutdown. Without this, the MongoDB driver pool leaks until process exit. --- db/mongo.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/mongo.go b/db/mongo.go index c2782ab..93d67ed 100644 --- a/db/mongo.go +++ b/db/mongo.go @@ -555,3 +555,10 @@ func (c *mongoClient) GetCollection(dbName, col string) StoreCollection { func (c *mongoClient) HealthCheck(ctx context.Context) error { return c.client.Ping(ctx, nil) } + +// Close disconnects the underlying MongoDB driver client, releasing its +// connection pool. Implements io.Closer so callers can type-assert +// StoreClient to io.Closer for graceful shutdown. +func (c *mongoClient) Close() error { + return c.client.Disconnect(context.Background()) +}