nats

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: 17 Imported by: 4

Documentation

Index

Constants

View Source
const (
	BusFmt = "[%v].NATS.New"
)
View Source
const (
	ListenerFmt = "%+v.NATSListener"
)
View Source
const (
	RequesterFmt = "NATS.Requester(%+v)"
)

Variables

This section is empty.

Functions

func IAmNATSBus

func IAmNATSBus(b INATSBus) bool

func ResponderFtor

func ResponderFtor[THope contract.IHope, TCmd behavior.ICmd](
	topic string,
	feature spokes.ISpoke,
	hope2Cmd behavior.Hope2CmdFunc[THope, TCmd],
) comps.GenResponderFtor[THope]

ResponderFtor is a generic functor that is discriminated by the feature's specific IHope and ICmd injectors.

Types

type BusFtor

type BusFtor func() (INATSBus, error)

func SingleNATS

func SingleNATS(config config.IAppConfig) BusFtor

SingleNATS returns functor that produces a guaranteed singleton instance of the NATS bus.

func TransientNATS

func TransientNATS(config config.IAppConfig) BusFtor

TransientNATS returns functor that produces a transient instance of the NATS bus.

type Emitter

type Emitter struct {
	*comps.EventReaction

	Topic behavior.EventType
	// contains filtered or unexported fields
}

func NewEmitter

func NewEmitter(
	topic behavior.EventType,
	emitFact comps.OnEvtFunc,
) (*Emitter, error)

func (*Emitter) IAmEmitter

func (e *Emitter) IAmEmitter()

type IEmitter

type IEmitter interface {
	comps.IEmitter
}

type IListener

type IListener[TFact contract.IFact, TCmd behavior.ICmd] interface {
	comps.IGenListener[*nats.Msg, TFact]
}

type INATSBus

type INATSBus interface {
	comps.IGenBus[*nats.Conn, *nats.Msg]
}

INATSBus is the Injector that hides driver specifics from the application.

type IRequester

type IRequester[THope contract.IHope] interface {
	comps.IGenRequester[THope]
}

type IResponder

type IResponder[THope contract.IHope, TCmd behavior.ICmd] interface {
	comps.IResponder
}

func NewResponder

func NewResponder[THope contract.IHope, TCmd behavior.ICmd](
	topic string,
	h2c behavior.Hope2CmdFunc[THope, TCmd]) (IResponder[THope, TCmd], error)

type Listener

type Listener[TCmd behavior.ICmd] struct {
	*comps.Component
	Topic string
	// contains filtered or unexported fields
}

func NewListener

func NewListener[TCmd behavior.ICmd](
	topic string,
	d2c behavior.GenData2CmdFunc[TCmd]) (*Listener[TCmd], error)

func (*Listener[TCmd]) Activate

func (l *Listener[TCmd]) Activate(ctx context.Context) error

func (*Listener[TCmd]) Deactivate

func (l *Listener[TCmd]) Deactivate(ctx context.Context) error

func (*Listener[TCmd]) IAmListener

func (l *Listener[TCmd]) IAmListener()

type Requester

type Requester[THope contract.IHope] struct {
	*comps.Component

	Topic string
	// contains filtered or unexported fields
}

func NewRequester

func NewRequester[THope contract.IHope](topic string) (*Requester[THope], error)

func (*Requester[THope]) GenRequest

func (r *Requester[THope]) GenRequest(ctx context.Context, hope THope, timeout time.Duration) contract.IFbk

func (*Requester[THope]) GenRequestAsync

func (r *Requester[THope]) GenRequestAsync(ctx context.Context, hope THope, timeout time.Duration) contract.IFbk

func (*Requester[THope]) GetHopeType

func (r *Requester[THope]) GetHopeType() contract.HopeType

func (*Requester[THope]) IAmRequester

func (r *Requester[THope]) IAmRequester()

func (*Requester[THope]) Request

func (r *Requester[THope]) Request(ctx context.Context, hope contract.IHope, timeout time.Duration) contract.IFbk

func (*Requester[THope]) RequestAsync

func (r *Requester[THope]) RequestAsync(ctx context.Context, hope contract.IHope, timeout time.Duration) contract.IFbk

type Responder

type Responder[THope contract.IHope, TCmd behavior.ICmd] struct {
	*comps.Component
	Topic string
	// contains filtered or unexported fields
}

func (*Responder[THope, TCmd]) Activate

func (r *Responder[THope, TCmd]) Activate(ctx context.Context) error

func (*Responder[THope, TCmd]) Deactivate

func (r *Responder[THope, TCmd]) Deactivate(ctx context.Context) error

Deactivate is called when the component is deactivated

func (*Responder[THope, TCmd]) GetHopeType

func (r *Responder[THope, TCmd]) GetHopeType() contract.HopeType

func (*Responder[THope, TCmd]) IAmResponder

func (r *Responder[THope, TCmd]) IAmResponder()

Jump to

Keyboard shortcuts

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