Skip to content

Instantly share code, notes, and snippets.

@decentral1se
Last active December 12, 2024 12:48
Show Gist options
  • Save decentral1se/dff0a1f0b18299226643f60c91ef7987 to your computer and use it in GitHub Desktop.
Save decentral1se/dff0a1f0b18299226643f60c91ef7987 to your computer and use it in GitHub Desktop.
incus listener add handler
// ...
listener, err := conn.GetEventsAllProjects()
_, err = listener.AddHandler(
[]string{
api.EventLifecycleInstanceCreated,
api.EventLifecycleInstanceReady,
api.EventLifecycleInstanceRestarted,
}, func(event api.Event) {
ctx.Logger().Debug("handling instance create event", zap.Any("event", event))
err := u.provisionCandidates(ctx, conn)
if err != nil {
ctx.Logger().Error("unable to provision candidates", zap.Error(err))
}
})
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment