mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 19:14:23 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
30 lines
727 B
Go
30 lines
727 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
type HandlerConfig struct {
|
|
Eventstore *eventstore.Eventstore
|
|
}
|
|
type Handler struct {
|
|
Eventstore *eventstore.Eventstore
|
|
Sub *eventstore.Subscription
|
|
EventQueue chan eventstore.Event
|
|
}
|
|
|
|
func NewHandler(config HandlerConfig) Handler {
|
|
return Handler{
|
|
Eventstore: config.Eventstore,
|
|
EventQueue: make(chan eventstore.Event, 100),
|
|
}
|
|
}
|
|
|
|
func (h *Handler) Subscribe(aggregates ...eventstore.AggregateType) {
|
|
h.Sub = eventstore.SubscribeAggregates(h.EventQueue, aggregates...)
|
|
}
|
|
|
|
func (h *Handler) SubscribeEvents(types map[eventstore.AggregateType][]eventstore.EventType) {
|
|
h.Sub = eventstore.SubscribeEventTypes(h.EventQueue, types)
|
|
}
|