cqrs

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventBusConfig

type EventBusConfig struct {

	// 错误重试次数
	Retry int
	// 在发布事件前触发
	OnPublishBefore OnEventSendFn
	// 在发布事件后触发
	OnPublishAfter OnEventSendFn
	// 触发发布错误
	OnError OnEventErrorFn
	// 序列化器
	Marshaler Marshaler
}

type Handler

type Handler struct {
	E              event.IntegrationEvent // event_interface
	UnSubscription chan int
	OnSubscription chan int
}

type IEventBus

type IEventBus interface {
	// Subscribe 事件模型订阅
	Subscribe(ctx context.Context, e event.IntegrationEvent, h event.IDynamicIntegrationEventHandler)
	// SubscribeDynamic 根据事件名称进行订阅
	SubscribeDynamic(ctx context.Context, e string, h event.IDynamicIntegrationEventHandler)
	// SubscribeToDelay 延时订阅
	SubscribeToDelay(e event.IntegrationEvent, h event.IDynamicIntegrationEventHandler)
	// UnSubscribe 取消订阅
	UnSubscribe(e event.IntegrationEvent)
	// UnsubscribeDynamic 根据事件名称取消订阅
	UnsubscribeDynamic(e string)
	// Publish 推送事件
	Publish(e ...event.IntegrationEvent)
	// PublishToDelay 延时发布
	PublishToDelay(time time.Duration, e ...event.IntegrationEvent)
	// Disposable 销毁资源
	Disposable() error
}

IEventBus 事件基本模型

type IEventBusSubscriptionsManager

type IEventBusSubscriptionsManager struct {
	// contains filtered or unexported fields
}
var SubscriptionsManager *IEventBusSubscriptionsManager

func (*IEventBusSubscriptionsManager) AddDynamicSubscription

func (c *IEventBusSubscriptionsManager) AddDynamicSubscription(eventName string)

func (*IEventBusSubscriptionsManager) AddSubscription

func (c *IEventBusSubscriptionsManager) AddSubscription(event event.IntegrationEvent)

func (*IEventBusSubscriptionsManager) Clear

func (c *IEventBusSubscriptionsManager) Clear()

func (*IEventBusSubscriptionsManager) DynamicUnSubscription

func (c *IEventBusSubscriptionsManager) DynamicUnSubscription(eventName string)

func (*IEventBusSubscriptionsManager) GetHandle

func (c *IEventBusSubscriptionsManager) GetHandle(name string) *Handler

func (*IEventBusSubscriptionsManager) GetSubscription

func (c *IEventBusSubscriptionsManager) GetSubscription(eventName string) event.IntegrationEvent

func (*IEventBusSubscriptionsManager) RemoveDynamicSubscription

func (c *IEventBusSubscriptionsManager) RemoveDynamicSubscription(eventName string)

func (*IEventBusSubscriptionsManager) RemoveSubscription

func (c *IEventBusSubscriptionsManager) RemoveSubscription(event event.IntegrationEvent)

func (*IEventBusSubscriptionsManager) UnSubscription

func (c *IEventBusSubscriptionsManager) UnSubscription(event event.IntegrationEvent)

type JsonMarshaler

type JsonMarshaler struct{}

func (JsonMarshaler) Marshal

func (m JsonMarshaler) Marshal(v interface{}) (*message.Message, error)

func (JsonMarshaler) Unmarshal

func (JsonMarshaler) Unmarshal(msg *message.Message, v interface{}) (err error)

type Marshaler

type Marshaler interface {
	Marshal(v interface{}) (*message.Message, error)
	Unmarshal(msg *message.Message, v interface{}) (err error)
}

type OnEventErrorFn

type OnEventErrorFn func(params OnEventErrorParams)

type OnEventErrorParams

type OnEventErrorParams struct {
	UId       uuid.UUID
	EventName string
	Message   *message.Message
	// contains filtered or unexported fields
}

type OnEventRemove

type OnEventRemove func(eventName string) error

type OnEventSendFn

type OnEventSendFn func(params OnEventSendParams) error

type OnEventSendParams

type OnEventSendParams struct {
	UId       uuid.UUID
	EventName string
	Message   *message.Message
	// contains filtered or unexported fields
}

type ProtobufMarshaler

type ProtobufMarshaler struct{}

func (ProtobufMarshaler) Marshal

func (m ProtobufMarshaler) Marshal(v interface{}) (*message.Message, error)

func (ProtobufMarshaler) Unmarshal

func (ProtobufMarshaler) Unmarshal(msg *message.Message, v interface{}) (err error)

Directories

Path Synopsis
contrib

Jump to

Keyboard shortcuts

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