mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 07:12:46 +01:00
18 lines
404 B
Go
18 lines
404 B
Go
package hook
|
|
|
|
import "context"
|
|
|
|
type Hook struct {
|
|
subscribers []func(ctx context.Context, table string, record any)
|
|
}
|
|
|
|
func (h *Hook) Publish(ctx context.Context, table string, record any) {
|
|
for _, subscriber := range h.subscribers {
|
|
subscriber(ctx, table, record)
|
|
}
|
|
}
|
|
|
|
func (h *Hook) Subscribe(fn func(ctx context.Context, table string, record any)) {
|
|
h.subscribers = append(h.subscribers, fn)
|
|
}
|