diff --git a/errors.go b/errors.go index 05a83be..08bbc77 100644 --- a/errors.go +++ b/errors.go @@ -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" diff --git a/examples/bytes/dequeue/bytes.go b/examples/bytes/dequeue/bytes.go index bbf5c11..30487d2 100644 --- a/examples/bytes/dequeue/bytes.go +++ b/examples/bytes/dequeue/bytes.go @@ -10,6 +10,7 @@ package main import ( "log/slog" + "os" "github.com/fogfish/swarm" "github.com/fogfish/swarm/broker/sqs" @@ -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")) diff --git a/examples/bytes/enqueue/bytes.go b/examples/bytes/enqueue/bytes.go index a67b0b2..8a97a9b 100644 --- a/examples/bytes/enqueue/bytes.go +++ b/examples/bytes/enqueue/bytes.go @@ -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") diff --git a/examples/eventbridge/enqueue/eventbridge.go b/examples/eventbridge/enqueue/eventbridge.go index b8bec35..9ec030a 100644 --- a/examples/eventbridge/enqueue/eventbridge.go +++ b/examples/eventbridge/enqueue/eventbridge.go @@ -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"} diff --git a/examples/events/enqueue/events.go b/examples/events/enqueue/events.go index 9ac2883..b5ff66c 100644 --- a/examples/events/enqueue/events.go +++ b/examples/events/enqueue/events.go @@ -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 diff --git a/examples/sqs/enqueue/sqs.go b/examples/sqs/enqueue/sqs.go index 4855eff..f69a990 100644 --- a/examples/sqs/enqueue/sqs.go +++ b/examples/sqs/enqueue/sqs.go @@ -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"} diff --git a/queue/dlq.go b/service.go similarity index 89% rename from queue/dlq.go rename to service.go index a110842..c35a907 100644 --- a/queue/dlq.go +++ b/service.go @@ -6,7 +6,7 @@ // https://github.com/fogfish/swarm // -package queue +package swarm import ( "log/slog" @@ -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)