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

Add NotifierChan helper #11

Merged
merged 1 commit into from
Jul 14, 2021
Merged

Add NotifierChan helper #11

merged 1 commit into from
Jul 14, 2021

Conversation

slok
Copy link
Owner

@slok slok commented Jul 14, 2021

Add helper to get notifiers from string channels.

There are times where a simple channel is enough for the Notifier, for example, an HTTP handler:

reloadManager := reload.NewManager()

// Add reload notifier.
reloadChan := make(chan string)
reloadManager.On(reload.NotifierChan(reloadChan))

// On HTTP request to `/-/reload` trigger reload.
mux := http.NewServeMux()
mux.Handle("/-/reload", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  reloadChan <- "http"
}))

Signed-off-by: Xabier Larrakoetxea <me@slok.dev>
@slok slok merged commit 29e5eaa into main Jul 14, 2021
@slok slok deleted the slok/notifier-chan branch July 14, 2021 05:14
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