Skip to content

Commit

Permalink
Remove message package and replace with enginekit/message.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Oct 5, 2024
1 parent d4cbce6 commit 2528533
Show file tree
Hide file tree
Showing 38 changed files with 50 additions and 1,169 deletions.
2 changes: 1 addition & 1 deletion aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"

"github.com/dogmatiq/configkit/internal/typename/goreflect"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
"github.com/dogmatiq/enginekit/message"
)

// Aggregate is an interface that represents the configuration of a Dogma
Expand Down
2 changes: 1 addition & 1 deletion aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"reflect"

. "github.com/dogmatiq/configkit"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
"github.com/dogmatiq/enginekit/message"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion application.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/dogmatiq/configkit/internal/typename/goreflect"
"github.com/dogmatiq/configkit/internal/validation"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
"github.com/dogmatiq/enginekit/message"
)

// Application is an interface that represents the configuration of a Dogma
Expand Down
2 changes: 1 addition & 1 deletion application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"reflect"

. "github.com/dogmatiq/configkit"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
"github.com/dogmatiq/enginekit/message"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"slices"

"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/enginekit/message"
)

// Entity is an interface that represents the configuration of a Dogma "entity"
Expand Down
2 changes: 1 addition & 1 deletion entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"maps"

. "github.com/dogmatiq/configkit"
"github.com/dogmatiq/configkit/message"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
"github.com/dogmatiq/enginekit/message"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.23.1
require (
github.com/dogmatiq/aureus v0.1.0
github.com/dogmatiq/dogma v0.15.0
github.com/dogmatiq/enginekit v0.16.0
github.com/dogmatiq/enginekit v0.16.1-0.20241005100116-c3335230d56f
github.com/dogmatiq/iago v0.4.0
github.com/emicklei/dot v1.6.2
github.com/google/uuid v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/dogmatiq/dapper v0.6.0 h1:hnWUsjnt3nUiC9hmkPvuxrnMd7fYNz1i+/GS3gOx0Xs
github.com/dogmatiq/dapper v0.6.0/go.mod h1:ubRHWzt73s0MsPpGhWvnfW/Z/1YPnrkCsQv6CUOZVEw=
github.com/dogmatiq/dogma v0.15.0 h1:aXOTd2K4wLvlwHc1D9OsFREp0BusNJ9o9KssxURftmg=
github.com/dogmatiq/dogma v0.15.0/go.mod h1:TF6xisRxQ2RE3JQwFr6MCI4nWLKQQp7KRWXVHOq9K0k=
github.com/dogmatiq/enginekit v0.16.0 h1:1+Fr0117jihoiY2SABsSAGhJYLi8DeNv35rR8PWgBfk=
github.com/dogmatiq/enginekit v0.16.0/go.mod h1:nODdKEljyHQHDRlwQrKD3NCJ/4y1jFFKYDwJ0yeHcVo=
github.com/dogmatiq/enginekit v0.16.1-0.20241005100116-c3335230d56f h1:U00wlzp2h0VLhQCk6AyCZ1oI0UW1iFvmxwOqvuuL/E4=
github.com/dogmatiq/enginekit v0.16.1-0.20241005100116-c3335230d56f/go.mod h1:nODdKEljyHQHDRlwQrKD3NCJ/4y1jFFKYDwJ0yeHcVo=
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/jumble v0.1.0 h1:Cb3ExfxY+AoUP4G9/sOwoOdYX8o+kOLK8+dhXAry+QA=
Expand Down
6 changes: 3 additions & 3 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"

"github.com/dogmatiq/configkit/internal/validation"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
"github.com/dogmatiq/enginekit/message"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
Expand Down Expand Up @@ -185,8 +185,8 @@ func mustHaveProducerRoute(
}
}

verb := message.MapKind(kind, "execute", "record", "schedule")
routeFunc := message.MapKind(kind, "ExecutesCommand", "RecordsEvent", "SchedulesTimeout")
verb := message.MapByKind(kind, "execute", "record", "schedule")
routeFunc := message.MapByKind(kind, "ExecutesCommand", "RecordsEvent", "SchedulesTimeout")

validation.Panicf(
`%s is not configured to %s any %ss, at least one %s() route must be added within Configure()`,
Expand Down
2 changes: 1 addition & 1 deletion handlerset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package configkit
import (
"context"

"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/enginekit/message"
)

// HandlerSet is a collection of handlers.
Expand Down
2 changes: 1 addition & 1 deletion handlerset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"errors"

. "github.com/dogmatiq/configkit"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
"github.com/dogmatiq/enginekit/message"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down
6 changes: 3 additions & 3 deletions handlertype.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"slices"

"github.com/dogmatiq/configkit/internal/validation"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/enginekit/message"
)

