Skip to content

Commit

Permalink
Use specific message interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Aug 15, 2024
1 parent 2d6ad8f commit 1b62ea8
Show file tree
Hide file tree
Showing 36 changed files with 298 additions and 326 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ The format is based on [Keep a Changelog], and this project adheres to
### Changed

- Bumped minimum Go version to 1.22.
- Use `dogma.Command`, `Event` and `Timeout` interfaces instead of
`dogma.Message` where appropriate.

## [0.13.3] - 2024-08-15

Expand Down
10 changes: 5 additions & 5 deletions static/testdata/apps/app-level-messages/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Aggregate struct{}

// ApplyEvent updates the aggregate instance to reflect the occurrence of an
// event that was recorded against this instance.
func (Aggregate) ApplyEvent(m dogma.Message) {}
func (Aggregate) ApplyEvent(dogma.Event) {}

// AggregateHandler is a test implementation of dogma.AggregateMessageHandler.
type AggregateHandler struct{}
Expand All @@ -33,14 +33,14 @@ func (AggregateHandler) Configure(c dogma.AggregateConfigurer) {

// RouteCommandToInstance returns the ID of the aggregate instance that is
// targetted by m.
func (AggregateHandler) RouteCommandToInstance(m dogma.Message) string {
func (AggregateHandler) RouteCommandToInstance(dogma.Command) string {
return "<aggregate>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (AggregateHandler) HandleCommand(
r dogma.AggregateRoot,
s dogma.AggregateCommandScope,
m dogma.Message,
dogma.AggregateRoot,
dogma.AggregateCommandScope,
dogma.Command,
) {
}
12 changes: 6 additions & 6 deletions static/testdata/apps/app-level-messages/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Integration struct{}

// ApplyEvent updates the integration instance to reflect the occurrence of an
// event that was recorded against this instance.
func (Integration) ApplyEvent(m dogma.Message) {}
func (Integration) ApplyEvent(dogma.Event) {}

// IntegrationHandler is a test implementation of
// dogma.IntegrationMessageHandler.
Expand All @@ -32,21 +32,21 @@ func (IntegrationHandler) Configure(c dogma.IntegrationConfigurer) {

// RouteCommandToInstance returns the ID of the integration instance that is
// targetted by m.
func (IntegrationHandler) RouteCommandToInstance(m dogma.Message) string {
func (IntegrationHandler) RouteCommandToInstance(dogma.Command) string {
return "<integration>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (IntegrationHandler) HandleCommand(
ctx context.Context,
s dogma.IntegrationCommandScope,
m dogma.Message,
context.Context,
dogma.IntegrationCommandScope,
dogma.Command,
) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (IntegrationHandler) TimeoutHint(m dogma.Message) time.Duration {
func (IntegrationHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}
22 changes: 11 additions & 11 deletions static/testdata/apps/app-level-messages/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,35 @@ func (ProcessHandler) Configure(c dogma.ProcessConfigurer) {
// RouteEventToInstance returns the ID of the process instance that is
// targeted by m.
func (ProcessHandler) RouteEventToInstance(
ctx context.Context,
m dogma.Message,
context.Context,
dogma.Event,
) (string, bool, error) {
return "<process>", true, nil
}

// HandleEvent handles an event message.
func (ProcessHandler) HandleEvent(
ctx context.Context,
r dogma.ProcessRoot,
s dogma.ProcessEventScope,
m dogma.Message,
context.Context,
dogma.ProcessRoot,
dogma.ProcessEventScope,
dogma.Event,
) error {
return nil
}

// HandleTimeout handles a timeout message that has been scheduled with
// ProcessScope.ScheduleTimeout().
func (ProcessHandler) HandleTimeout(
ctx context.Context,
r dogma.ProcessRoot,
s dogma.ProcessTimeoutScope,
m dogma.Message,
context.Context,
dogma.ProcessRoot,
dogma.ProcessTimeoutScope,
dogma.Timeout,
) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (ProcessHandler) TimeoutHint(m dogma.Message) time.Duration {
func (ProcessHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}
19 changes: 8 additions & 11 deletions static/testdata/apps/app-level-messages/projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,32 @@ func (ProjectionHandler) Configure(c dogma.ProjectionConfigurer) {

// HandleEvent updates the projection to reflect the occurrence of an event.
func (ProjectionHandler) HandleEvent(
ctx context.Context,
r, c, n []byte,
s dogma.ProjectionEventScope,
m dogma.Message,
_ context.Context,
_, _, _ []byte,
_ dogma.ProjectionEventScope,
_ dogma.Event,
) (ok bool, err error) {
return false, nil
}

// ResourceVersion returns the version of the resource r.
func (ProjectionHandler) ResourceVersion(
ctx context.Context,
r []byte,
) ([]byte, error) {
func (ProjectionHandler) ResourceVersion(context.Context, []byte) ([]byte, error) {
return nil, nil
}

// CloseResource informs the projection that the resource r will not be
// used in any future calls to HandleEvent().
func (ProjectionHandler) CloseResource(ctx context.Context, r []byte) error {
func (ProjectionHandler) CloseResource(context.Context, []byte) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (ProjectionHandler) TimeoutHint(m dogma.Message) time.Duration {
func (ProjectionHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}

// Compact reduces the size of the projection's data.
func (ProjectionHandler) Compact(ctx context.Context, s dogma.ProjectionCompactScope) error {
func (ProjectionHandler) Compact(context.Context, dogma.ProjectionCompactScope) error {
return nil
}
10 changes: 5 additions & 5 deletions static/testdata/apps/handler-from-field/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Aggregate struct{}

// ApplyEvent updates the aggregate instance to reflect the occurrence of an
// event that was recorded against this instance.
func (Aggregate) ApplyEvent(m dogma.Message) {}
func (Aggregate) ApplyEvent(dogma.Event) {}

// AggregateHandler is a test implementation of dogma.AggregateMessageHandler.
type AggregateHandler struct{}
Expand All @@ -33,14 +33,14 @@ func (*AggregateHandler) Configure(c dogma.AggregateConfigurer) {

// RouteCommandToInstance returns the ID of the aggregate instance that is
// targetted by m.
func (*AggregateHandler) RouteCommandToInstance(m dogma.Message) string {
func (*AggregateHandler) RouteCommandToInstance(dogma.Command) string {
return "<aggregate>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (*AggregateHandler) HandleCommand(
r dogma.AggregateRoot,
s dogma.AggregateCommandScope,
m dogma.Message,
dogma.AggregateRoot,
dogma.AggregateCommandScope,
dogma.Command,
) {
}
10 changes: 5 additions & 5 deletions static/testdata/handlers/conditional-branches/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Aggregate struct{}

// ApplyEvent updates the aggregate instance to reflect the occurrence of an
// event that was recorded against this instance.
func (Aggregate) ApplyEvent(m dogma.Message) {}
func (Aggregate) ApplyEvent(dogma.Event) {}

// AggregateHandler is a test implementation of dogma.AggregateMessageHandler.
type AggregateHandler struct{}
Expand Down Expand Up @@ -51,14 +51,14 @@ func (AggregateHandler) Configure(c dogma.AggregateConfigurer) {

// RouteCommandToInstance returns the ID of the aggregate instance that is
// targetted by m.
func (AggregateHandler) RouteCommandToInstance(m dogma.Message) string {
func (AggregateHandler) RouteCommandToInstance(dogma.Command) string {
return "<aggregate>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (AggregateHandler) HandleCommand(
r dogma.AggregateRoot,
s dogma.AggregateCommandScope,
m dogma.Message,
dogma.AggregateRoot,
dogma.AggregateCommandScope,
dogma.Command,
) {
}
10 changes: 5 additions & 5 deletions static/testdata/handlers/conditional-branches/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ func (IntegrationHandler) Configure(c dogma.IntegrationConfigurer) {

// RouteCommandToInstance returns the ID of the integration instance that is
// targetted by m.
func (IntegrationHandler) RouteCommandToInstance(m dogma.Message) string {
func (IntegrationHandler) RouteCommandToInstance(dogma.Command) string {
return "<integration>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (IntegrationHandler) HandleCommand(
ctx context.Context,
s dogma.IntegrationCommandScope,
m dogma.Message,
context.Context,
dogma.IntegrationCommandScope,
dogma.Command,
) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (IntegrationHandler) TimeoutHint(m dogma.Message) time.Duration {
func (IntegrationHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}
22 changes: 11 additions & 11 deletions static/testdata/handlers/conditional-branches/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,35 @@ func (ProcessHandler) Configure(c dogma.ProcessConfigurer) {
// RouteEventToInstance returns the ID of the process instance that is
// targeted by m.
func (ProcessHandler) RouteEventToInstance(
ctx context.Context,
m dogma.Message,
context.Context,
dogma.Event,
) (string, bool, error) {
return "<process>", true, nil
}

// HandleEvent handles an event message.
func (ProcessHandler) HandleEvent(
ctx context.Context,
r dogma.ProcessRoot,
s dogma.ProcessEventScope,
m dogma.Message,
context.Context,
dogma.ProcessRoot,
dogma.ProcessEventScope,
dogma.Event,
) error {
return nil
}

// HandleTimeout handles a timeout message that has been scheduled with
// ProcessScope.ScheduleTimeout().
func (ProcessHandler) HandleTimeout(
ctx context.Context,
r dogma.ProcessRoot,
s dogma.ProcessTimeoutScope,
m dogma.Message,
context.Context,
dogma.ProcessRoot,
dogma.ProcessTimeoutScope,
dogma.Timeout,
) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (ProcessHandler) TimeoutHint(m dogma.Message) time.Duration {
func (ProcessHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}
19 changes: 8 additions & 11 deletions static/testdata/handlers/conditional-branches/projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,32 @@ func (ProjectionHandler) Configure(c dogma.ProjectionConfigurer) {

// HandleEvent updates the projection to reflect the occurrence of an event.
func (ProjectionHandler) HandleEvent(
ctx context.Context,
r, c, n []byte,
s dogma.ProjectionEventScope,
m dogma.Message,
_ context.Context,
_, _, _ []byte,
_ dogma.ProjectionEventScope,
_ dogma.Event,
) (ok bool, err error) {
return false, nil
}

// ResourceVersion returns the version of the resource r.
func (ProjectionHandler) ResourceVersion(
ctx context.Context,
r []byte,
) ([]byte, error) {
func (ProjectionHandler) ResourceVersion(context.Context, []byte) ([]byte, error) {
return nil, nil
}

// CloseResource informs the projection that the resource r will not be
// used in any future calls to HandleEvent().
func (ProjectionHandler) CloseResource(ctx context.Context, r []byte) error {
func (ProjectionHandler) CloseResource(context.Context, []byte) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (ProjectionHandler) TimeoutHint(m dogma.Message) time.Duration {
func (ProjectionHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}

// Compact reduces the size of the projection's data.
func (ProjectionHandler) Compact(ctx context.Context, s dogma.ProjectionCompactScope) error {
func (ProjectionHandler) Compact(context.Context, dogma.ProjectionCompactScope) error {
return nil
}
10 changes: 5 additions & 5 deletions static/testdata/handlers/constructor/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Aggregate struct{}

// ApplyEvent updates the aggregate instance to reflect the occurrence of an
// event that was recorded against this instance.
func (Aggregate) ApplyEvent(m dogma.Message) {}
func (Aggregate) ApplyEvent(dogma.Event) {}

// AggregateHandler is a test implementation of dogma.AggregateMessageHandler.
type AggregateHandler struct{}
Expand Down Expand Up @@ -40,14 +40,14 @@ func (AggregateHandler) Configure(c dogma.AggregateConfigurer) {

// RouteCommandToInstance returns the ID of the aggregate instance that is
// targetted by m.
func (AggregateHandler) RouteCommandToInstance(m dogma.Message) string {
func (AggregateHandler) RouteCommandToInstance(dogma.Command) string {
return "<aggregate>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (AggregateHandler) HandleCommand(
r dogma.AggregateRoot,
s dogma.AggregateCommandScope,
m dogma.Message,
dogma.AggregateRoot,
dogma.AggregateCommandScope,
dogma.Command,
) {
}
10 changes: 5 additions & 5 deletions static/testdata/handlers/constructor/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ func (IntegrationHandler) Configure(c dogma.IntegrationConfigurer) {

// RouteCommandToInstance returns the ID of the integration instance that is
// targetted by m.
func (IntegrationHandler) RouteCommandToInstance(m dogma.Message) string {
func (IntegrationHandler) RouteCommandToInstance(dogma.Command) string {
return "<integration>"
}

// HandleCommand handles a command message that has been routed to this handler.
func (IntegrationHandler) HandleCommand(
ctx context.Context,
s dogma.IntegrationCommandScope,
m dogma.Message,
context.Context,
dogma.IntegrationCommandScope,
dogma.Command,
) error {
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (IntegrationHandler) TimeoutHint(m dogma.Message) time.Duration {
func (IntegrationHandler) TimeoutHint(dogma.Message) time.Duration {
return 0
}
Loading

0 comments on commit 1b62ea8

Please sign in to comment.