comps

package
v0.0.0-...-42841ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 20 Imported by: 10

Documentation

Index

Constants

View Source
const AllTopics = "*"
View Source
const (
	CmdHandlerFmt = "%+v.CmdHandler"
)
View Source
const EventReactionFmt = "%+v.EvtReaction"
View Source
const MsgReactionFmt = "%+v.MsgReaction"

Variables

This section is empty.

Functions

This section is empty.

Types

type BehaviorStoreFtor

type BehaviorStoreFtor func() IBehaviorStore

type BusFtor

type BusFtor func() (IBus, error)

BusFtor is a functor that returns a simple IBus injector.

type CmdHandlerFtor

type CmdHandlerFtor func() ICmdHandler

type CommandHandler

type CommandHandler interface {
	Handle(ctx context.Context, cmd behavior.ICmd) contract.IFbk
}

type Component

type Component struct {
	Name schema.Name
	// contains filtered or unexported fields
}

func NewComponent

func NewComponent(name schema.Name) *Component

func (*Component) GetConfig

func (a *Component) GetConfig() config.IAppConfig

func (*Component) GetLogger

func (a *Component) GetLogger() logger.IAppLogger

func (*Component) GetMediator

func (a *Component) GetMediator() mediator.IMediator

func (*Component) GetName

func (a *Component) GetName() schema.Name

type EventReaction

type EventReaction struct {
	*Component
	// contains filtered or unexported fields
}

EventReaction is a base structure for implementing specialized Reactions to Events

func NewEventReaction

func NewEventReaction(
	eventType behavior.EventType,
	react OnEvtFunc,
) *EventReaction

func (*EventReaction) Activate

func (er *EventReaction) Activate(ctx context.Context) error

Activate activates the Reaction and subscribes to the specific Event type on the Mediator

func (*EventReaction) Deactivate

func (er *EventReaction) Deactivate(ctx context.Context) error

func (*EventReaction) GetEventType

func (er *EventReaction) GetEventType() behavior.EventType

func (*EventReaction) React

func (er *EventReaction) React(ctx context.Context, evt behavior.IEvt) error

React is the function that is responsible for handling events.

func (*EventReaction) Subscribe

func (er *EventReaction) Subscribe(ctx context.Context, topic string, when OnEvtFunc, transactional bool) error

Subscribe connects the Reaction to a specific Event that appears on the Mediator

func (*EventReaction) SubscribeAll

func (er *EventReaction) SubscribeAll(ctx context.Context, when OnEvtFunc, transactional bool) error

SubscribeAll subscribes to all events that appear on the Mediator

func (*EventReaction) SubscribeAllAsync

func (er *EventReaction) SubscribeAllAsync(events chan behavior.IEvt, transactional bool) map[string]error

func (*EventReaction) SubscribeAsync

func (er *EventReaction) SubscribeAsync(events chan behavior.IEvt, transactional bool) error

func (*EventReaction) Unsubscribe

func (er *EventReaction) Unsubscribe(topic string, fn OnEvtFunc) error

func (*EventReaction) UnsubscribeAll

func (er *EventReaction) UnsubscribeAll(when OnEvtFunc) map[string]error

UnsubscribeAll disconnects the Reaction from all topics.

type EventStoreFtor

type EventStoreFtor func() IEventStore

type EvtReactionFtor

type EvtReactionFtor func() IEvtReaction

type GenBusFtor

type GenBusFtor[TConn interface{}, TMsg interface{}] func() (IGenBus[TConn, TMsg], error)

GenBusFtor is a generic functor that is discriminated by the Type of Connection and Message Type of the bus driver. that returns a IGenBus injector.

type GenCommandHandler

type GenCommandHandler[T behavior.ICmd] interface {
	Handle(ctx context.Context, cmd T) contract.IFbk
}

type GenEvtReactionFtor

type GenEvtReactionFtor[TEvt behavior.IEvt] func() IGenEvtReaction[TEvt]

type GenEvtReactor

type GenEvtReactor[TEvt behavior.IEvt] struct {
	*Component
	// contains filtered or unexported fields
}

func (*GenEvtReactor[TEvt]) Activate

func (er *GenEvtReactor[TEvt]) Activate(ctx context.Context) error

func (*GenEvtReactor[TEvt]) Deactivate

