Versions in this module Expand all Collapse all v0 v0.0.1 Jun 13, 2023 Changes in this version + const BusiPort + var BusiConf dtmcli.DBConf + var NodeNumber int64 = 1 + func ApplyAggregateChange(ctx context.Context, aggregate Aggregate, change aggregateChange) + func BaseAddRoute(app *gin.Engine) + func ExecuteLocalTransaction(ctx context.Context, es EventStore, eventsMessages []DomainEvent) error + func NewAggregateId() (id int64) + func NewDomainEventId() (id int64) + func NodeTime(snowflakeId int64) time.Time + func RunHTTP(app *gin.Engine) + func SetGrpcHeaderForDomainEvent(ctx context.Context, method string, req, reply interface{}, ...) error + func Startup(conf dtmimp.DBConf) *gin.Engine + func UnaryClientInterceptor() grpc.UnaryClientInterceptor + type AbstractAggregate struct + Id int64 + func (a *AbstractAggregate) Applied() (events []DomainEvent) + func (a *AbstractAggregate) Apply(agg Aggregate, aggChange aggregateChange) + func (a *AbstractAggregate) Identifier() (id int64) + func (a *AbstractAggregate) InitId() + type AbstractCommand struct + AggregateId string + type Aggregate interface + Applied func() (events []DomainEvent) + Apply func(agg Aggregate, event aggregateChange) + Identifier func() (id int64) + InitId func() + type Command interface + type CommandHandle func(ctx context.Context, command Command) (result interface{}, err error) + type Context struct + func NewContext(ctx context.Context, repository *Repository) Context + func (c *Context) Apply(aggregate Aggregate, change aggregateChange) + func (c *Context) Load(aggregate Aggregate) (has bool, err error) + func (c *Context) Save(aggregates ...Aggregate) (ok bool, err error) + type DBConfig struct + MaxIdleConnections int + MaxOpenConnections int + SqlDataSourceName string + type DomainEvent interface + AggregateId func() int64 + AggregateName func() string + EventBody func() protoreflect.ProtoMessage + EventBodyRaw func() ([]byte, error) + EventCreateTime func() time.Time + EventId func() int64 + EventName func() string + type DomainEventMessage struct + AggregateId int64 + AggregateName string + EventBody []byte + EventId int64 + EventName string + func (msg *DomainEventMessage) Decode(byteData []byte) (err error) + func (msg *DomainEventMessage) TopicName(eventBusName string) string + type DtmEventConsumerConfig struct + DomainName string + GroupName string + NameServers []string + type DtmEventProducer struct + Brokers []string + EventStore EventStore + Name string + Producer *dtmcli.Msg + func NewDtmEventProducer(ctx context.Context, config DtmEventProducerConfig) (eventProducer DtmEventProducer, err error) + func (p *DtmEventProducer) Send(ctx context.Context, eventMessages ...DomainEvent) (err error) + type DtmEventProducerConfig struct + DomainName string + DtmDBConf dtmimp.DBConf + EventStore *EventStore + NameServers []string + SubDomainName string + type EventBus interface + Await func() + Close func(ctx context.Context) (err error) + Name func() string + Recv func(ctx context.Context, topic string, handle EventHandle) (err error) + Send func(ctx context.Context, eventMessages ...DomainEventMessage) (err error) + Shutdown func() + Start func(ctx context.Context) (err error) + func NewLocalEventBus(name string) (bus EventBus) + type EventDecoder interface + Decode func(v interface{}) (err error) + RAW func() (raw []byte) + type EventHandle func(ctx context.Context, domainEvent DomainEvent) (err error, requeue bool) + type EventStore interface + CheckEvents func(ctx context.Context, events []StoredEvent) (err error) + GetDB func(ctx context.Context) *sql.DB + InitDomainEventStoreTable func(ctx context.Context, aggregateName string) + LoadSnapshot func(ctx context.Context, aggregateId int64, aggregate Aggregate) (lastEventId int64, err error) + MakeSnapshot func(ctx context.Context, aggregate Aggregate) (err error) + Name func() (name string) + ReadEvents func(ctx context.Context, aggregateName string, aggregateId int64, ...) (events []StoredEvent, err error) + StoreEvents func(ctx context.Context, events []StoredEvent) (err error) + func NewMysqlEventStore(ctx context.Context, config MysqlEventStoreConfig) (es EventStore, err error) + type JsonEventDecoder struct + func NewJsonEventDecoder(raw []byte) *JsonEventDecoder + func (d *JsonEventDecoder) Decode(v interface{}) (err error) + func (d *JsonEventDecoder) RAW() (raw []byte) + type LocalEventBus struct + func (bus *LocalEventBus) Await() + func (bus *LocalEventBus) Close(ctx context.Context) (err error) + func (bus *LocalEventBus) Name() string + func (bus *LocalEventBus) Recv(ctx context.Context, topic string, handle EventHandle) (err error) + func (bus *LocalEventBus) Send(ctx context.Context, eventMessages ...DomainEventMessage) (err error) + func (bus *LocalEventBus) Shutdown() + func (bus *LocalEventBus) Start(ctx context.Context) (err error) + type MysqlEventStoreConfig struct + DBConfig DBConfig + SubDomainName string + type RawEventDecoder struct + func NewRawEventDecoder(raw []byte) *RawEventDecoder + func (d *RawEventDecoder) Decode(v interface{}) (err error) + func (d *RawEventDecoder) RAW() (raw []byte) + type RegularEvent interface + type Repository struct + func NewRepository(ctx context.Context, config *RepositoryConfig) (r *Repository, err error) + func (r *Repository) Load(ctx context.Context, aggregate Aggregate) (has bool, err error) + func (r *Repository) RegisterAggregates(ctx context.Context, aggregates ...Aggregate) (err error) + func (r *Repository) Save(ctx context.Context, aggregates ...Aggregate) (ok bool, err error) + func (r *Repository) SetSaveListener(ctx context.Context, saveListener RepositorySaveListener) (err error) + type RepositoryConfig struct + DomainName string + DtmDBConf dtmimp.DBConf + MysqlEventStoreDBConfig DBConfig + RocketMqEventBusNameServers []string + SaveListener RepositorySaveListener + SubDomainName string + type RepositorySaveListener interface + Handle func(ctx context.Context, event DomainEventMessage) + type SampleDomainEvent struct + func (s *SampleDomainEvent) AggregateId() (id int64) + func (s *SampleDomainEvent) AggregateName() (name string) + func (s *SampleDomainEvent) EventBody() (body protoreflect.ProtoMessage) + func (s *SampleDomainEvent) EventBodyRaw() (bodyRaw []byte, err error) + func (s *SampleDomainEvent) EventCreateTime() (createTime time.Time) + func (s *SampleDomainEvent) EventId() (id int64) + func (s *SampleDomainEvent) EventName() (name string) + type StoredEvent interface + AggregateId func() int64 + AggregateName func() string + EventBodyRaw func() []byte + EventCreateTime func() time.Time + EventId func() int64 + EventName func() string