Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to make a persistent interceptor queue #57

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Coyote

Coyote is a RabbitMQ message sink. The default routing key is `#` so every message in the given `exchange` is routed to a ephemeral `interceptor` queue.
Coyote is a RabbitMQ message sink. The default routing key is `#` so every message in the given `exchange` is routed to an `interceptor` queue.

## Install

Expand Down Expand Up @@ -31,15 +31,15 @@ USAGE:
--exchange myexchange1,myexchange2=mykey2 # Messages with or without routing keys in multiple exchanges

VERSION:
v0.14.0
v0.16.0

COMMANDS:
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--url value RabbitMQ url, must start with amqps:// or amqp://.
--exchange value Exchange & routing key combinations to listen messages.
--queue value Interceptor queue name. (default: "interceptor")
--queue value Interceptor queue name. If provided, interceptor queue will not be auto deleted.
--store value SQLite filename to store events.
--insecure Skips certificate verification. (default: false)
--noprompt Disables password prompt. (default: false)
Expand Down
22 changes: 14 additions & 8 deletions coyote.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ func main() {
},
&cli.StringFlag{
Name: "queue",
Value: "interceptor",
Usage: "Interceptor queue name.",
Usage: "Interceptor queue name. If provided, interceptor queue will not be auto deleted.",
},
&cli.StringFlag{
Name: "store",
Expand Down Expand Up @@ -174,13 +173,20 @@ func main() {
log.Printf("💔 Terminating AMQP channel")
}()

var queueName string
persistent := ctx.IsSet("queue")
if persistent {
queueName = ctx.String("queue")
} else {
queueName = fmt.Sprintf("%s.%s", "coyote", uuid.NewString())
}
q, err := ch.QueueDeclare(
fmt.Sprintf("%s.%s", ctx.String("queue"), uuid.NewString()), // queue name
false, // is durable
true, // is auto delete
true, // is exclusive
false, // is no wait
nil, // args
queueName, // queue name
false, // is durable
!persistent, // is auto delete
!persistent, // is exclusive
false, // is no wait
nil, // args
)
if err != nil {
return fmt.Errorf("%s %w", color.RedString("failed to declare a queue:"), err)
Expand Down
2 changes: 1 addition & 1 deletion coyote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ COMMANDS:
GLOBAL OPTIONS:
--url value RabbitMQ url, must start with amqps:// or amqp://.
--exchange value Exchange & routing key combinations to listen messages.
--queue value Interceptor queue name. (default: "interceptor")
--queue value Interceptor queue name. If provided, interceptor queue will not be auto deleted.
--store value SQLite filename to store events.
--insecure Skips certificate verification. (default: false)
--noprompt Disables password prompt. (default: false)
Expand Down
Loading