func (er *GenEvtReactor[TEvt]) Deactivate(ctx context.Context) error

func (*GenEvtReactor[TEvt]) GetEventType

func (er *GenEvtReactor[TEvt]) GetEventType() behavior.EventType

func (*GenEvtReactor[TEvt]) React

func (er *GenEvtReactor[TEvt]) React(ctx context.Context, evt TEvt) error

func (*GenEvtReactor[TEvt]) SubscribeAsync

func (er *GenEvtReactor[TEvt]) SubscribeAsync(events chan TEvt, transactional bool) error

type GenMediatorLoggerFtor

type GenMediatorLoggerFtor[TEvt behavior.IEvt] func() IGenMediatorLogger[TEvt]

type GenMsgReactionFtor

type GenMsgReactionFtor[TMsg schema.IMsg] func() IGenMsgReaction[TMsg]

type GenProjFtor

type GenProjFtor[TEvt behavior.IEvt, TState schema.ISchema] func() IGenProjection[TEvt, TState]

type GenProjection

type GenProjection[TEvt behavior.IEvt, TState schema.ISchema] struct {
	*EventReaction
	// contains filtered or unexported fields
}

func NewProjection

func NewProjection[TEvt behavior.IEvt, TState schema.ISchema](
	name schema.Name,
	eventType behavior.EventType,
	newStore behavior.StoreFtor[TState],
	evt2Doc behavior.Evt2DocFunc[TEvt, TState],
	newDoc schema.DocFtor[TState],
	getDocKey schema.GetDocKeyFunc) *GenProjection[TEvt, TState]

func (*GenProjection[TEvt, TState]) IAmProjection

func (ph *GenProjection[TEvt, TState]) IAmProjection()

type GenProjectionFtor

type GenProjectionFtor[TEvt behavior.IEvt, TState schema.ISchema] func() IGenProjection[TEvt, TState]

type GenReactFunc

type GenReactFunc[TEvt behavior.IEvt] func(ctx context.Context, evt TEvt) error

type GenRequesterFtor

type GenRequesterFtor[THope contract.IHope] func() (IGenRequester[THope], error)

type GenResponderFtor

type GenResponderFtor[THope contract.IHope] func() IGenResponder[THope]

type IActivate

type IActivate interface {
	Activate(ctx context.Context) error
}

type IBehaviorStore

type IBehaviorStore interface {
	IClose
	Load(ctx context.Context, behavior behavior.IBehavior) error
	Save(ctx context.Context, behavior behavior.IBehavior) error
	Exists(ctx context.Context, streamID string) error
}

type IBus

type IBus interface {
	Close()
	Publish(ctx context.Context, topic string, data []byte) error
	Request(ctx context.Context, topic string, data []byte, timeout time.Duration) ([]byte, error)
	RequestAsync(ctx context.Context, topic string, data []byte, timeout time.Duration, responses chan []byte) func() error
	Listen(ctx context.Context, topic string, facts chan []byte)
	ListenAsync(ctx context.Context, topic string, facts chan []byte) func() error
	Wait() error
}

IBus is an interface to a Bus. Will be replaced with IGenBus

type IClose

type IClose interface {
	Close() error
}

type ICmdHandler

type ICmdHandler interface {
	IComponent
	CommandHandler
}

ICmdHandler is an interface to a Command Handler. Will be replaced with IGenCmdHandler

type IComponent

type IComponent interface {
	GetMediator() mediator.IMediator
	GetName() schema.Name
	GetLogger() logger.IAppLogger
	GetConfig() config.IAppConfig
}

type IConnection

type IConnection[TConn interface{}] interface {
	Connection() TConn
}

type IDeactivate

type IDeactivate interface {
	Deactivate(ctx context.Context) error
}

type IEmitter

type IEmitter interface {
	ISpokePlugin
	IMediatorReaction
	IAmEmitter()
}

IEmitter is the injector for components that emit facts to message brokers. It specializes the IMediatorReaction as it registers at the mediator, where it listens for specific events that must be emitted from the domain to other systems.

type IEventStore

type IEventStore interface {
	IBehaviorStore
	ISnapshotStore
	SaveEvents(ctx context.Context, streamID string, events []behavior.IEvt) error
	LoadEvents(ctx context.Context, streamID string) ([]behavior.IEvt, error)
}

