generated from dogmatiq/template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix parsing indirect calls to handler
.Configure()
method.
- Loading branch information
1 parent
2eb058a
commit 011a7e5
Showing
7 changed files
with
383 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
static/testdata/handlers/non-pointer-registered-as-pointer/aggregate.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/dogmatiq/dogma" | ||
"github.com/dogmatiq/dogma/fixtures" | ||
) | ||
|
||
// Aggregate is an aggregate used for testing. | ||
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) {} | ||
|
||
// AggregateHandler is a test implementation of dogma.AggregateMessageHandler. | ||
type AggregateHandler struct{} | ||
|
||
// New returns a new account instance. | ||
func (AggregateHandler) New() dogma.AggregateRoot { | ||
return Aggregate{} | ||
} | ||
|
||
// Configure configures the behavior of the engine as it relates to this | ||
// handler. | ||
func (AggregateHandler) Configure(c dogma.AggregateConfigurer) { | ||
c.Identity("<aggregate>", "ee1814e3-194d-438a-916e-ee7766598646") | ||
|
||
c.Routes( | ||
dogma.HandlesCommand[fixtures.MessageA](), | ||
dogma.HandlesCommand[fixtures.MessageB](), | ||
dogma.RecordsEvent[fixtures.MessageC](), | ||
dogma.RecordsEvent[fixtures.MessageD](), | ||
) | ||
} | ||
|
||
// RouteCommandToInstance returns the ID of the aggregate instance that is | ||
// targetted by m. | ||
func (AggregateHandler) RouteCommandToInstance(m dogma.Message) 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, | ||
) { | ||
} |
17 changes: 17 additions & 0 deletions
17
static/testdata/handlers/non-pointer-registered-as-pointer/app.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package app | ||
|
||
import "github.com/dogmatiq/dogma" | ||
|
||
// App implements dogma.Application interface. | ||
type App struct{} | ||
|
||
// Configure configures the behavior of the engine as it relates to this | ||
// application. | ||
func (App) Configure(c dogma.ApplicationConfigurer) { | ||
c.Identity("<non-pointer-handler-registered-as-pointer>", "282653ad-9343-44f1-889e-a8b2b095b54b") | ||
|
||
c.RegisterIntegration(&IntegrationHandler{}) | ||
c.RegisterProjection(&ProjectionHandler{}) | ||
c.RegisterAggregate(&AggregateHandler{}) | ||
c.RegisterProcess(&ProcessHandler{}) | ||
} |
47 changes: 47 additions & 0 deletions
47
static/testdata/handlers/non-pointer-registered-as-pointer/integration.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package app | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/dogmatiq/dogma" | ||
"github.com/dogmatiq/dogma/fixtures" | ||
) | ||
|
||
// IntegrationHandler is a test implementation of | ||
// dogma.IntegrationMessageHandler. | ||
type IntegrationHandler struct{} | ||
|
||
// Configure configures the behavior of the engine as it relates to this | ||
// handler. | ||
func (IntegrationHandler) Configure(c dogma.IntegrationConfigurer) { | ||
c.Identity("<integration>", "1425ca64-0448-4bfd-b18d-9fe63a95995f") | ||
|
||
c.Routes( | ||
dogma.HandlesCommand[fixtures.MessageA](), | ||
dogma.HandlesCommand[fixtures.MessageB](), | ||
dogma.RecordsEvent[fixtures.MessageC](), | ||
dogma.RecordsEvent[fixtures.MessageD](), | ||
) | ||
} | ||
|
||
// RouteCommandToInstance returns the ID of the integration instance that is | ||
// targetted by m. | ||
func (IntegrationHandler) RouteCommandToInstance(m dogma.Message) 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, | ||
) 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 { | ||
return 0 | ||
} |
72 changes: 72 additions & 0 deletions
72
static/testdata/handlers/non-pointer-registered-as-pointer/process.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package app | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/dogmatiq/dogma" | ||
"github.com/dogmatiq/dogma/fixtures" | ||
) | ||
|
||
// Process is a process used for testing. | ||
type Process struct{} | ||
|
||
// ProcessHandler is a test implementation of dogma.ProcessMessageHandler. | ||
type ProcessHandler struct{} | ||
|
||
// New constructs a new process instance initialized with any default values and | ||
// returns the process root. | ||
func (ProcessHandler) New() dogma.ProcessRoot { | ||
return Process{} | ||
} | ||
|
||
// Configure configures the behavior of the engine as it relates to this | ||
// handler. | ||
func (ProcessHandler) Configure(c dogma.ProcessConfigurer) { | ||
c.Identity("<process>", "39af6b34-5fa1-4f3a-b049-40a5e1d9b33b") | ||
|
||
c.Routes( | ||
dogma.HandlesEvent[fixtures.MessageA](), | ||
dogma.HandlesEvent[fixtures.MessageB](), | ||
dogma.ExecutesCommand[fixtures.MessageC](), | ||
dogma.ExecutesCommand[fixtures.MessageD](), | ||
dogma.SchedulesTimeout[fixtures.MessageE](), | ||
dogma.SchedulesTimeout[fixtures.MessageF](), | ||
) | ||
} | ||
|
||
// RouteEventToInstance returns the ID of the process instance that is | ||
// targeted by m. | ||
func (ProcessHandler) RouteEventToInstance( | ||
ctx context.Context, | ||
m dogma.Message, | ||
) (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, | ||
) 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, | ||
) 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 { | ||
return 0 | ||
} |
Oops, something went wrong.