mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
b9aae0b2e3
* add spooler to eventstore * Update internal/eventstore/spooler/spooler.go Co-Authored-By: Silvan <silvan.reusser@gmail.com> * Update internal/eventstore/spooler/spooler_test.go Co-Authored-By: Silvan <silvan.reusser@gmail.com> * remove comments * fix race condition in test Co-authored-by: Silvan <silvan.reusser@gmail.com>
30 lines
715 B
Go
30 lines
715 B
Go
package spooler
|
|
|
|
import (
|
|
"github.com/caos/logging"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/sony/sonyflake"
|
|
"strconv"
|
|
)
|
|
|
|
type Config struct {
|
|
Eventstore eventstore.Eventstore
|
|
Locker Locker
|
|
ViewHandlers []Handler
|
|
ConcurrentTasks int
|
|
}
|
|
|
|
func (c *Config) New() *Spooler {
|
|
lockID, err := sonyflake.NewSonyflake(sonyflake.Settings{}).NextID()
|
|
logging.Log("SPOOL-bdO56").OnError(err).Panic("unable to generate lockID")
|
|
|
|
return &Spooler{
|
|
handlers: c.ViewHandlers,
|
|
lockID: strconv.FormatUint(lockID, 10),
|
|
eventstore: c.Eventstore,
|
|
locker: c.Locker,
|
|
queue: make(chan *spooledHandler),
|
|
concurrentTasks: c.ConcurrentTasks,
|
|
}
|
|
}
|