type IEvtReaction

type IEvtReaction interface {
	IMediatorReaction
}

type IGenBus

type IGenBus[TConn interface{}, TMsg interface{}] interface {
	IBus
	IConnection[TConn]
	Respond(ctx context.Context, topic string, hopes chan TMsg)
	RespondAsync(ctx context.Context, topic string, hopes chan TMsg) func() error
}

type IGenCmdHandler

type IGenCmdHandler[T behavior.ICmd] interface {
	GenCommandHandler[T]
	GetTopic() behavior.Topic
	GetBehaviorStore() IBehaviorStore
	GetBehavior(ID schema.IIdentity) behavior.IBehavior
	SetTopic(topic behavior.Topic)
}

IGenCmdHandler is a Command Handler for a specific ICmd

type IGenEvtReaction

type IGenEvtReaction[TEvt behavior.IEvt] interface {
	IGenMediatorReaction[TEvt]
}

func NewGenEvtHandler

func NewGenEvtHandler[TEvt behavior.IEvt](eventType behavior.EventType,
	onEvt OnEvtFunc) IGenEvtReaction[TEvt]

type IGenListener

type IGenListener[TMsg interface{}, TFact contract.IFact] interface {
	IListener
}

type IGenMediatorLogger

type IGenMediatorLogger[TEvt behavior.IEvt] interface {
	IGenEvtReaction[TEvt]
}

type IGenMediatorReaction

type IGenMediatorReaction[TEvt behavior.IEvt] interface {
	ISpokePlugin
	behavior.IGetEvtType
	behavior.IGenReacter[TEvt]
}

type IGenMsgReaction

type IGenMsgReaction[TMsg schema.IMsg] interface {
	IMsgReaction
	GenWhen(ctx context.Context, msg TMsg)
}

type IGenProjection

type IGenProjection[TEvt behavior.IEvt, TState schema.ISchema] interface {
	IProjection
}

type IGenRequester

type IGenRequester[THope contract.IHope] interface {
	IRequester
	GenRequest(ctx context.Context, hope THope, timeout time.Duration) contract.IFbk
	GenRequestAsync(ctx context.Context, hope THope, timeout time.Duration) contract.IFbk
}

IGenRequester is an Injector to a Hope Request Handler.

type IGenResponder

type IGenResponder[THope contract.IHope] interface {
	IResponder
}

type IListener

type IListener interface {
	ISpokePlugin
	IAmFactListener()
}

IListener is an injector for all components that listen for Facts on a message bus.

type IMediatorLogger

type IMediatorLogger interface {
	IEvtReaction
}

func GeneralMediatorLogger

func GeneralMediatorLogger() IMediatorLogger

func NewMediatorLogger

func NewMediatorLogger(topic behavior.EventType) IMediatorLogger

type IMediatorReaction

type IMediatorReaction interface {
	ISpokePlugin
	behavior.IGetEvtType
	behavior.Reacter
}

IMediatorReaction is an Injector for a mediator Subscriber. Will be replaced with IGenMediatorReaction at some point.

type IMsgReaction

type IMsgReaction interface {
	ISpokePlugin
}

type IPolicy

type IPolicy interface {
	IMediatorReaction
	IAmPolicy()
}

type IProjection

type IProjection interface {
	IMediatorReaction
	IAmProjection()
}

type IProjector

type IProjector interface {
	ISpokePlugin
	behavior.Reacter
	Project(ctx context.Context, prefixes []string, poolSize int) error
	Inject(handlers ...IProjection)
}

type IQueryProvider

type IQueryProvider interface {
	ISpokePlugin
	IAmQueryProvider()
	RunQuery(ctx context.Context, qry contract.IReq) contract.IRsp
}

type IRequester

type IRequester interface {
	IComponent
	IAmRequester()
	GetHopeType() contract.HopeType
	Request(ctx context.Context, hope contract.IHope, timeout time.Duration) contract.IFbk
	RequestAsync(ctx context.Context, hope contract.IHope, timeout time.Duration) contract.IFbk
}

type IResponder

type IResponder interface {
	ISpokePlugin
	IAmResponder()
	GetHopeType() contract.HopeType
}

type IShutdown

type IShutdown interface {
	Shutdown(ctx context.Context)
}

type ISnapshotStore

type ISnapshotStore interface {
	SaveSnapshot(ctx context.Context, aggregate behavior.IBehavior) error
	GetSnapshot(ctx context.Context, id string) (*behavior.Snapshot, error)
}

type ISpokePlugin

type ISpokePlugin interface {
	IComponent
	IActivate
	IDeactivate
}

ISpokePlugin is a base Injector for Spoke plugins

type IStore

type IStore interface {
	Load(id string) interface{}
	Save(id string, model interface{})
}

type MediatorLoggerFtor

type MediatorLoggerFtor func() IMediatorLogger

func NewMediatorLoggerFtor

func NewMediatorLoggerFtor(topic behavior.EventType) MediatorLoggerFtor

type MsgReaction

type MsgReaction struct {
	*Component
	// contains filtered or unexported fields
}

func NewMsgReaction

func NewMsgReaction(
	msgType schema.MsgType,
	react OnMsgFunc,
) *MsgReaction

func (*MsgReaction) Activate

func (h *MsgReaction) Activate(ctx context.Context) error

func (*MsgReaction) Deactivate

func (h *MsgReaction) Deactivate(ctx context.Context) error

func (*MsgReaction) GetMsgType

func (h *MsgReaction) GetMsgType() schema.MsgType

func (*MsgReaction) Subscribe

func (h *MsgReaction) Subscribe(ctx context.Context, topic string, when OnMsgFunc, transactional bool) error

func (*MsgReaction) SubscribeAll

func (h *MsgReaction) SubscribeAll(ctx context.Context, when OnMsgFunc, transactional bool) error

func (*MsgReaction) SubscribeAllAsync

func (h *MsgReaction) SubscribeAllAsync(msgs chan schema.IMsg, transactional bool) map[string]error

func (*MsgReaction) SubscribeAsync

func (h *MsgReaction) SubscribeAsync(msgs chan schema.IMsg, transactional bool) error

func (*MsgReaction) Unsubscribe

func (h *MsgReaction) Unsubscribe(topic string, fn OnMsgFunc) error

func (*MsgReaction) UnsubscribeAll

func (h *MsgReaction) UnsubscribeAll(when OnMsgFunc) map[string]error

func (*MsgReaction) When

func (h *MsgReaction) When(ctx context.Context, msg schema.IMsg) error

type MsgReactionFtor

type MsgReactionFtor func() IMsgReaction

type OnEvtFunc

type OnEvtFunc func(ctx context.Context, evt behavior.IEvt) error

type OnMsgFunc

type OnMsgFunc func(ctx context.Context, msg schema.IMsg) error

type Policy

type Policy struct {
	*EventReaction
	NewCH CmdHandlerFtor
}

func NewPolicy

func NewPolicy(
	name schema.Name,
	eventType behavior.EventType,
	onEvt OnEvtFunc,
	newCH CmdHandlerFtor,
) *Policy

func (*Policy) IAmPolicy

func (h *Policy) IAmPolicy()

type ProjFtor

type ProjFtor[TEvt behavior.IEvt, TState schema.ISchema] func() IProjection

type ProjectorBuilder

type ProjectorBuilder func(newProj ProjectorFtor) IProjector

type ProjectorFtor

type ProjectorFtor func() IProjector

type QryProvider

type QryProvider[TReadModel schema.ISchema] struct {
	*Component
	// contains filtered or unexported fields
}

func NewQryProvider

func NewQryProvider[TReadModel schema.ISchema](
	name schema.Name,
	storeFtor behavior.StoreFtor[TReadModel],
	qryWorker QryWorker[TReadModel],
) *QryProvider[TReadModel]

func (*QryProvider[TReadModel]) IAmQryProvider

func (p *QryProvider[TReadModel]) IAmQryProvider()

func (*QryProvider[TReadModel]) RunQuery

func (p *QryProvider[TReadModel]) RunQuery(ctx context.Context, qry contract.IReq) contract.IRsp

type QryWorker

type QryWorker[TReadModel schema.ISchema] func(ctx context.Context, store behavior.IModelStore[TReadModel], qry contract.IReq) contract.IRsp

type RequesterFtor

type RequesterFtor func() (IRequester, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL