Closed shayonj closed 1 day ago
Caller can now use it like this:
ctx, cancel := context.WithCancel(context.Background()) defer cancel() replicator, err := factory.CreateReplicator(config, natsClient) if err != nil { log.Fatal(err) } // Start replication if err := replicator.Start(ctx); err != nil { log.Fatal(err) } // Handle shutdown signal sigCh := make(chan os.Signal, 1) signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) <-sigCh // Stop replication shutdownCtx, shutdownCancel := context.WithTimeout(context.Background(), 30*time.Second) defer shutdownCancel() if err := replicator.Stop(shutdownCtx); err != nil { log.Error(err) }
Caller can now use it like this: