Skip to content

Commit

Permalink
Bump Dogma to v0.14.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Aug 17, 2024
1 parent 8f2a595 commit 8eee7d7
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 6 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ The format is based on [Keep a Changelog], and this project adheres to
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## [0.7.5] - 2024-08-17

### Added

- Added `MustMarshalCommandIntoEnvelope()`, `MustMarshalEventIntoEnvelope()` and `MustMarshalTimeoutIntoEnvelope()`.
- Added `UnmarshalCommandFromEnvelope()`, `UnmarshalEventFromEnvelope()` and `UnmarshalTimeoutFromEnvelope()`.

### Deprecated

- Deprecated `MustMarshalMessageIntoEnvelope()` and `UnmarshalMessageFromEnvelope()`.

## [0.7.4] - 2024-06-21

### Added
Expand Down Expand Up @@ -153,6 +164,7 @@ different marshalers/unmarshalers provided by `google.golang.org/protobuf`.
[0.7.0]: https://github.com/dogmatiq/marshalkit/releases/tag/v0.7.0
[0.7.1]: https://github.com/dogmatiq/marshalkit/releases/tag/v0.7.1
[0.7.3]: https://github.com/dogmatiq/marshalkit/releases/tag/v0.7.3
[0.7.5]: https://github.com/dogmatiq/marshalkit/releases/tag/v0.7.5

<!-- version template
## [0.0.1] - YYYY-MM-DD
Expand Down
68 changes: 66 additions & 2 deletions envelope.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import (
"github.com/dogmatiq/interopspec/envelopespec"
)

