From ed870db6f919c338deb6ba6a3432b6f4f3ba7d62 Mon Sep 17 00:00:00 2001 From: Prabhjot Singh Sethi Date: Fri, 2 May 2025 12:33:42 +0000 Subject: [PATCH] Enable sync initializationg without specifying db name Signed-off-by: Prabhjot Singh Sethi --- sync/owner.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sync/owner.go b/sync/owner.go index 1146fac..ecd22f6 100644 --- a/sync/owner.go +++ b/sync/owner.go @@ -19,6 +19,9 @@ import ( ) const ( + // Store/Database name for the ownership table + ownerShipDatabase = "sync" + // collection name for sync ownership table ownerShipCollection = "owner-table" @@ -197,3 +200,14 @@ func InitializeOwnerWithUpdateInterval(ctx context.Context, store db.Store, name // allocate owner entry context return ownerTable.allocateOwner(name) } + +// Initialize the Sync Owner management constructs, anyone while working with +// this library requires to use this function before actually start consuming +// any functionality from here. +// This function falls back to using the default database, ensuring common +// definition for all the consuming processes to ensure synchronisation to work +// in a seemless manner +func InitializeOwnerTableDefault(ctx context.Context, client db.StoreClient, name string) error { + store := client.GetDataStore(ownerShipDatabase) + return InitializeOwnerWithUpdateInterval(ctx, store, name, defaultOwnerUpdateInterval) +}