2020-04-29 10:11:13 +00:00
|
|
|
package spooler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/caos/logging"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2020-05-28 11:28:36 +00:00
|
|
|
"github.com/caos/zitadel/internal/id"
|
2020-04-29 10:11:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Eventstore eventstore.Eventstore
|
|
|
|
Locker Locker
|
|
|
|
ViewHandlers []Handler
|
|
|
|
ConcurrentTasks int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Config) New() *Spooler {
|
2020-05-28 11:28:36 +00:00
|
|
|
lockID, err := id.SonyFlakeGenerator.Next()
|
2020-04-29 10:11:13 +00:00
|
|
|
logging.Log("SPOOL-bdO56").OnError(err).Panic("unable to generate lockID")
|
|
|
|
|
|
|
|
return &Spooler{
|
|
|
|
handlers: c.ViewHandlers,
|
2020-05-28 11:28:36 +00:00
|
|
|
lockID: lockID,
|
2020-04-29 10:11:13 +00:00
|
|
|
eventstore: c.Eventstore,
|
|
|
|
locker: c.Locker,
|
|
|
|
queue: make(chan *spooledHandler),
|
|
|
|
concurrentTasks: c.ConcurrentTasks,
|
|
|
|
}
|
|
|
|
}
|