Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fogfish committed Nov 17, 2023
1 parent 3589bb5 commit 57b1133
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
8 changes: 8 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// Copyright (C) 2021 - 2022 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the Apache License Version 2.0. See the LICENSE file for details.
// https://github.com/fogfish/swarm
//

package swarm

import "github.com/fogfish/faults"
Expand Down
11 changes: 11 additions & 0 deletions examples/bytes/dequeue/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main

import (
"log/slog"
"os"

"github.com/fogfish/swarm"
"github.com/fogfish/swarm/broker/sqs"
Expand All @@ -18,6 +19,16 @@ import (
)

func main() {
slog.SetDefault(
slog.New(
slog.NewTextHandler(os.Stdout,
&slog.HandlerOptions{
Level: slog.LevelDebug,
},
),
),
)

q := queue.Must(sqs.New("swarm-test", swarm.WithLogStdErr()))

go actor("user").handle(bytes.Dequeue(q, "User"))
Expand Down
6 changes: 3 additions & 3 deletions examples/bytes/enqueue/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ func main() {

q := queue.Must(sqs.New("swarm-test", swarm.WithLogStdErr()))

user := queue.LogDeadLetters(bytes.Enqueue(q, "User"))
note := queue.LogDeadLetters(bytes.Enqueue(q, "Note"))
like := queue.LogDeadLetters(bytes.Enqueue(q, "Like"))
user := swarm.LogDeadLetters(bytes.Enqueue(q, "User"))
note := swarm.LogDeadLetters(bytes.Enqueue(q, "Note"))
like := swarm.LogDeadLetters(bytes.Enqueue(q, "Like"))

user <- []byte("user|some text by user")

Expand Down
6 changes: 3 additions & 3 deletions examples/eventbridge/enqueue/eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func main() {
swarm.WithLogStdErr(),
))

user := queue.LogDeadLetters(queue.Enqueue[*User](q))
note := queue.LogDeadLetters(queue.Enqueue[*Note](q))
like := queue.LogDeadLetters(queue.Enqueue[*Like](q))
user := swarm.LogDeadLetters(queue.Enqueue[*User](q))
note := swarm.LogDeadLetters(queue.Enqueue[*Note](q))
like := swarm.LogDeadLetters(queue.Enqueue[*Like](q))

user <- &User{ID: "user", Text: "some text"}
note <- &Note{ID: "note", Text: "some text"}
Expand Down
8 changes: 4 additions & 4 deletions examples/events/enqueue/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ func (EventNote) HKT2(*Note) {}
func main() {
q := queue.Must(sqs.New("swarm-test", swarm.WithLogStdErr()))

userCreated := queue.LogDeadLetters(events.Enqueue[*User, EventCreateUser](q))
userUpdated := queue.LogDeadLetters(events.Enqueue[*User, EventUpdateUser](q))
userRemoved := queue.LogDeadLetters(events.Enqueue[*User, EventRemoveUser](q))
note := queue.LogDeadLetters(events.Enqueue[*Note, EventNote](q))
userCreated := swarm.LogDeadLetters(events.Enqueue[*User, EventCreateUser](q))
userUpdated := swarm.LogDeadLetters(events.Enqueue[*User, EventUpdateUser](q))
userRemoved := swarm.LogDeadLetters(events.Enqueue[*User, EventRemoveUser](q))
note := swarm.LogDeadLetters(events.Enqueue[*Note, EventNote](q))

//
// Multiple channels emits events
Expand Down
6 changes: 3 additions & 3 deletions examples/sqs/enqueue/sqs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func main() {

q := queue.Must(sqs.New("swarm-test", swarm.WithLogStdErr()))

user := queue.LogDeadLetters(queue.Enqueue[*User](q))
note := queue.LogDeadLetters(queue.Enqueue[*Note](q))
like := queue.LogDeadLetters(queue.Enqueue[*Like](q))
user := swarm.LogDeadLetters(queue.Enqueue[*User](q))
note := swarm.LogDeadLetters(queue.Enqueue[*Note](q))
like := swarm.LogDeadLetters(queue.Enqueue[*Like](q))

user <- &User{ID: "user", Text: "some text by user"}

Expand Down
4 changes: 2 additions & 2 deletions queue/dlq.go → service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// https://github.com/fogfish/swarm
//

package queue
package swarm

import (
"log/slog"
Expand All @@ -16,7 +16,7 @@ import (

// Consumes dead letter messages
//
// queue.LogDeadLetters(queue.Enqueue(...))
// swarm.LogDeadLetters(queue.Enqueue(...))
func LogDeadLetters[T any](out chan<- T, err <-chan T) chan<- T {
pipe.ForEach[T](err, func(t T) {
slog.Error("Fail to emit", "object", t)
Expand Down

0 comments on commit 57b1133

Please sign in to comment.