diff --git a/aggregate_test.go b/aggregate_test.go index 65e61b68..5160e5f8 100644 --- a/aggregate_test.go +++ b/aggregate_test.go @@ -22,9 +22,11 @@ var _ = Describe("func FromAggregate()", func() { handler = &fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageB{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageB](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, } }) @@ -157,8 +159,10 @@ var _ = Describe("func FromAggregate()", func() { "when the handler does not configure an identity", `*fixtures.AggregateMessageHandler is configured without an identity, Identity() must be called exactly once within Configure()`, func(c dogma.AggregateConfigurer) { - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -167,8 +171,10 @@ var _ = Describe("func FromAggregate()", func() { func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -176,8 +182,10 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler is configured with an invalid identity, invalid name "\t \n", names must be non-empty, printable UTF-8 strings with no whitespace`, func(c dogma.AggregateConfigurer) { c.Identity("\t \n", appKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -185,8 +193,10 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler is configured with an invalid identity, invalid key "\t \n", keys must be RFC 4122 UUIDs`, func(c dogma.AggregateConfigurer) { c.Identity("", "\t \n") - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -194,7 +204,9 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler () is not configured to consume any commands, ConsumesCommandType() must be called at least once within Configure()`, func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -202,9 +214,11 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler () is configured to consume the fixtures.MessageA command more than once, should this refer to different message types?`, func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -212,7 +226,9 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler () is not configured to produce any events, ProducesEventType() must be called at least once within Configure()`, func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + ) }, ), Entry( @@ -220,9 +236,11 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler () is configured to produce the fixtures.MessageE event more than once, should this refer to different message types?`, func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -230,16 +248,20 @@ var _ = Describe("func FromAggregate()", func() { `*fixtures.AggregateMessageHandler () is configured to use fixtures.MessageA as both a command and an event`, func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageA](), + ) }, ), Entry( "when an error occurs before the identity is configured it omits the handler name", `*fixtures.AggregateMessageHandler is configured to consume the fixtures.MessageA command more than once, should this refer to different message types?`, func(c dogma.AggregateConfigurer) { - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageA](), + ) }, ), ) diff --git a/api/blackbox_test.go b/api/blackbox_test.go index ab191419..813a1989 100644 --- a/api/blackbox_test.go +++ b/api/blackbox_test.go @@ -36,17 +36,21 @@ var _ = Context("end-to-end tests", func() { c.RegisterAggregate(&AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "938b829d-e4d7-4780-bf06-ea349453ba8f") - c.ConsumesCommandType(MessageC{}) - c.ProducesEventType(MessageE{}) + c.Routes( + dogma.HandlesCommand[MessageC](), + dogma.RecordsEvent[MessageE](), + ) }, }) c.RegisterProcess(&ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "2a87972b-547d-416b-b6e5-4dddb1187658") - c.ConsumesEventType(MessageE{}) - c.ProducesCommandType(MessageC{}) - c.SchedulesTimeoutType(MessageT{}) + c.Routes( + dogma.HandlesEvent[MessageE](), + dogma.ExecutesCommand[MessageC](), + dogma.SchedulesTimeout[MessageT](), + ) }, }) }, @@ -59,16 +63,20 @@ var _ = Context("end-to-end tests", func() { c.RegisterIntegration(&IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", "e6f0ad02-d301-4f46-a03d-4f9d0d20f5cf") - c.ConsumesCommandType(MessageI{}) - c.ProducesEventType(MessageJ{}) + c.Routes( + dogma.HandlesCommand[MessageI](), + dogma.RecordsEvent[MessageJ](), + ) }, }) c.RegisterProjection(&ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", "280a58bd-f154-46d7-863b-23ce70e49d2a") - c.ConsumesEventType(MessageE{}) - c.ConsumesEventType(MessageJ{}) + c.Routes( + dogma.HandlesEvent[MessageE](), + dogma.HandlesEvent[MessageJ](), + ) }, }) }, diff --git a/application_test.go b/application_test.go index 603b881e..0208f84b 100644 --- a/application_test.go +++ b/application_test.go @@ -29,34 +29,42 @@ var _ = Describe("func FromApplication()", func() { aggregate = &fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, } process = &fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageB{}) - c.ConsumesEventType(fixtures.MessageE{}) // shared with - c.ProducesCommandType(fixtures.MessageC{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageB](), + dogma.HandlesEvent[fixtures.MessageE](), // shared with + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, } integration = &fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageF{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageF](), + ) }, } projection = &fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageD{}) - c.ConsumesEventType(fixtures.MessageE{}) // shared with + c.Routes( + dogma.HandlesEvent[fixtures.MessageD](), + dogma.HandlesEvent[fixtures.MessageE](), // shared with + ) }, } @@ -207,8 +215,10 @@ var _ = Describe("func FromApplication()", func() { It("does not panic when the app name is shared with handler", func() { aggregate.ConfigureFunc = func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) } Expect(func() { @@ -220,18 +230,22 @@ var _ = Describe("func FromApplication()", func() { process1 := &fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "51621cac-73e2-48fa-95ad-8c3d06ab2ac3") - c.ConsumesEventType(fixtures.MessageB{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageB](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, } process2 := &fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "97abc0e1-39c8-434a-8ff2-1f0e2d37486e") - c.ConsumesEventType(fixtures.MessageB{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageB](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, } @@ -331,8 +345,10 @@ var _ = Describe("func FromApplication()", func() { func() { aggregate.ConfigureFunc = func(c dogma.AggregateConfigurer) { c.Identity("", appKey) // conflict! - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) } }, ), @@ -370,8 +386,10 @@ var _ = Describe("func FromApplication()", func() { func() { aggregate.ConfigureFunc = func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) // conflict! - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) } app.ConfigureFunc = func(c dogma.ApplicationConfigurer) { @@ -387,8 +405,10 @@ var _ = Describe("func FromApplication()", func() { func() { aggregate.ConfigureFunc = func(c dogma.AggregateConfigurer) { c.Identity("", processKey) // conflict! - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) } app.ConfigureFunc = func(c dogma.ApplicationConfigurer) { @@ -404,8 +424,10 @@ var _ = Describe("func FromApplication()", func() { func() { integration.ConfigureFunc = func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) // conflict with - c.ProducesEventType(fixtures.MessageF{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), // conflict with + dogma.RecordsEvent[fixtures.MessageF](), + ) } }, ), @@ -415,8 +437,10 @@ var _ = Describe("func FromApplication()", func() { func() { integration.ConfigureFunc = func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageE{}) // conflict with + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageE](), // conflict with + ) } }, ), @@ -426,7 +450,9 @@ var _ = Describe("func FromApplication()", func() { func() { projection.ConfigureFunc = func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageA{}) // conflict with + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), // conflict with + ) } app.ConfigureFunc = func(c dogma.ApplicationConfigurer) { @@ -447,7 +473,9 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) }, @@ -475,7 +503,9 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) }, @@ -494,7 +524,9 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) }, @@ -509,7 +541,9 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) }, @@ -523,7 +557,9 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) }, @@ -537,8 +573,10 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) - c.ConsumesEventType(fixtures.MessageX{}) // diff + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.HandlesEvent[fixtures.MessageX](), // diff + ) }, }) }, @@ -552,7 +590,9 @@ var _ = Describe("func IsApplicationEqual()", func() { c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) // diff - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) }, diff --git a/applicationconfigurer.go b/applicationconfigurer.go index 43a1c156..8bab3225 100644 --- a/applicationconfigurer.go +++ b/applicationconfigurer.go @@ -26,22 +26,22 @@ func (c *applicationConfigurer) Identity(name, key string) { c.entityConfigurer.Identity(name, key) } -func (c *applicationConfigurer) RegisterAggregate(h dogma.AggregateMessageHandler) { +func (c *applicationConfigurer) RegisterAggregate(h dogma.AggregateMessageHandler, _ ...dogma.RegisterAggregateOption) { cfg := FromAggregate(h) c.register(cfg) } -func (c *applicationConfigurer) RegisterProcess(h dogma.ProcessMessageHandler) { +func (c *applicationConfigurer) RegisterProcess(h dogma.ProcessMessageHandler, _ ...dogma.RegisterProcessOption) { cfg := FromProcess(h) c.register(cfg) } -func (c *applicationConfigurer) RegisterIntegration(h dogma.IntegrationMessageHandler) { +func (c *applicationConfigurer) RegisterIntegration(h dogma.IntegrationMessageHandler, _ ...dogma.RegisterIntegrationOption) { cfg := FromIntegration(h) c.register(cfg) } -func (c *applicationConfigurer) RegisterProjection(h dogma.ProjectionMessageHandler) { +func (c *applicationConfigurer) RegisterProjection(h dogma.ProjectionMessageHandler, _ ...dogma.RegisterProjectionOption) { cfg := FromProjection(h) c.register(cfg) } diff --git a/go.mod b/go.mod index 7f065e74..09605e67 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/dogmatiq/configkit go 1.21 require ( - github.com/dogmatiq/dogma v0.12.1 + github.com/dogmatiq/dogma v0.12.2-0.20240216000138-5952f8b37b64 github.com/dogmatiq/iago v0.4.0 github.com/dogmatiq/interopspec v0.5.3 github.com/emicklei/dot v1.6.1 diff --git a/go.sum b/go.sum index fcc8ba4a..8d46e5d7 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dogmatiq/dogma v0.12.1 h1:mWIzmi3jio9ZnHJeJKNS5D19O2S4x4SLSxGXXn3IQiQ= github.com/dogmatiq/dogma v0.12.1/go.mod h1:op4IjAGC593ONvvUPhh2xNyk/3Ezv9HkCPRlzdbkX9Y= +github.com/dogmatiq/dogma v0.12.2-0.20240216000138-5952f8b37b64 h1:eDqLJEZMfnG8TkWninf1d1iZixYLyu6MmQd4wATOhXY= +github.com/dogmatiq/dogma v0.12.2-0.20240216000138-5952f8b37b64/go.mod h1:9lyVA+6V2+E/exV0IrBOrkUiyFwIATEhv+b0vnB2umQ= github.com/dogmatiq/iago v0.4.0 h1:57nZqVT34IZxtCZEW/RFif7DNUEjMXgevfr/Mmd0N8I= github.com/dogmatiq/iago v0.4.0/go.mod h1:fishMWBtzYcjgis6d873VTv9kFm/wHYLOzOyO9ECBDc= github.com/dogmatiq/interopspec v0.5.3 h1:AES184nLWcek8/vafykZJLmm59NlRiYiC40Tll8hEeg= diff --git a/handler_test.go b/handler_test.go index 2254bbb3..13b3e171 100644 --- a/handler_test.go +++ b/handler_test.go @@ -14,9 +14,11 @@ var _ = Describe("func IsHandlerEqual()", func() { h := &fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageB{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageB](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, } @@ -32,9 +34,11 @@ var _ = Describe("func IsHandlerEqual()", func() { h := &fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageB{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageB](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, } @@ -47,9 +51,11 @@ var _ = Describe("func IsHandlerEqual()", func() { FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageB{}) // diff - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageB](), // diff + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }), ), @@ -58,9 +64,11 @@ var _ = Describe("func IsHandlerEqual()", func() { FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) // diff - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageB{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageB](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }), ), @@ -69,9 +77,11 @@ var _ = Describe("func IsHandlerEqual()", func() { FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "799239e7-8c03-48f9-a324-14b7f9b76e30") // diff - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageB{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageB](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }), ), @@ -80,9 +90,11 @@ var _ = Describe("func IsHandlerEqual()", func() { FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageB{}) // diff - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageB](), // diff + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }), ), diff --git a/handlerset_test.go b/handlerset_test.go index adc53b9d..44f2e106 100644 --- a/handlerset_test.go +++ b/handlerset_test.go @@ -20,15 +20,19 @@ var _ = Describe("type HandlerSet", func() { aggregate := FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }) projection := FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) @@ -228,7 +232,9 @@ var _ = Describe("type HandlerSet", func() { NewHandlerSet(aggregate, projection, FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageX{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageX](), + ) }, })), ), @@ -237,7 +243,9 @@ var _ = Describe("type HandlerSet", func() { NewHandlerSet(aggregate, FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageF{}) // diff + c.Routes( + dogma.HandlesEvent[fixtures.MessageF](), // diff + ) }, })), ), @@ -336,62 +344,78 @@ var _ = Describe("type HandlerSet", func() { aggregate1 = FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "ca82de11-1794-486e-a190-78e2443de7dd") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) aggregate2 = FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "3a7ad56e-d9b9-42be-9a16-01f25e572c49") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) process1 = FromProcess(&fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "5695e728-33ca-4b0f-b063-ff0ff6f48276") - c.ConsumesEventType(fixtures.MessageE{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, }) process2 = FromProcess(&fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "3d510ba8-6dca-46bb-bcde-193015867834") - c.ConsumesEventType(fixtures.MessageE{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, }) integration1 = FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", "fdf0059e-8786-42db-a348-caac60d6118a") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) integration2 = FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", "34d19336-95c5-47c7-b36e-4e90b24b1b83") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) projection1 = FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", "ee9bd355-e9fd-413a-ac83-7182ea76cb89") - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) projection2 = FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", "0fe3a5e3-b8e1-4ba0-8c90-f002f0a842f9") - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) @@ -541,15 +565,19 @@ var _ = Describe("type RichHandlerSet", func() { aggregate := FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }) projection := FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) @@ -749,7 +777,9 @@ var _ = Describe("type RichHandlerSet", func() { NewRichHandlerSet(aggregate, projection, FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageX{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageX](), + ) }, })), ), @@ -758,7 +788,9 @@ var _ = Describe("type RichHandlerSet", func() { NewRichHandlerSet(aggregate, FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageF{}) // diff + c.Routes( + dogma.HandlesEvent[fixtures.MessageF](), // diff + ) }, })), ), @@ -857,62 +889,78 @@ var _ = Describe("type RichHandlerSet", func() { aggregate1 = FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "648c035d-2a6a-49e6-8968-044bec062fed") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) aggregate2 = FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "e465c85d-4ac0-4aed-8054-665a86b9ef4e") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) process1 = FromProcess(&fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "71a4111b-ee0d-4df1-a059-d8bb94dc3e77") - c.ConsumesEventType(fixtures.MessageE{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, }) process2 = FromProcess(&fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", "3b4ce9af-ca54-4c77-a8e7-285267f73c82") - c.ConsumesEventType(fixtures.MessageE{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, }) integration1 = FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", "22857e0c-7990-4dfe-9cd0-40d6dd160aaf") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) integration2 = FromIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", "26ae7db1-7a81-407d-ac08-52e35f7765d1") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageD{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageD](), + ) }, }) projection1 = FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", "400a4609-9e00-4ccd-8436-3ad9ef073f5d") - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) projection2 = FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", "2d09f134-8971-4dff-8b84-b0e3c279ca88") - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) diff --git a/integration_test.go b/integration_test.go index 82342203..e5610475 100644 --- a/integration_test.go +++ b/integration_test.go @@ -22,9 +22,11 @@ var _ = Describe("func FromIntegration()", func() { handler = &fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageB{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageB](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, } }) @@ -132,7 +134,9 @@ var _ = Describe("func FromIntegration()", func() { BeforeEach(func() { handler.ConfigureFunc = func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + ) } }) @@ -170,8 +174,10 @@ var _ = Describe("func FromIntegration()", func() { "when the handler does not configure an identity", `*fixtures.IntegrationMessageHandler is configured without an identity, Identity() must be called exactly once within Configure()`, func(c dogma.IntegrationConfigurer) { - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -180,8 +186,10 @@ var _ = Describe("func FromIntegration()", func() { func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -189,8 +197,10 @@ var _ = Describe("func FromIntegration()", func() { `*fixtures.IntegrationMessageHandler is configured with an invalid identity, invalid name "\t \n", names must be non-empty, printable UTF-8 strings with no whitespace`, func(c dogma.IntegrationConfigurer) { c.Identity("\t \n", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -198,8 +208,10 @@ var _ = Describe("func FromIntegration()", func() { `*fixtures.IntegrationMessageHandler is configured with an invalid identity, invalid key "\t \n", keys must be RFC 4122 UUIDs`, func(c dogma.IntegrationConfigurer) { c.Identity("", "\t \n") - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -207,7 +219,9 @@ var _ = Describe("func FromIntegration()", func() { `*fixtures.IntegrationMessageHandler () is not configured to consume any commands, ConsumesCommandType() must be called at least once within Configure()`, func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -215,9 +229,11 @@ var _ = Describe("func FromIntegration()", func() { `*fixtures.IntegrationMessageHandler () is configured to consume the fixtures.MessageA command more than once, should this refer to different message types?`, func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -225,9 +241,11 @@ var _ = Describe("func FromIntegration()", func() { `*fixtures.IntegrationMessageHandler () is configured to produce the fixtures.MessageE event more than once, should this refer to different message types?`, func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageE{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageE](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, ), Entry( @@ -235,16 +253,20 @@ var _ = Describe("func FromIntegration()", func() { `*fixtures.IntegrationMessageHandler () is configured to use fixtures.MessageA as both a command and an event`, func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageA{}) - c.ProducesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.RecordsEvent[fixtures.MessageA](), + ) }, ), Entry( "when an error occurs before the identity is configured it omits the handler name", `*fixtures.IntegrationMessageHandler is configured to consume the fixtures.MessageA command more than once, should this refer to different message types?`, func(c dogma.IntegrationConfigurer) { - c.ConsumesCommandType(fixtures.MessageA{}) - c.ConsumesCommandType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageA](), + dogma.HandlesCommand[fixtures.MessageA](), + ) }, ), ) diff --git a/internal/entity/entity_test.go b/internal/entity/entity_test.go index 22b92ba1..9114c167 100644 --- a/internal/entity/entity_test.go +++ b/internal/entity/entity_test.go @@ -73,15 +73,19 @@ var _ = Describe("type Application", func() { aggregate := configkit.FromAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", "63990c32-ecdd-46dd-8e6a-7bb16f3b1730") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }) projection := configkit.FromProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", "b34181e8-2930-4b6c-a649-18a001836ec3") - c.ConsumesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + ) }, }) diff --git a/process_test.go b/process_test.go index be9b3a8c..bc272048 100644 --- a/process_test.go +++ b/process_test.go @@ -22,10 +22,12 @@ var _ = Describe("func FromProcess()", func() { handler = &fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ConsumesEventType(fixtures.MessageB{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.HandlesEvent[fixtures.MessageB](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, } }) @@ -162,8 +164,10 @@ var _ = Describe("func FromProcess()", func() { "when the handler does not configure an identity", `*fixtures.ProcessMessageHandler is configured without an identity, Identity() must be called exactly once within Configure()`, func(c dogma.ProcessConfigurer) { - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -172,8 +176,10 @@ var _ = Describe("func FromProcess()", func() { func(c dogma.ProcessConfigurer) { c.Identity("", processKey) c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -181,8 +187,10 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler is configured with an invalid identity, invalid name "\t \n", names must be non-empty, printable UTF-8 strings with no whitespace`, func(c dogma.ProcessConfigurer) { c.Identity("\t \n", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -190,8 +198,10 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler is configured with an invalid identity, invalid key "\t \n", keys must be RFC 4122 UUIDs`, func(c dogma.ProcessConfigurer) { c.Identity("", "\t \n") - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -199,7 +209,9 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler () is not configured to consume any events, ConsumesEventType() must be called at least once within Configure()`, func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -207,9 +219,11 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler () is configured to consume the fixtures.MessageA event more than once, should this refer to different message types?`, func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -217,7 +231,9 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler () is not configured to produce any commands, ProducesCommandType() must be called at least once within Configure()`, func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), Entry( @@ -225,9 +241,11 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler () is configured to produce the fixtures.MessageC command more than once, should this refer to different message types?`, func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.ProducesCommandType(fixtures.MessageC{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.ExecutesCommand[fixtures.MessageC](), + ) }, ), Entry( @@ -235,10 +253,12 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler () is configured to schedule the fixtures.MessageT timeout more than once, should this refer to different message types?`, func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.SchedulesTimeout[fixtures.MessageT](), + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, ), Entry( @@ -246,16 +266,20 @@ var _ = Describe("func FromProcess()", func() { `*fixtures.ProcessMessageHandler () is configured to use fixtures.MessageA as both an event and a timeout`, func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.SchedulesTimeoutType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.SchedulesTimeout[fixtures.MessageA](), + ) }, ), Entry( "when an error occurs before the identity is configured it omits the handler name", `*fixtures.ProcessMessageHandler is configured to consume the fixtures.MessageA event more than once, should this refer to different message types?`, func(c dogma.ProcessConfigurer) { - c.ConsumesEventType(fixtures.MessageA{}) - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), ) diff --git a/projection_test.go b/projection_test.go index 17bc1fbf..b10c5dd0 100644 --- a/projection_test.go +++ b/projection_test.go @@ -22,8 +22,10 @@ var _ = Describe("func FromProjection()", func() { handler = &fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ConsumesEventType(fixtures.MessageB{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.HandlesEvent[fixtures.MessageB](), + ) c.DeliveryPolicy(dogma.BroadcastProjectionDeliveryPolicy{ PrimaryFirst: true, }) @@ -165,7 +167,9 @@ var _ = Describe("func FromProjection()", func() { "when the handler does not configure an identity", `*fixtures.ProjectionMessageHandler is configured without an identity, Identity() must be called exactly once within Configure()`, func(c dogma.ProjectionConfigurer) { - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), Entry( @@ -174,7 +178,9 @@ var _ = Describe("func FromProjection()", func() { func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), Entry( @@ -182,7 +188,9 @@ var _ = Describe("func FromProjection()", func() { `*fixtures.ProjectionMessageHandler is configured with an invalid identity, invalid name "\t \n", names must be non-empty, printable UTF-8 strings with no whitespace`, func(c dogma.ProjectionConfigurer) { c.Identity("\t \n", projectionKey) - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), Entry( @@ -190,7 +198,9 @@ var _ = Describe("func FromProjection()", func() { `*fixtures.ProjectionMessageHandler is configured with an invalid identity, invalid key "\t \n", keys must be RFC 4122 UUIDs`, func(c dogma.ProjectionConfigurer) { c.Identity("", "\t \n") - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), Entry( @@ -205,16 +215,20 @@ var _ = Describe("func FromProjection()", func() { `*fixtures.ProjectionMessageHandler () is configured to consume the fixtures.MessageA event more than once, should this refer to different message types?`, func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageA{}) - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), Entry( "when an error occurs before the identity is configured it omits the handler name", `*fixtures.ProjectionMessageHandler is configured to consume the fixtures.MessageA event more than once, should this refer to different message types?`, func(c dogma.ProjectionConfigurer) { - c.ConsumesEventType(fixtures.MessageA{}) - c.ConsumesEventType(fixtures.MessageA{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageA](), + dogma.HandlesEvent[fixtures.MessageA](), + ) }, ), ) diff --git a/string_test.go b/string_test.go index 20a9802e..e0e1093f 100644 --- a/string_test.go +++ b/string_test.go @@ -21,33 +21,41 @@ var _ = Describe("func ToString()", func() { c.RegisterAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("", aggregateKey) - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageE{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageE](), + ) }, }) c.RegisterProcess(&fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("", processKey) - c.ConsumesEventType(fixtures.MessageE{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.SchedulesTimeoutType(fixtures.MessageT{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, }) c.RegisterIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("", integrationKey) - c.ConsumesCommandType(fixtures.MessageI{}) - c.ProducesEventType(fixtures.MessageJ{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageI](), + dogma.RecordsEvent[fixtures.MessageJ](), + ) }, }) c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("", projectionKey) - c.ConsumesEventType(fixtures.MessageE{}) - c.ConsumesEventType(fixtures.MessageJ{}) + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.HandlesEvent[fixtures.MessageJ](), + ) }, }) }, diff --git a/visualization/dot/generate_test.go b/visualization/dot/generate_test.go index ac0abfa2..ba32fb37 100644 --- a/visualization/dot/generate_test.go +++ b/visualization/dot/generate_test.go @@ -17,34 +17,43 @@ func TestGenerate_coverage(t *testing.T) { c.RegisterAggregate(&fixtures.AggregateMessageHandler{ ConfigureFunc: func(c dogma.AggregateConfigurer) { c.Identity("aggregate", "b2a8b880-5a1a-4792-ab03-5675b002230a") - c.ConsumesCommandType(fixtures.MessageC{}) - c.ProducesEventType(fixtures.MessageE{}) - c.ProducesEventType(fixtures.MessageF{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageC](), + dogma.RecordsEvent[fixtures.MessageE](), + dogma.RecordsEvent[fixtures.MessageF](), + ) }, }) c.RegisterProcess(&fixtures.ProcessMessageHandler{ ConfigureFunc: func(c dogma.ProcessConfigurer) { c.Identity("process", "3d5bb944-1cb7-40f4-9298-e154acd5effd") - c.ConsumesEventType(fixtures.MessageE{}) - c.ProducesCommandType(fixtures.MessageC{}) - c.ProducesCommandType(fixtures.MessageX{}) // not handled by this app + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.ExecutesCommand[fixtures.MessageC](), + dogma.ExecutesCommand[fixtures.MessageX](), // not handled by this app + dogma.SchedulesTimeout[fixtures.MessageT](), + ) }, }) c.RegisterIntegration(&fixtures.IntegrationMessageHandler{ ConfigureFunc: func(c dogma.IntegrationConfigurer) { c.Identity("integration", "5a496ba8-92f4-439e-bdba-d0e4ef6dd03d") - c.ConsumesCommandType(fixtures.MessageI{}) + c.Routes( + dogma.HandlesCommand[fixtures.MessageI](), + ) }, }) c.RegisterProjection(&fixtures.ProjectionMessageHandler{ ConfigureFunc: func(c dogma.ProjectionConfigurer) { c.Identity("projection", "3f060ff7-630a-4446-8313-35ace689d5ce") - c.ConsumesEventType(fixtures.MessageE{}) - c.ConsumesEventType(fixtures.MessageF{}) - c.ConsumesEventType(fixtures.MessageY{}) // not produced by this app + c.Routes( + dogma.HandlesEvent[fixtures.MessageE](), + dogma.HandlesEvent[fixtures.MessageF](), + dogma.HandlesEvent[fixtures.MessageY](), // not produced by this app + ) }, }) },