Documentation
¶
Index ¶
- func GetDefaultPublisherConfig() *outbox.PublisherConfig
- type MockAsyncEventPublisher
- func (m *MockAsyncEventPublisher) Clear()
- func (m *MockAsyncEventPublisher) Close()
- func (m *MockAsyncEventPublisher) GetPublishResultChannel() <-chan *outbox.PublishResult
- func (m *MockAsyncEventPublisher) GetPublishedEnvelopeCount() int
- func (m *MockAsyncEventPublisher) GetPublishedEnvelopes() []*outbox.Envelope
- func (m *MockAsyncEventPublisher) GetPublishedTopics() []string
- func (m *MockAsyncEventPublisher) PublishEnvelope(ctx context.Context, topic string, envelope *outbox.Envelope) error
- func (m *MockAsyncEventPublisher) SendACKFailure(eventID, topic, aggregateID, eventType string, err error)
- func (m *MockAsyncEventPublisher) SendACKSuccess(eventID, topic, aggregateID, eventType string)
- func (m *MockAsyncEventPublisher) SetPublishDelay(delay time.Duration)
- func (m *MockAsyncEventPublisher) SetPublishError(err error)
- type MockEventBusForAdapter
- func (m *MockEventBusForAdapter) Close() error
- func (m *MockEventBusForAdapter) ConfigureTopic(ctx context.Context, topic string, options eventbus.TopicOptions) error
- func (m *MockEventBusForAdapter) GetConnectionState() eventbus.ConnectionState
- func (m *MockEventBusForAdapter) GetHealthCheckPublisherStatus() eventbus.HealthCheckStatus
- func (m *MockEventBusForAdapter) GetHealthCheckSubscriberStats() eventbus.HealthCheckSubscriberStats
- func (m *MockEventBusForAdapter) GetHealthStatus() eventbus.HealthCheckStatus
- func (m *MockEventBusForAdapter) GetMetrics() eventbus.Metrics
- func (m *MockEventBusForAdapter) GetPublishResultChannel() <-chan *eventbus.PublishResult
- func (m *MockEventBusForAdapter) GetPublishedEnvelopeCount() int
- func (m *MockEventBusForAdapter) GetPublishedEnvelopes() []*eventbus.Envelope
- func (m *MockEventBusForAdapter) GetRegisteredTenants() []string
- func (m *MockEventBusForAdapter) GetTenantPublishResultChannel(tenantID string) <-chan *eventbus.PublishResult
- func (m *MockEventBusForAdapter) GetTopicConfig(topic string) (eventbus.TopicOptions, error)
- func (m *MockEventBusForAdapter) GetTopicConfigStrategy() eventbus.TopicConfigStrategy
- func (m *MockEventBusForAdapter) ListConfiguredTopics() []string
- func (m *MockEventBusForAdapter) Publish(ctx context.Context, topic string, message []byte) error
- func (m *MockEventBusForAdapter) PublishEnvelope(ctx context.Context, topic string, envelope *eventbus.Envelope) error
- func (m *MockEventBusForAdapter) PublishWithOptions(ctx context.Context, topic string, message []byte, ...) error
- func (m *MockEventBusForAdapter) RegisterHealthCheckPublisherCallback(callback eventbus.HealthCheckCallback) error
- func (m *MockEventBusForAdapter) RegisterHealthCheckSubscriberCallback(callback eventbus.HealthCheckAlertCallback) error
- func (m *MockEventBusForAdapter) RegisterPublishCallback(callback eventbus.PublishCallback) error
- func (m *MockEventBusForAdapter) RegisterPublisherBacklogCallback(callback eventbus.PublisherBacklogCallback) error
- func (m *MockEventBusForAdapter) RegisterReconnectCallback(callback eventbus.ReconnectCallback) error
- func (m *MockEventBusForAdapter) RegisterSubscriberBacklogCallback(callback eventbus.BacklogStateCallback) error
- func (m *MockEventBusForAdapter) RegisterSubscriptionCallback(callback eventbus.SubscriptionCallback) error
- func (m *MockEventBusForAdapter) RegisterTenant(tenantID string, bufferSize int) error
- func (m *MockEventBusForAdapter) RemoveTopicConfig(topic string) error
- func (m *MockEventBusForAdapter) SendACKFailure(eventID, topic, aggregateID, eventType string, err error)
- func (m *MockEventBusForAdapter) SendACKSuccess(eventID, topic, aggregateID, eventType string)
- func (m *MockEventBusForAdapter) SetErrorHandler(handler eventbus.ErrorHandler) error
- func (m *MockEventBusForAdapter) SetMessageFormatter(formatter eventbus.MessageFormatter) error
- func (m *MockEventBusForAdapter) SetMessageRouter(router eventbus.MessageRouter) error
- func (m *MockEventBusForAdapter) SetPublishError(err error)
- func (m *MockEventBusForAdapter) SetTopicConfigStrategy(strategy eventbus.TopicConfigStrategy)
- func (m *MockEventBusForAdapter) SetTopicPersistence(ctx context.Context, topic string, persistent bool) error
- func (m *MockEventBusForAdapter) Start(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartAllBacklogMonitoring(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartAllHealthCheck(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartHealthCheck(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartHealthCheckPublisher(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartHealthCheckSubscriber(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartPublisherBacklogMonitoring(ctx context.Context) error
- func (m *MockEventBusForAdapter) StartSubscriberBacklogMonitoring(ctx context.Context) error
- func (m *MockEventBusForAdapter) Stop() error
- func (m *MockEventBusForAdapter) StopAllBacklogMonitoring() error
- func (m *MockEventBusForAdapter) StopAllHealthCheck() error
- func (m *MockEventBusForAdapter) StopHealthCheck() error
- func (m *MockEventBusForAdapter) StopHealthCheckPublisher() error
- func (m *MockEventBusForAdapter) StopHealthCheckSubscriber() error
- func (m *MockEventBusForAdapter) StopPublisherBacklogMonitoring() error
- func (m *MockEventBusForAdapter) StopSubscriberBacklogMonitoring() error
- func (m *MockEventBusForAdapter) Subscribe(ctx context.Context, topic string, handler eventbus.MessageHandler) error
- func (m *MockEventBusForAdapter) SubscribeEnvelope(ctx context.Context, topic string, handler eventbus.EnvelopeHandler) error
- func (m *MockEventBusForAdapter) SubscribeWithOptions(ctx context.Context, topic string, handler eventbus.MessageHandler, ...) error
- func (m *MockEventBusForAdapter) UnregisterTenant(tenantID string) error
- type MockEventPublisher
- func (m *MockEventPublisher) Clear()
- func (m *MockEventPublisher) GetPublishResultChannel() <-chan *outbox.PublishResult
- func (m *MockEventPublisher) GetPublishedCount() int
- func (m *MockEventPublisher) GetPublishedData() [][]byte
- func (m *MockEventPublisher) GetPublishedTopics() []string
- func (m *MockEventPublisher) Publish(ctx context.Context, topic string, data []byte) error
- func (m *MockEventPublisher) PublishEnvelope(ctx context.Context, topic string, envelope *outbox.Envelope) error
- func (m *MockEventPublisher) SetPublishDelay(delay time.Duration)
- func (m *MockEventPublisher) SetPublishError(err error)
- type MockRepository
- func (m *MockRepository) BatchUpdate(ctx context.Context, events []*outbox.OutboxEvent) error
- func (m *MockRepository) Clear()
- func (m *MockRepository) Count(ctx context.Context, status outbox.EventStatus, tenantID string) (int64, error)
- func (m *MockRepository) CountByStatus(ctx context.Context, tenantID string) (map[outbox.EventStatus]int64, error)
- func (m *MockRepository) CountFailedEvents(ctx context.Context, tenantID string) (int64, error)
- func (m *MockRepository) CountPendingEvents(ctx context.Context, tenantID string) (int64, error)
- func (m *MockRepository) Delete(ctx context.Context, id string) error
- func (m *MockRepository) DeleteBatch(ctx context.Context, ids []string) error
- func (m *MockRepository) DeleteFailedBefore(ctx context.Context, before time.Time, tenantID string) (int64, error)
- func (m *MockRepository) DeletePublishedBefore(ctx context.Context, before time.Time, tenantID string) (int64, error)
- func (m *MockRepository) ExistsByIdempotencyKey(ctx context.Context, idempotencyKey string) (bool, error)
- func (m *MockRepository) FindByAggregateID(ctx context.Context, aggregateID string, tenantID string) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindByAggregateType(ctx context.Context, aggregateType string, limit int) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindByID(ctx context.Context, id string) (*outbox.OutboxEvent, error)
- func (m *MockRepository) FindByIdempotencyKey(ctx context.Context, key string) (*outbox.OutboxEvent, error)
- func (m *MockRepository) FindEventsForRetry(ctx context.Context, maxRetries int, limit int) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindFailedEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindMaxRetryEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindPendingEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindPendingEventsWithDelay(ctx context.Context, tenantID string, delaySeconds int, limit int) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) FindScheduledEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
- func (m *MockRepository) GetEventByID(id string) *outbox.OutboxEvent
- func (m *MockRepository) GetEventCount() int
- func (m *MockRepository) IncrementRetry(ctx context.Context, id string, errorMsg string) error
- func (m *MockRepository) IncrementRetryCount(ctx context.Context, id string) error
- func (m *MockRepository) MarkAsFailed(ctx context.Context, id string, err error) error
- func (m *MockRepository) MarkAsMaxRetry(ctx context.Context, id string, errorMsg string) error
- func (m *MockRepository) MarkAsPublished(ctx context.Context, id string) error
- func (m *MockRepository) Save(ctx context.Context, event *outbox.OutboxEvent) error
- func (m *MockRepository) SaveBatch(ctx context.Context, events []*outbox.OutboxEvent) error
- func (m *MockRepository) SetFindPendingError(err error)
- func (m *MockRepository) SetSaveError(err error)
- func (m *MockRepository) SetUpdateError(err error)
- func (m *MockRepository) Update(ctx context.Context, event *outbox.OutboxEvent) error
- type MockTopicMapper
- type TestHelper
- func (h *TestHelper) AssertContains(s, contains interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertEqual(expected, actual interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertError(err error, msgAndArgs ...interface{})
- func (h *TestHelper) AssertFalse(value bool, msgAndArgs ...interface{})
- func (h *TestHelper) AssertGreater(e1, e2 interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertNil(obj interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertNoError(err error, msgAndArgs ...interface{})
- func (h *TestHelper) AssertNotEmpty(obj interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertNotEqual(expected, actual interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertNotNil(obj interface{}, msgAndArgs ...interface{})
- func (h *TestHelper) AssertRegex(pattern, s string, msgAndArgs ...interface{})
- func (h *TestHelper) AssertTrue(value bool, msgAndArgs ...interface{})
- func (h *TestHelper) CreateTestEvent(tenantID, aggregateType, aggregateID, eventType string) *outbox.OutboxEvent
- func (h *TestHelper) CreateTestEventWithPayload(tenantID, aggregateType, aggregateID, eventType string, payload interface{}) *outbox.OutboxEvent
- func (h *TestHelper) RequireNoError(err error, msgAndArgs ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultPublisherConfig ¶
func GetDefaultPublisherConfig() *outbox.PublisherConfig
GetDefaultPublisherConfig 获取默认发布器配置
Types ¶
type MockAsyncEventPublisher ¶
type MockAsyncEventPublisher struct {
// contains filtered or unexported fields
}
MockAsyncEventPublisher 模拟异步事件发布器(支持 PublishEnvelope 和 ACK)
func NewMockAsyncEventPublisher ¶
func NewMockAsyncEventPublisher() *MockAsyncEventPublisher
NewMockAsyncEventPublisher 创建模拟异步事件发布器
func (*MockAsyncEventPublisher) GetPublishResultChannel ¶
func (m *MockAsyncEventPublisher) GetPublishResultChannel() <-chan *outbox.PublishResult
GetPublishResultChannel 获取发布结果通道(符合 EventPublisher 接口)
func (*MockAsyncEventPublisher) GetPublishedEnvelopeCount ¶
func (m *MockAsyncEventPublisher) GetPublishedEnvelopeCount() int
GetPublishedEnvelopeCount 获取已发布 Envelope 数量
func (*MockAsyncEventPublisher) GetPublishedEnvelopes ¶
func (m *MockAsyncEventPublisher) GetPublishedEnvelopes() []*outbox.Envelope
GetPublishedEnvelopes 获取已发布的 Envelope
func (*MockAsyncEventPublisher) GetPublishedTopics ¶
func (m *MockAsyncEventPublisher) GetPublishedTopics() []string
GetPublishedTopics 获取已发布主题
func (*MockAsyncEventPublisher) PublishEnvelope ¶
func (m *MockAsyncEventPublisher) PublishEnvelope(ctx context.Context, topic string, envelope *outbox.Envelope) error
PublishEnvelope 发布 Envelope(符合 EventPublisher 接口)
func (*MockAsyncEventPublisher) SendACKFailure ¶
func (m *MockAsyncEventPublisher) SendACKFailure(eventID, topic, aggregateID, eventType string, err error)
SendACKFailure 发送 ACK 失败结果
func (*MockAsyncEventPublisher) SendACKSuccess ¶
func (m *MockAsyncEventPublisher) SendACKSuccess(eventID, topic, aggregateID, eventType string)
SendACKSuccess 发送 ACK 成功结果
func (*MockAsyncEventPublisher) SetPublishDelay ¶
func (m *MockAsyncEventPublisher) SetPublishDelay(delay time.Duration)
SetPublishDelay 设置发布延迟
func (*MockAsyncEventPublisher) SetPublishError ¶
func (m *MockAsyncEventPublisher) SetPublishError(err error)
SetPublishError 设置发布错误
type MockEventBusForAdapter ¶
type MockEventBusForAdapter struct {
// contains filtered or unexported fields
}
MockEventBusForAdapter 用于测试 EventBus 适配器的 Mock EventBus 实现完整的 eventbus.EventBus 接口
func NewMockEventBusForAdapter ¶
func NewMockEventBusForAdapter() *MockEventBusForAdapter
NewMockEventBusForAdapter 创建用于适配器测试的 Mock EventBus
func (*MockEventBusForAdapter) Close ¶
func (m *MockEventBusForAdapter) Close() error
func (*MockEventBusForAdapter) ConfigureTopic ¶
func (m *MockEventBusForAdapter) ConfigureTopic(ctx context.Context, topic string, options eventbus.TopicOptions) error
func (*MockEventBusForAdapter) GetConnectionState ¶
func (m *MockEventBusForAdapter) GetConnectionState() eventbus.ConnectionState
func (*MockEventBusForAdapter) GetHealthCheckPublisherStatus ¶
func (m *MockEventBusForAdapter) GetHealthCheckPublisherStatus() eventbus.HealthCheckStatus
func (*MockEventBusForAdapter) GetHealthCheckSubscriberStats ¶
func (m *MockEventBusForAdapter) GetHealthCheckSubscriberStats() eventbus.HealthCheckSubscriberStats
func (*MockEventBusForAdapter) GetHealthStatus ¶
func (m *MockEventBusForAdapter) GetHealthStatus() eventbus.HealthCheckStatus
func (*MockEventBusForAdapter) GetMetrics ¶
func (m *MockEventBusForAdapter) GetMetrics() eventbus.Metrics
func (*MockEventBusForAdapter) GetPublishResultChannel ¶
func (m *MockEventBusForAdapter) GetPublishResultChannel() <-chan *eventbus.PublishResult
GetPublishResultChannel 获取发布结果通道(实现 eventbus.EventBus 接口)
func (*MockEventBusForAdapter) GetPublishedEnvelopeCount ¶
func (m *MockEventBusForAdapter) GetPublishedEnvelopeCount() int
GetPublishedEnvelopeCount 获取已发布 Envelope 数量
func (*MockEventBusForAdapter) GetPublishedEnvelopes ¶
func (m *MockEventBusForAdapter) GetPublishedEnvelopes() []*eventbus.Envelope
GetPublishedEnvelopes 获取已发布的 Envelope
func (*MockEventBusForAdapter) GetRegisteredTenants ¶ added in v1.1.22
func (m *MockEventBusForAdapter) GetRegisteredTenants() []string
GetRegisteredTenants 获取已注册的租户列表(Mock 实现)
func (*MockEventBusForAdapter) GetTenantPublishResultChannel ¶ added in v1.1.22
func (m *MockEventBusForAdapter) GetTenantPublishResultChannel(tenantID string) <-chan *eventbus.PublishResult
GetTenantPublishResultChannel 获取租户专属的 ACK Channel(Mock 实现)
func (*MockEventBusForAdapter) GetTopicConfig ¶
func (m *MockEventBusForAdapter) GetTopicConfig(topic string) (eventbus.TopicOptions, error)
func (*MockEventBusForAdapter) GetTopicConfigStrategy ¶
func (m *MockEventBusForAdapter) GetTopicConfigStrategy() eventbus.TopicConfigStrategy
func (*MockEventBusForAdapter) ListConfiguredTopics ¶
func (m *MockEventBusForAdapter) ListConfiguredTopics() []string
func (*MockEventBusForAdapter) PublishEnvelope ¶
func (m *MockEventBusForAdapter) PublishEnvelope(ctx context.Context, topic string, envelope *eventbus.Envelope) error
PublishEnvelope 发布 Envelope(实现 eventbus.EventBus 接口)
func (*MockEventBusForAdapter) PublishWithOptions ¶
func (m *MockEventBusForAdapter) PublishWithOptions(ctx context.Context, topic string, message []byte, opts eventbus.PublishOptions) error
func (*MockEventBusForAdapter) RegisterHealthCheckPublisherCallback ¶
func (m *MockEventBusForAdapter) RegisterHealthCheckPublisherCallback(callback eventbus.HealthCheckCallback) error
func (*MockEventBusForAdapter) RegisterHealthCheckSubscriberCallback ¶
func (m *MockEventBusForAdapter) RegisterHealthCheckSubscriberCallback(callback eventbus.HealthCheckAlertCallback) error
func (*MockEventBusForAdapter) RegisterPublishCallback ¶
func (m *MockEventBusForAdapter) RegisterPublishCallback(callback eventbus.PublishCallback) error
func (*MockEventBusForAdapter) RegisterPublisherBacklogCallback ¶
func (m *MockEventBusForAdapter) RegisterPublisherBacklogCallback(callback eventbus.PublisherBacklogCallback) error
func (*MockEventBusForAdapter) RegisterReconnectCallback ¶
func (m *MockEventBusForAdapter) RegisterReconnectCallback(callback eventbus.ReconnectCallback) error
func (*MockEventBusForAdapter) RegisterSubscriberBacklogCallback ¶
func (m *MockEventBusForAdapter) RegisterSubscriberBacklogCallback(callback eventbus.BacklogStateCallback) error
func (*MockEventBusForAdapter) RegisterSubscriptionCallback ¶
func (m *MockEventBusForAdapter) RegisterSubscriptionCallback(callback eventbus.SubscriptionCallback) error
func (*MockEventBusForAdapter) RegisterTenant ¶ added in v1.1.22
func (m *MockEventBusForAdapter) RegisterTenant(tenantID string, bufferSize int) error
RegisterTenant 注册租户(Mock 实现)
func (*MockEventBusForAdapter) RemoveTopicConfig ¶
func (m *MockEventBusForAdapter) RemoveTopicConfig(topic string) error
func (*MockEventBusForAdapter) SendACKFailure ¶
func (m *MockEventBusForAdapter) SendACKFailure(eventID, topic, aggregateID, eventType string, err error)
SendACKFailure 发送 ACK 失败结果
func (*MockEventBusForAdapter) SendACKSuccess ¶
func (m *MockEventBusForAdapter) SendACKSuccess(eventID, topic, aggregateID, eventType string)
SendACKSuccess 发送 ACK 成功结果
func (*MockEventBusForAdapter) SetErrorHandler ¶
func (m *MockEventBusForAdapter) SetErrorHandler(handler eventbus.ErrorHandler) error
func (*MockEventBusForAdapter) SetMessageFormatter ¶
func (m *MockEventBusForAdapter) SetMessageFormatter(formatter eventbus.MessageFormatter) error
func (*MockEventBusForAdapter) SetMessageRouter ¶
func (m *MockEventBusForAdapter) SetMessageRouter(router eventbus.MessageRouter) error
func (*MockEventBusForAdapter) SetPublishError ¶
func (m *MockEventBusForAdapter) SetPublishError(err error)
SetPublishError 设置发布错误
func (*MockEventBusForAdapter) SetTopicConfigStrategy ¶
func (m *MockEventBusForAdapter) SetTopicConfigStrategy(strategy eventbus.TopicConfigStrategy)
func (*MockEventBusForAdapter) SetTopicPersistence ¶
func (*MockEventBusForAdapter) Start ¶
func (m *MockEventBusForAdapter) Start(ctx context.Context) error
func (*MockEventBusForAdapter) StartAllBacklogMonitoring ¶
func (m *MockEventBusForAdapter) StartAllBacklogMonitoring(ctx context.Context) error
func (*MockEventBusForAdapter) StartAllHealthCheck ¶
func (m *MockEventBusForAdapter) StartAllHealthCheck(ctx context.Context) error
func (*MockEventBusForAdapter) StartHealthCheck ¶
func (m *MockEventBusForAdapter) StartHealthCheck(ctx context.Context) error
func (*MockEventBusForAdapter) StartHealthCheckPublisher ¶
func (m *MockEventBusForAdapter) StartHealthCheckPublisher(ctx context.Context) error
func (*MockEventBusForAdapter) StartHealthCheckSubscriber ¶
func (m *MockEventBusForAdapter) StartHealthCheckSubscriber(ctx context.Context) error
func (*MockEventBusForAdapter) StartPublisherBacklogMonitoring ¶
func (m *MockEventBusForAdapter) StartPublisherBacklogMonitoring(ctx context.Context) error
func (*MockEventBusForAdapter) StartSubscriberBacklogMonitoring ¶
func (m *MockEventBusForAdapter) StartSubscriberBacklogMonitoring(ctx context.Context) error
func (*MockEventBusForAdapter) Stop ¶
func (m *MockEventBusForAdapter) Stop() error
func (*MockEventBusForAdapter) StopAllBacklogMonitoring ¶
func (m *MockEventBusForAdapter) StopAllBacklogMonitoring() error
func (*MockEventBusForAdapter) StopAllHealthCheck ¶
func (m *MockEventBusForAdapter) StopAllHealthCheck() error
func (*MockEventBusForAdapter) StopHealthCheck ¶
func (m *MockEventBusForAdapter) StopHealthCheck() error
func (*MockEventBusForAdapter) StopHealthCheckPublisher ¶
func (m *MockEventBusForAdapter) StopHealthCheckPublisher() error
func (*MockEventBusForAdapter) StopHealthCheckSubscriber ¶
func (m *MockEventBusForAdapter) StopHealthCheckSubscriber() error
func (*MockEventBusForAdapter) StopPublisherBacklogMonitoring ¶
func (m *MockEventBusForAdapter) StopPublisherBacklogMonitoring() error
func (*MockEventBusForAdapter) StopSubscriberBacklogMonitoring ¶
func (m *MockEventBusForAdapter) StopSubscriberBacklogMonitoring() error
func (*MockEventBusForAdapter) Subscribe ¶
func (m *MockEventBusForAdapter) Subscribe(ctx context.Context, topic string, handler eventbus.MessageHandler) error
func (*MockEventBusForAdapter) SubscribeEnvelope ¶
func (m *MockEventBusForAdapter) SubscribeEnvelope(ctx context.Context, topic string, handler eventbus.EnvelopeHandler) error
func (*MockEventBusForAdapter) SubscribeWithOptions ¶
func (m *MockEventBusForAdapter) SubscribeWithOptions(ctx context.Context, topic string, handler eventbus.MessageHandler, opts eventbus.SubscribeOptions) error
func (*MockEventBusForAdapter) UnregisterTenant ¶ added in v1.1.22
func (m *MockEventBusForAdapter) UnregisterTenant(tenantID string) error
UnregisterTenant 注销租户(Mock 实现)
type MockEventPublisher ¶
type MockEventPublisher struct {
// contains filtered or unexported fields
}
MockEventPublisher 模拟事件发布器(旧版,已废弃,使用 MockAsyncEventPublisher)
func NewMockEventPublisher ¶
func NewMockEventPublisher() *MockEventPublisher
NewMockEventPublisher 创建模拟事件发布器
func (*MockEventPublisher) GetPublishResultChannel ¶
func (m *MockEventPublisher) GetPublishResultChannel() <-chan *outbox.PublishResult
GetPublishResultChannel 获取发布结果通道(符合 EventPublisher 接口)
func (*MockEventPublisher) GetPublishedCount ¶
func (m *MockEventPublisher) GetPublishedCount() int
GetPublishedCount 获取已发布事件数量
func (*MockEventPublisher) GetPublishedData ¶
func (m *MockEventPublisher) GetPublishedData() [][]byte
GetPublishedData 获取已发布数据
func (*MockEventPublisher) GetPublishedTopics ¶
func (m *MockEventPublisher) GetPublishedTopics() []string
GetPublishedTopics 获取已发布主题
func (*MockEventPublisher) PublishEnvelope ¶
func (m *MockEventPublisher) PublishEnvelope(ctx context.Context, topic string, envelope *outbox.Envelope) error
PublishEnvelope 发布 Envelope(符合 EventPublisher 接口)
func (*MockEventPublisher) SetPublishDelay ¶
func (m *MockEventPublisher) SetPublishDelay(delay time.Duration)
SetPublishDelay 设置发布延迟
func (*MockEventPublisher) SetPublishError ¶
func (m *MockEventPublisher) SetPublishError(err error)
SetPublishError 设置发布错误
type MockRepository ¶
type MockRepository struct {
// contains filtered or unexported fields
}
MockRepository 模拟仓储
func (*MockRepository) BatchUpdate ¶
func (m *MockRepository) BatchUpdate(ctx context.Context, events []*outbox.OutboxEvent) error
BatchUpdate 批量更新事件
func (*MockRepository) Count ¶
func (m *MockRepository) Count(ctx context.Context, status outbox.EventStatus, tenantID string) (int64, error)
Count 统计事件数量
func (*MockRepository) CountByStatus ¶
func (m *MockRepository) CountByStatus(ctx context.Context, tenantID string) (map[outbox.EventStatus]int64, error)
CountByStatus 按状态统计事件数量
func (*MockRepository) CountFailedEvents ¶
CountFailedEvents 统计失败事件数量
func (*MockRepository) CountPendingEvents ¶
CountPendingEvents 统计待发布事件数量
func (*MockRepository) Delete ¶
func (m *MockRepository) Delete(ctx context.Context, id string) error
Delete 删除事件
func (*MockRepository) DeleteBatch ¶
func (m *MockRepository) DeleteBatch(ctx context.Context, ids []string) error
DeleteBatch 批量删除事件
func (*MockRepository) DeleteFailedBefore ¶
func (m *MockRepository) DeleteFailedBefore(ctx context.Context, before time.Time, tenantID string) (int64, error)
DeleteFailedBefore 删除指定时间之前失败的事件
func (*MockRepository) DeletePublishedBefore ¶
func (m *MockRepository) DeletePublishedBefore(ctx context.Context, before time.Time, tenantID string) (int64, error)
DeletePublishedBefore 删除指定时间之前已发布的事件
func (*MockRepository) ExistsByIdempotencyKey ¶
func (m *MockRepository) ExistsByIdempotencyKey(ctx context.Context, idempotencyKey string) (bool, error)
ExistsByIdempotencyKey 检查幂等性键是否已存在
func (*MockRepository) FindByAggregateID ¶
func (m *MockRepository) FindByAggregateID(ctx context.Context, aggregateID string, tenantID string) ([]*outbox.OutboxEvent, error)
FindByAggregateID 根据聚合根 ID 查找事件
func (*MockRepository) FindByAggregateType ¶
func (m *MockRepository) FindByAggregateType(ctx context.Context, aggregateType string, limit int) ([]*outbox.OutboxEvent, error)
FindByAggregateType 根据聚合类型查找待发布事件
func (*MockRepository) FindByID ¶
func (m *MockRepository) FindByID(ctx context.Context, id string) (*outbox.OutboxEvent, error)
FindByID 根据 ID 查找事件
func (*MockRepository) FindByIdempotencyKey ¶
func (m *MockRepository) FindByIdempotencyKey(ctx context.Context, key string) (*outbox.OutboxEvent, error)
FindByIdempotencyKey 根据幂等性键查找事件
func (*MockRepository) FindEventsForRetry ¶
func (m *MockRepository) FindEventsForRetry(ctx context.Context, maxRetries int, limit int) ([]*outbox.OutboxEvent, error)
FindEventsForRetry 查找需要重试的事件
func (*MockRepository) FindFailedEvents ¶
func (m *MockRepository) FindFailedEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
FindFailedEvents 查找失败的事件
func (*MockRepository) FindMaxRetryEvents ¶
func (m *MockRepository) FindMaxRetryEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
FindMaxRetryEvents 查找超过最大重试次数的事件
func (*MockRepository) FindPendingEvents ¶
func (m *MockRepository) FindPendingEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
FindPendingEvents 查找待发布事件
func (*MockRepository) FindPendingEventsWithDelay ¶
func (m *MockRepository) FindPendingEventsWithDelay(ctx context.Context, tenantID string, delaySeconds int, limit int) ([]*outbox.OutboxEvent, error)
FindPendingEventsWithDelay 查找创建时间超过指定延迟的待发布事件
func (*MockRepository) FindScheduledEvents ¶
func (m *MockRepository) FindScheduledEvents(ctx context.Context, limit int, tenantID string) ([]*outbox.OutboxEvent, error)
FindScheduledEvents 查找计划发布的事件
func (*MockRepository) GetEventByID ¶
func (m *MockRepository) GetEventByID(id string) *outbox.OutboxEvent
GetEventByID 获取事件
func (*MockRepository) GetEventCount ¶
func (m *MockRepository) GetEventCount() int
GetEventCount 获取事件数量
func (*MockRepository) IncrementRetry ¶
IncrementRetry 增加重试次数
func (*MockRepository) IncrementRetryCount ¶
func (m *MockRepository) IncrementRetryCount(ctx context.Context, id string) error
IncrementRetryCount 增加重试次数(已废弃)
func (*MockRepository) MarkAsFailed ¶
MarkAsFailed 标记事件为失败
func (*MockRepository) MarkAsMaxRetry ¶
MarkAsMaxRetry 标记事件为超过最大重试次数
func (*MockRepository) MarkAsPublished ¶
func (m *MockRepository) MarkAsPublished(ctx context.Context, id string) error
MarkAsPublished 标记事件为已发布
func (*MockRepository) Save ¶
func (m *MockRepository) Save(ctx context.Context, event *outbox.OutboxEvent) error
Save 保存事件
func (*MockRepository) SaveBatch ¶
func (m *MockRepository) SaveBatch(ctx context.Context, events []*outbox.OutboxEvent) error
SaveBatch 批量保存事件
func (*MockRepository) SetFindPendingError ¶
func (m *MockRepository) SetFindPendingError(err error)
SetFindPendingError 设置查找待发布事件错误
func (*MockRepository) SetSaveError ¶
func (m *MockRepository) SetSaveError(err error)
SetSaveError 设置保存错误
func (*MockRepository) SetUpdateError ¶
func (m *MockRepository) SetUpdateError(err error)
SetUpdateError 设置更新错误
func (*MockRepository) Update ¶
func (m *MockRepository) Update(ctx context.Context, event *outbox.OutboxEvent) error
Update 更新事件
type MockTopicMapper ¶
type MockTopicMapper struct {
// contains filtered or unexported fields
}
MockTopicMapper 模拟 Topic 映射器
func NewMockTopicMapper ¶
func NewMockTopicMapper() *MockTopicMapper
NewMockTopicMapper 创建模拟 Topic 映射器
func (*MockTopicMapper) GetTopic ¶
func (m *MockTopicMapper) GetTopic(aggregateType string) string
GetTopic 获取 Topic(符合 TopicMapper 接口)
func (*MockTopicMapper) SetTopicMapping ¶
func (m *MockTopicMapper) SetTopicMapping(aggregateType, topic string)
SetTopicMapping 设置 Topic 映射
type TestHelper ¶
type TestHelper struct {
// contains filtered or unexported fields
}
TestHelper 测试辅助工具
func (*TestHelper) AssertContains ¶
func (h *TestHelper) AssertContains(s, contains interface{}, msgAndArgs ...interface{})
AssertContains 断言包含
func (*TestHelper) AssertEqual ¶
func (h *TestHelper) AssertEqual(expected, actual interface{}, msgAndArgs ...interface{})
AssertEqual 断言相等
func (*TestHelper) AssertError ¶ added in v1.1.23
func (h *TestHelper) AssertError(err error, msgAndArgs ...interface{})
AssertError 断言有错误
func (*TestHelper) AssertFalse ¶
func (h *TestHelper) AssertFalse(value bool, msgAndArgs ...interface{})
AssertFalse 断言为 false
func (*TestHelper) AssertGreater ¶
func (h *TestHelper) AssertGreater(e1, e2 interface{}, msgAndArgs ...interface{})
AssertGreater 断言大于
func (*TestHelper) AssertNil ¶
func (h *TestHelper) AssertNil(obj interface{}, msgAndArgs ...interface{})
AssertNil 断言为 nil
func (*TestHelper) AssertNoError ¶
func (h *TestHelper) AssertNoError(err error, msgAndArgs ...interface{})
AssertNoError 断言无错误
func (*TestHelper) AssertNotEmpty ¶
func (h *TestHelper) AssertNotEmpty(obj interface{}, msgAndArgs ...interface{})
AssertNotEmpty 断言非空
func (*TestHelper) AssertNotEqual ¶
func (h *TestHelper) AssertNotEqual(expected, actual interface{}, msgAndArgs ...interface{})
AssertNotEqual 断言两个值不相等
func (*TestHelper) AssertNotNil ¶
func (h *TestHelper) AssertNotNil(obj interface{}, msgAndArgs ...interface{})
AssertNotNil 断言不为 nil
func (*TestHelper) AssertRegex ¶
func (h *TestHelper) AssertRegex(pattern, s string, msgAndArgs ...interface{})
AssertRegex 断言字符串匹配正则表达式
func (*TestHelper) AssertTrue ¶
func (h *TestHelper) AssertTrue(value bool, msgAndArgs ...interface{})
AssertTrue 断言为 true
func (*TestHelper) CreateTestEvent ¶
func (h *TestHelper) CreateTestEvent(tenantID, aggregateType, aggregateID, eventType string) *outbox.OutboxEvent
CreateTestEvent 创建测试事件
func (*TestHelper) CreateTestEventWithPayload ¶
func (h *TestHelper) CreateTestEventWithPayload(tenantID, aggregateType, aggregateID, eventType string, payload interface{}) *outbox.OutboxEvent
CreateTestEventWithPayload 创建带自定义负载的测试事件
func (*TestHelper) RequireNoError ¶
func (h *TestHelper) RequireNoError(err error, msgAndArgs ...interface{})
RequireNoError 要求无错误