fix: request cleanup jobs

This commit is contained in:
Jon Lundy
2022-12-19 10:50:38 -07:00
parent 7315759b20
commit 250395d6b3
18 changed files with 575 additions and 227 deletions

View File

@@ -16,10 +16,22 @@ type projector struct {
fns []func(event.Event) []event.Event
}
func New(ctx context.Context, fns ...func(event.Event) []event.Event) *projector {
func New(_ context.Context, fns ...func(event.Event) []event.Event) *projector {
return &projector{fns: fns}
}
func (p *projector) Apply(e *es.EventStore) {
up := e.Driver
for up != nil {
if op, ok := up.(*projector); ok {
op.AddProjections(p.fns...)
p.up = op.up
return
}
up = es.Unwrap(up)
}
p.up = e.Driver
e.Driver = p
}
@@ -39,6 +51,9 @@ func (s *projector) EventLog(ctx context.Context, streamID string) (driver.Event
l, err := s.up.EventLog(ctx, streamID)
return &wrapper{l, s}, err
}
func (s *projector) AddProjections(fns ...func(event.Event) []event.Event) {
s.fns = append(s.fns, fns...)
}
type wrapper struct {
up driver.EventLog