Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move towards simpler interfaces and good lifecycle management hygiene #52

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

shayonj
Copy link
Collaborator

@shayonj shayonj commented Nov 16, 2024

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)
}

@shayonj shayonj force-pushed the s/cleaner branch 3 times, most recently from d49d849 to dbf12c0 Compare November 16, 2024 18:23
@shayonj shayonj merged commit 33ee371 into main Nov 16, 2024
15 checks passed
@shayonj shayonj deleted the s/cleaner branch November 16, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant