Skip to content
Snippets Groups Projects
option.go 690 B
Newer Older
package emitter

import (
	"context"

	"xbus.io/go-xbus/v4"

	"orus.io/orus-io/go-orusapi/cmd"
	"orus.io/orus-io/go-orusapi/xbus/emissionqueue/migration"
)

func WithXbusEmitter[E any]() cmd.Option[E] {
	return cmd.CombineOptions(
		cmd.WithSchema[E]("emissionqueue", migration.Source),
		cmd.WithXbusActors(func(program *cmd.Program[E]) []cmd.XbusActorFactory {
			return []cmd.XbusActorFactory{{
				Name: program.Name + ".emitter",
				Factory: xbus.NewActorServiceFunc(func(
					actor *xbus.Actor, settings xbus.Settings,
				) (xbus.ActorService, error) {
					return NewEmitter(
						context.TODO(), program.DB, actor, settings, program.Logger,
					), nil
				}),
			}}
		}),
	)
}