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 eed5f7f commit 2ed0e81
Show file tree
Hide file tree
Showing 23 changed files with 71 additions and 235 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ 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.4] - 2024-08-17

### Changed

- Bumped Dogma to v0.14.0.

## [0.7.3] - 2024-07-16

### Added
Expand Down Expand Up @@ -194,6 +200,7 @@ placeholder format (`?` for MySQL, `$1` for everything else).
[0.7.1]: https://github.com/dogmatiq/projectionkit/releases/tag/v0.7.1
[0.7.2]: https://github.com/dogmatiq/projectionkit/releases/tag/v0.7.2
[0.7.3]: https://github.com/dogmatiq/projectionkit/releases/tag/v0.7.3
[0.7.4]: https://github.com/dogmatiq/projectionkit/releases/tag/v0.7.4

<!-- version template
## [0.0.1] - YYYY-MM-DD
Expand Down
9 changes: 1 addition & 8 deletions boltprojection/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package boltprojection

import (
"context"
"time"

"github.com/dogmatiq/dogma"
"github.com/dogmatiq/projectionkit/internal/identity"
Expand Down Expand Up @@ -53,7 +52,7 @@ func (a *adaptor) HandleEvent(
ctx context.Context,
r, c, n []byte,
s dogma.ProjectionEventScope,
m dogma.Message,
m dogma.Event,
) (bool, error) {
return a.repo.UpdateResourceVersionFn(
ctx,
Expand All @@ -75,12 +74,6 @@ func (a *adaptor) CloseResource(ctx context.Context, r []byte) error {
return a.repo.DeleteResource(ctx, r)
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (a *adaptor) TimeoutHint(m dogma.Message) time.Duration {
return a.handler.TimeoutHint(m)
}

// Compact reduces the size of the projection's data.
func (a *adaptor) Compact(ctx context.Context, s dogma.ProjectionCompactScope) error {
return a.handler.Compact(ctx, a.db, s)
Expand Down
19 changes: 1 addition & 18 deletions boltprojection/adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"io/ioutil"
"os"
"time"

"github.com/dogmatiq/dogma"
. "github.com/dogmatiq/dogma/fixtures"
Expand Down Expand Up @@ -85,7 +84,7 @@ var _ = Describe("type adaptor", func() {
context.Context,
*bbolt.Tx,
dogma.ProjectionEventScope,
dogma.Message,
dogma.Event,
) error {
return terr
}
Expand All @@ -102,22 +101,6 @@ var _ = Describe("type adaptor", func() {
})
})

Describe("func TimeoutHint()", func() {
It("forwards to the handler", func() {
handler.TimeoutHintFunc = func(
m dogma.Message,
) time.Duration {
Expect(m).To(BeIdenticalTo(MessageA1))
return 100 * time.Millisecond
}

d := adaptor.TimeoutHint(
MessageA1,
)
Expect(d).To(Equal(100 * time.Millisecond))
})
})

Describe("func Compact()", func() {
It("forwards to the handler", func() {
handler.CompactFunc = func(
Expand Down
19 changes: 2 additions & 17 deletions boltprojection/fixtures/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fixtures

import (
"context"
"time"

"github.com/dogmatiq/dogma"
"go.etcd.io/bbolt"
Expand All @@ -11,8 +10,7 @@ import (
// MessageHandler is a test implementation of boltdb.MessageHandler.
type MessageHandler struct {
ConfigureFunc func(c dogma.ProjectionConfigurer)
HandleEventFunc func(context.Context, *bbolt.Tx, dogma.ProjectionEventScope, dogma.Message) error
TimeoutHintFunc func(m dogma.Message) time.Duration
HandleEventFunc func(context.Context, *bbolt.Tx, dogma.ProjectionEventScope, dogma.Event) error
CompactFunc func(context.Context, *bbolt.DB, dogma.ProjectionCompactScope) error
}

Expand All @@ -37,7 +35,7 @@ func (h *MessageHandler) HandleEvent(
ctx context.Context,
tx *bbolt.Tx,
s dogma.ProjectionEventScope,
m dogma.Message,
m dogma.Event,
) error {
if h.HandleEventFunc != nil {
return h.HandleEventFunc(ctx, tx, s, m)
Expand All @@ -46,19 +44,6 @@ func (h *MessageHandler) HandleEvent(
return nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline for
// the handling of the given message by this handler.
//
// If h.TimeoutHintFunc is non-nil it returns h.TimeoutHintFunc(m), otherwise it
// returns 0.
func (h *MessageHandler) TimeoutHint(m dogma.Message) time.Duration {
if h.TimeoutHintFunc != nil {
return h.TimeoutHintFunc(m)
}

return 0
}

// Compact reduces the size of the projection's data.
//
// If h.CompactFunc is non-nil it returns h.CompactFunc(ctx,db,s), otherwise it
Expand Down
24 changes: 4 additions & 20 deletions boltprojection/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package boltprojection

import (
"context"
"time"

"github.com/dogmatiq/dogma"
"go.etcd.io/bbolt"
Expand Down Expand Up @@ -40,28 +39,13 @@ type MessageHandler interface {
// portability the implementation SHOULD NOT assume that HandleEvent() will
// be called with events in the same order that they were recorded.
//
// The supplied context parameter SHOULD have a deadline. The implementation
// SHOULD NOT impose its own deadline. Instead a suitable timeout duration
// can be suggested to the engine via the handler's TimeoutHint() method.
//
// The engine MUST NOT call HandleEvent() with any message of a type that
// has not been configured for consumption by a prior call to Configure().
// If any such message is passed, the implementation MUST panic with the
// UnexpectedMessage value.
//
// The engine MAY call HandleEvent() from multiple goroutines concurrently.
HandleEvent(ctx context.Context, tx *bbolt.Tx, s dogma.ProjectionEventScope, m dogma.Message) error

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
//
// The hint SHOULD be as short as possible. The implementation MAY return a
// zero-value to indicate that no hint can be made.
//
// The engine SHOULD use a duration as close as possible to the hint. Use of
// a duration shorter than the hint is NOT RECOMMENDED, as this will likely
// lead to repeated message handling failures.
TimeoutHint(m dogma.Message) time.Duration
HandleEvent(ctx context.Context, tx *bbolt.Tx, s dogma.ProjectionEventScope, m dogma.Event) error

// Compact reduces the size of the projection's data.
//
Expand All @@ -88,9 +72,9 @@ type NoCompactBehavior struct{}

// Compact returns nil.
func (NoCompactBehavior) Compact(
ctx context.Context,
db *bbolt.DB,
s dogma.ProjectionCompactScope,
context.Context,
*bbolt.DB,
dogma.ProjectionCompactScope,
) error {
return nil
}
12 changes: 6 additions & 6 deletions boltprojection/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewResourceRepository(
}

// ResourceVersion returns the version of the resource r.
func (rr *ResourceRepository) ResourceVersion(ctx context.Context, r []byte) ([]byte, error) {
func (rr *ResourceRepository) ResourceVersion(_ context.Context, r []byte) ([]byte, error) {
var v []byte

return v, rr.db.View(func(tx *bbolt.Tx) error {
Expand All @@ -40,7 +40,7 @@ func (rr *ResourceRepository) ResourceVersion(ctx context.Context, r []byte) ([]

// StoreResourceVersion sets the version of the resource r to v without checking
// the current version.
func (rr *ResourceRepository) StoreResourceVersion(ctx context.Context, r, v []byte) error {
func (rr *ResourceRepository) StoreResourceVersion(_ context.Context, r, v []byte) error {
return rr.db.Update(func(tx *bbolt.Tx) error {
b, err := makeHandlerBucket(tx, rr.key)
if err != nil {
Expand All @@ -63,7 +63,7 @@ func (rr *ResourceRepository) StoreResourceVersion(ctx context.Context, r, v []b
//
// If c is not the current version of r, it returns false and no update occurs.
func (rr *ResourceRepository) UpdateResourceVersion(
ctx context.Context,
_ context.Context,
r, c, n []byte,
) (ok bool, err error) {
return ok, rr.db.Update(func(tx *bbolt.Tx) error {
Expand All @@ -73,8 +73,8 @@ func (rr *ResourceRepository) UpdateResourceVersion(
})
}

// UpdateResourceVersion updates the version of the resource r to n and performs
// a user-defined operation within the same transaction.
// UpdateResourceVersionFn updates the version of the resource r to n and
// performs a user-defined operation within the same transaction.
//
// If c is not the current version of r, it returns false and no update occurs.
func (rr *ResourceRepository) UpdateResourceVersionFn(
Expand Down Expand Up @@ -123,7 +123,7 @@ func (rr *ResourceRepository) updateResourceVersion(
}

// DeleteResource removes all information about the resource r.
func (rr *ResourceRepository) DeleteResource(ctx context.Context, r []byte) error {
func (rr *ResourceRepository) DeleteResource(_ context.Context, r []byte) error {
return rr.db.Update(func(tx *bbolt.Tx) error {
if b := handlerBucket(tx, rr.key); b != nil {
return b.Delete(r)
Expand Down
9 changes: 1 addition & 8 deletions dynamoprojection/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package dynamoprojection

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/dogmatiq/dogma"
Expand Down Expand Up @@ -69,7 +68,7 @@ func (a *adaptor) HandleEvent(
ctx context.Context,
r, c, n []byte,
s dogma.ProjectionEventScope,
m dogma.Message,
m dogma.Event,
) (bool, error) {
items, err := a.handler.HandleEvent(ctx, s, m)
if err != nil {
Expand All @@ -90,12 +89,6 @@ func (a *adaptor) CloseResource(ctx context.Context, r []byte) error {
return a.repo.DeleteResource(ctx, r)
}

// TimeoutHint returns a duration that is suitable for computing a deadline
// for the handling of the given message by this handler.
func (a *adaptor) TimeoutHint(m dogma.Message) time.Duration {
return a.handler.TimeoutHint(m)
}

// Compact reduces the size of the projection's data.
func (a *adaptor) Compact(ctx context.Context, s dogma.ProjectionCompactScope) error {
return a.handler.Compact(ctx, a.client, s)
Expand Down
20 changes: 2 additions & 18 deletions dynamoprojection/adaptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var _ = Describe("type adaptor", func() {
handler.HandleEventFunc = func(
context.Context,
dogma.ProjectionEventScope,
dogma.Message,
dogma.Event,
) ([]types.TransactWriteItem, error) {
return nil, terr
}
Expand Down Expand Up @@ -207,7 +207,7 @@ var _ = Describe("type adaptor", func() {
handler.HandleEventFunc = func(
context.Context,
dogma.ProjectionEventScope,
dogma.Message,
dogma.Event,
) ([]types.TransactWriteItem, error) {
return []types.TransactWriteItem{
{
Expand Down Expand Up @@ -240,22 +240,6 @@ var _ = Describe("type adaptor", func() {
})
})

Describe("func TimeoutHint()", func() {
It("forwards to the handler", func() {
handler.TimeoutHintFunc = func(
m dogma.Message,
) time.Duration {
Expect(m).To(BeIdenticalTo(MessageA1))
return 100 * time.Millisecond
}

d := adaptor.TimeoutHint(
MessageA1,
)
Expect(d).To(Equal(100 * time.Millisecond))
})
})

Describe("func Compact()", func() {
It("forwards to the handler", func() {
handler.CompactFunc = func(
Expand Down
19 changes: 2 additions & 17 deletions dynamoprojection/fixtures/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fixtures

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
Expand All @@ -12,8 +11,7 @@ import (
// MessageHandler is a test implementation of dynamoprojection.MessageHandler.
type MessageHandler struct {
ConfigureFunc func(c dogma.ProjectionConfigurer)
HandleEventFunc func(ctx context.Context, s dogma.ProjectionEventScope, m dogma.Message) ([]types.TransactWriteItem, error)
TimeoutHintFunc func(m dogma.Message) time.Duration
HandleEventFunc func(ctx context.Context, s dogma.ProjectionEventScope, m dogma.Event) ([]types.TransactWriteItem, error)
CompactFunc func(context.Context, *dynamodb.Client, dogma.ProjectionCompactScope) error
}

Expand All @@ -37,7 +35,7 @@ func (h *MessageHandler) Configure(c dogma.ProjectionConfigurer) {
func (h *MessageHandler) HandleEvent(
ctx context.Context,
s dogma.ProjectionEventScope,
m dogma.Message,
m dogma.Event,
) ([]types.TransactWriteItem, error) {
if h.HandleEventFunc != nil {
return h.HandleEventFunc(ctx, s, m)
Expand All @@ -46,19 +44,6 @@ func (h *MessageHandler) HandleEvent(
return nil, nil
}

// TimeoutHint returns a duration that is suitable for computing a deadline for
// the handling of the given message by this handler.
//
// If h.TimeoutHintFunc is non-nil it returns h.TimeoutHintFunc(m), otherwise it
// returns 0.
func (h *MessageHandler) TimeoutHint(m dogma.Message) time.Duration {
if h.TimeoutHintFunc != nil {
return h.TimeoutHintFunc(m)
}

return 0
}

// Compact reduces the size of the projection's data.
//
// If h.CompactFunc is non-nil it returns h.CompactFunc(ctx,db,s), otherwise it
Expand Down
Loading

0 comments on commit 2ed0e81

Please sign in to comment.