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.
Merge pull request #263 from dogmatiq/fix-parsing-msg-on-handlers
Fix parsing indirect calls to handler `.Configure()` method.
- Loading branch information
Showing
10 changed files
with
345 additions
and
49 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
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
16 changes: 0 additions & 16 deletions
16
static/testdata/apps/pointer-handler-with-non-pointer-methodset/app.go
This file was deleted.
Oops, something went wrong.
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
17 changes: 17 additions & 0 deletions
17
static/testdata/handlers/pointer-handler-with-non-pointer-methodset/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/pointer-handler-with-non-pointer-methodset/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/pointer-handler-with-non-pointer-methodset/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.