// HandlerType is an enumeration of the types of handlers.
Expand Down Expand Up @@ -222,7 +222,7 @@ func (t *HandlerType) UnmarshalBinary(data []byte) error {

// ConsumersOf returns the handler types that can consume messages of kind k.
func ConsumersOf(k message.Kind) []HandlerType {
return message.MapKind(
return message.MapByKind(
k,
[]HandlerType{AggregateHandlerType, IntegrationHandlerType},
[]HandlerType{ProcessHandlerType, ProjectionHandlerType},
Expand All @@ -232,7 +232,7 @@ func ConsumersOf(k message.Kind) []HandlerType {

// ProducersOf returns the handler types that can produces messages of kind k.
func ProducersOf(k message.Kind) []HandlerType {
return message.MapKind(
return message.MapByKind(
k,
[]HandlerType{ProcessHandlerType},
[]HandlerType{AggregateHandlerType, IntegrationHandlerType},
Expand Down
2 changes: 1 addition & 1 deletion handlertype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package configkit_test

import (
. "github.com/dogmatiq/configkit"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/enginekit/message"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
Expand Down
2 changes: 1 addition & 1 deletion integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"reflect"

"github.com/dogmatiq/configkit/internal/typename/goreflect"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
"github.com/dogmatiq/enginekit/message"
)

// Integration is an interface that represents the configuration of a Dogma
Expand Down
2 changes: 1 addition & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"reflect"

. "github.com/dogmatiq/configkit"
"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
"github.com/dogmatiq/enginekit/message"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand Down
37 changes: 11 additions & 26 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"fmt"

"github.com/dogmatiq/configkit/message"
"github.com/dogmatiq/enginekit/message"
"github.com/dogmatiq/enginekit/protobuf/configpb"
"github.com/dogmatiq/enginekit/protobuf/identitypb"
"github.com/dogmatiq/enginekit/protobuf/uuidpb"
Expand All @@ -28,11 +28,6 @@ func ToProto(app Application) (*configpb.Application, error) {
}

for n, em := range app.MessageNames() {
nOut, err := n.MarshalText()
if err != nil {
return nil, err
}

kOut, err := marshalMessageKind(em.Kind)
if err != nil {
return nil, err
Expand All @@ -41,7 +36,7 @@ func ToProto(app Application) (*configpb.Application, error) {
if out.Messages == nil {
out.Messages = map[string]configpb.MessageKind{}
}
out.Messages[string(nOut)] = kOut
out.Messages[string(n)] = kOut
}

for _, h := range app.Handlers() {
Expand Down Expand Up @@ -74,17 +69,12 @@ func FromProto(app *configpb.Application) (Application, error) {
kinds := map[message.Name]message.Kind{}

for n, k := range app.GetMessages() {
var nOut message.Name
if err := nOut.UnmarshalText([]byte(n)); err != nil {
return nil, err
}

kOut, err := unmarshalMessageKind(k)
if err != nil {
return nil, err
}

kinds[nOut] = kOut
kinds[message.Name(n)] = kOut
}

for _, h := range app.GetHandlers() {
Expand Down Expand Up @@ -125,16 +115,15 @@ func marshalHandler(in Handler) (*configpb.Handler, error) {
}

for n, em := range in.MessageNames() {
if out.Messages == nil {
out.Messages = map[string]*configpb.MessageUsage{}
if n == "" {
return nil, errors.New("message name is empty")
}

name, err := n.MarshalText()
if err != nil {
return nil, err
if out.Messages == nil {
out.Messages = map[string]*configpb.MessageUsage{}
}

key := string(name)
key := string(n)

usage, ok := out.Messages[key]
if !ok {
Expand Down Expand Up @@ -181,12 +170,8 @@ func unmarshalHandler(
}

for n, usage := range in.GetMessages() {
var nOut message.Name
if err := nOut.UnmarshalText([]byte(n)); err != nil {
return nil, err
}

k, ok := kinds[nOut]
nOut := message.Name(n)
kOut, ok := kinds[nOut]
if !ok {
return nil, fmt.Errorf("message name %s as no associated message kind", n)
}
Expand All @@ -198,7 +183,7 @@ func unmarshalHandler(
out.names.Update(
nOut,
func(n message.Name, em *EntityMessage) {
em.Kind = k
em.Kind = kOut

if usage.IsProduced {
em.IsProduced = true
Expand Down
4 changes: 2 additions & 2 deletions marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package configkit

import (
//revive:disable:dot-imports
"github.com/dogmatiq/configkit/message"
. "github.com/dogmatiq/enginekit/enginetest/stubs"
"github.com/dogmatiq/enginekit/message"
"github.com/dogmatiq/enginekit/protobuf/configpb"
"github.com/dogmatiq/enginekit/protobuf/identitypb"
"github.com/dogmatiq/enginekit/protobuf/uuidpb"
Expand Down Expand Up @@ -136,7 +136,7 @@ var _ = Describe("func marshalHandler()", func() {
})

It("returns an error if there is an invalid message name", func() {
handler.names[message.Name{}] = EntityMessage{}
handler.names[""] = EntityMessage{}

_, err := marshalHandler(handler)
Expect(err).Should(HaveOccurred())
Expand Down
3 changes: 0 additions & 3 deletions message/doc.go

This file was deleted.

15 changes: 0 additions & 15 deletions message/ginkgo_test.go

This file was deleted.

Loading

0 comments on commit 2528533

Please sign in to comment.