// MustMarshalMessageIntoEnvelope marshals a Dogma message into an envelopespec.Envelope.
// MustMarshalMessageIntoEnvelope marshals a Dogma message into an
// [envelopespec.Envelope].
//
// Deprecated: Use [MustMarshalCommandIntoEnvelope],
// [MustMarshalEventIntoEnvelope], or [MustMarshalTimeoutIntoEnvelope] instead.
func MustMarshalMessageIntoEnvelope(
vm ValueMarshaler,
m dogma.Message,
Expand All @@ -30,8 +34,41 @@ func MustMarshalMessageIntoEnvelope(
env.Data = p.Data
}

// MustMarshalCommandIntoEnvelope marshals a [dogma.Command] into an
// [envelopespec.Envelope].
func MustMarshalCommandIntoEnvelope(
vm ValueMarshaler,
m dogma.Command,
env *envelopespec.Envelope,
) {
MustMarshalMessageIntoEnvelope(vm, m, env)
}

// MustMarshalEventIntoEnvelope marshals a [dogma.Event] into an
// [envelopespec.Envelope].
func MustMarshalEventIntoEnvelope(
vm ValueMarshaler,
m dogma.Event,
env *envelopespec.Envelope,
) {
MustMarshalMessageIntoEnvelope(vm, m, env)
}

// MustMarshalTimeoutIntoEnvelope marshals a [dogma.Timeout] into an
// [envelopespec.Envelope].
func MustMarshalTimeoutIntoEnvelope(
vm ValueMarshaler,
m dogma.Timeout,
env *envelopespec.Envelope,
) {
MustMarshalMessageIntoEnvelope(vm, m, env)
}

// UnmarshalMessageFromEnvelope unmarshals a Dogma message from an
// envelopespec.Envelope.
// [envelopespec.Envelope].
//
// Deprecated: Use [UnmarshalCommandFromEnvelope], [UnmarshalEventFromEnvelope],
// or [UnmarshalTimeoutFromEnvelope] instead.
func UnmarshalMessageFromEnvelope(
vm ValueMarshaler,
env *envelopespec.Envelope,
Expand All @@ -57,6 +94,33 @@ func UnmarshalMessageFromEnvelope(
return m, nil
}

// UnmarshalCommandFromEnvelope unmarshals a [dogma.Command] from an
// [envelopespec.Envelope].
func UnmarshalCommandFromEnvelope(
vm ValueMarshaler,
env *envelopespec.Envelope,
) (dogma.Command, error) {
return UnmarshalMessageFromEnvelope(vm, env)
}

// UnmarshalEventFromEnvelope unmarshals a [dogma.Event] from an
// [envelopespec.Envelope].
func UnmarshalEventFromEnvelope(
vm ValueMarshaler,
env *envelopespec.Envelope,
) (dogma.Event, error) {
return UnmarshalMessageFromEnvelope(vm, env)
}

// UnmarshalTimeoutFromEnvelope unmarshals a [dogma.Timeout] from an
// [envelopespec.Envelope].
func UnmarshalTimeoutFromEnvelope(
vm ValueMarshaler,
env *envelopespec.Envelope,
) (dogma.Timeout, error) {
return UnmarshalMessageFromEnvelope(vm, env)
}

// MustMarshalEnvelopeIdentity marshals id to its protocol buffers
// representation, as used within envelopespec.Envelope.
func MustMarshalEnvelopeIdentity(id configkit.Identity) *envelopespec.Identity {
Expand Down
102 changes: 102 additions & 0 deletions envelope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,66 @@ var _ = Describe("func MustMarshalMessageIntoEnvelope()", func() {
})
})

var _ = Describe("func MustMarshalCommandIntoEnvelope()", func() {
It("marshals the message into the envelope", func() {
var env Envelope

MustMarshalCommandIntoEnvelope(
fixtures.Marshaler,
MessageC1,
&env,
)

Expect(&env).To(EqualX(
&Envelope{
PortableName: fixtures.MessageCPortableName,
MediaType: fixtures.MessageC1Packet.MediaType,
Data: fixtures.MessageC1Packet.Data,
},
))
})
})

var _ = Describe("func MustMarshalEventIntoEnvelope()", func() {
It("marshals the message into the envelope", func() {
var env Envelope

MustMarshalEventIntoEnvelope(
fixtures.Marshaler,
MessageE1,
&env,
)

Expect(&env).To(EqualX(
&Envelope{
PortableName: fixtures.MessageEPortableName,
MediaType: fixtures.MessageE1Packet.MediaType,
Data: fixtures.MessageE1Packet.Data,
},
))
})
})

var _ = Describe("func MustMarshalTimeoutIntoEnvelope()", func() {
It("marshals the message into the envelope", func() {
var env Envelope

MustMarshalTimeoutIntoEnvelope(
fixtures.Marshaler,
MessageT1,
&env,
)

Expect(&env).To(EqualX(
&Envelope{
PortableName: fixtures.MessageTPortableName,
MediaType: fixtures.MessageT1Packet.MediaType,
Data: fixtures.MessageT1Packet.Data,
},
))
})
})

var _ = Describe("func UnmarshalMessageFromEnvelope()", func() {
It("unmarshals the message from the envelope", func() {
env := &Envelope{
Expand All @@ -47,6 +107,48 @@ var _ = Describe("func UnmarshalMessageFromEnvelope()", func() {
})
})

var _ = Describe("func UnmarshalCommandFromEnvelope()", func() {
It("unmarshals the message from the envelope", func() {
env := &Envelope{
PortableName: fixtures.MessageCPortableName,
MediaType: fixtures.MessageC1Packet.MediaType,
Data: fixtures.MessageC1Packet.Data,
}

m, err := UnmarshalCommandFromEnvelope(fixtures.Marshaler, env)
Expect(err).ShouldNot(HaveOccurred())
Expect(m).To(Equal(MessageC1))
})
})

var _ = Describe("func UnmarshalEventFromEnvelope()", func() {
It("unmarshals the message from the envelope", func() {
env := &Envelope{
PortableName: fixtures.MessageEPortableName,
MediaType: fixtures.MessageE1Packet.MediaType,
Data: fixtures.MessageE1Packet.Data,
}

m, err := UnmarshalEventFromEnvelope(fixtures.Marshaler, env)
Expect(err).ShouldNot(HaveOccurred())
Expect(m).To(Equal(MessageE1))
})
})

var _ = Describe("func UnmarshalTimeoutFromEnvelope()", func() {
It("unmarshals the message from the envelope", func() {
env := &Envelope{
PortableName: fixtures.MessageTPortableName,
MediaType: fixtures.MessageT1Packet.MediaType,
Data: fixtures.MessageT1Packet.Data,
}

m, err := UnmarshalTimeoutFromEnvelope(fixtures.Marshaler, env)
Expect(err).ShouldNot(HaveOccurred())
Expect(m).To(Equal(MessageT1))
})
})

var _ = Describe("func MustMarshalEnvelopeIdentity()", func() {
It("returns the protocol buffers identity", func() {
in := configkit.MustNewIdentity("<name>", "81ff36f1-96ba-401a-8291-024a725cf60c")
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module github.com/dogmatiq/marshalkit

go 1.21
go 1.22

toolchain go1.22.5

require (
github.com/dogmatiq/configkit v0.13.4
github.com/dogmatiq/dogma v0.13.1
github.com/dogmatiq/dogma v0.14.0
github.com/dogmatiq/interopspec v0.5.4
github.com/fxamacker/cbor/v2 v2.7.0
github.com/jmalloc/gomegax v0.0.0-20200507221434-64fca4c0e03a
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dogmatiq/configkit v0.13.4 h1:5hfWDMV5fmG1hf1VZFCFicdiLhP7QxW5+O9FNMnkml4=
github.com/dogmatiq/configkit v0.13.4/go.mod h1:lwCG/to/1ZEJJXGyxCxqQvg7HIb8dDrQv4Xc40K32Dw=
github.com/dogmatiq/dogma v0.13.1 h1:b1nsqYNmICEG2egvZ43K8w04Jma+MWYL6yF5Ad12y9o=
github.com/dogmatiq/dogma v0.13.1/go.mod h1:9lyVA+6V2+E/exV0IrBOrkUiyFwIATEhv+b0vnB2umQ=
github.com/dogmatiq/dogma v0.14.0 h1:hY4iMX4QskZpP+ksJbw+WLwz0JAUyWgz2Aoof6qjz44=
github.com/dogmatiq/dogma v0.14.0/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.4 h1:klyGPy16zUKJartJIJOBZ4JrQ4LxFiY3wgzFTTiNlDk=
Expand Down

0 comments on commit 8eee7d7

Please sign in to comment.