- Add EventPublisher interface in biz layer for domain event publishing - Wire EventBusPublisher (Watermill EventBus adapter) into FileUsecase, FolderUsecase, ShareUsecase - Publish events after UploadFile, DeleteFile, CreateFolder, DeleteFolder, CreateShare - Implement CQRSHandler with logging event handlers for all 6 event types - Register event handlers via CQRSBus.RegisterHandlers using Watermill EventProcessor - Store subscriber and wmLogger in CQRSBus for EventProcessor wiring - Expose SqlDB() on Data struct for Watermill SQL pub/sub - Start Watermill router in goroutine alongside Kratos app with graceful close - Use appContext wrapper struct to pass CQRSBus through Wire DI graph
21 lines
534 B
Go
21 lines
534 B
Go
package watermark
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// EventBusPublisher implements biz.EventPublisher using Watermill EventBus.
|
|
type EventBusPublisher struct {
|
|
bus *CQRSBus
|
|
}
|
|
|
|
// NewEventBusPublisher creates a new EventBusPublisher from a CQRSBus.
|
|
func NewEventBusPublisher(bus *CQRSBus) *EventBusPublisher {
|
|
return &EventBusPublisher{bus: bus}
|
|
}
|
|
|
|
// Publish publishes a domain event via the Watermill EventBus.
|
|
func (p *EventBusPublisher) Publish(ctx context.Context, event interface{}) error {
|
|
return p.bus.EventBus.Publish(ctx, event)
|
|
}
|