Skip to content

Commit

Permalink
(fix) create duplex eventbridge broker (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish authored Oct 26, 2024
1 parent 0dcf71a commit d9884ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
15 changes: 15 additions & 0 deletions broker/eventbridge/eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ func NewDequeuer(bus string, opts ...Option) (*kernel.Dequeuer, error) {
return kernel.NewDequeuer(bridge, c.config), nil
}

// Create enqueue & dequeue routine to AWS EventBridge
func New(bus string, opts ...Option) (*kernel.Kernel, error) {
cli, err := newEventBridge(bus, opts...)
if err != nil {
return nil, err
}

bridge := &bridge{kernel.NewBridge(cli.config.TimeToFlight)}

return kernel.New(
kernel.NewEnqueuer(cli, cli.config),
kernel.NewDequeuer(bridge, cli.config),
), nil
}

func newEventBridge(queue string, opts ...Option) (*Client, error) {
c := &Client{bus: queue}

Expand Down
8 changes: 8 additions & 0 deletions broker/eventbridge/eventbridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ func TestWriter(t *testing.T) {
})
}

func TestBroker(t *testing.T) {
t.Run("New", func(t *testing.T) {
q, err := New("test")
it.Then(t).Should(it.Nil(err))
q.Close()
})
}

//------------------------------------------------------------------------------

type mockEventBridge struct {
Expand Down
2 changes: 1 addition & 1 deletion broker/eventbridge/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

package eventbridge

const Version = "broker/eventbridge/v0.20.2"
const Version = "broker/eventbridge/v0.20.3"

0 comments on commit d9884ba

Please sign in to comment.