Skip to content

Commit

Permalink
feat: updated amqp library
Browse files Browse the repository at this point in the history
  • Loading branch information
nicollaspetrelli committed Jul 10, 2023
1 parent f945634 commit cf6ce2d
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 33 deletions.
8 changes: 0 additions & 8 deletions .env

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode/
cover*
.env
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ I created this package to help me to automate the creation of my message broker,
Actually, this package has two ways to declare your message broker.

### Using a file

This package will read a json file with the declarations and will create the queues, exchanges and bindings.

The format of declaration file is the same as RabbitMQ export file.

> Has a example of declaration file is in the examples folder, If you want more information about the format of declaration file can be found in the [RabbitMQ Documentation](https://www.rabbitmq.com/management-cli.html#export-import)
*Example*
_Example_

```go
package main
Expand All @@ -45,10 +46,12 @@ func main() {
declarator.DeclareFromFile("examples/hello-world-broker.json")
}
```

### Using separated functions
Also you can use the separated functions to declare in your code.

*Example*
Also you can use the separated functions to declare in your code.

_Example_

```go
package main
Expand Down Expand Up @@ -110,13 +113,9 @@ Now you can use the package in your project following the examples above or in t
# Future Work

- [x] Add a feature to create and read json file with the declarations
- [x] Add support to bindings arguments
- [ ] Make RabbitMQ Connection optional, passing DSN and create a new connection
- [ ] Add unit tests
- [ ] Add integration tests
- [ ] Add examples of usage
- [ ] Add documentation
- [ ] Add CI/CD

# Contributing

Expand All @@ -140,7 +139,9 @@ Just follow the steps below:
- Install [docker-compose](https://docs.docker.com/compose/install/)

### Makefile

Please run the make target below to see the provided targets.

```sh
$ make help
```
Expand Down
9 changes: 3 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@ version: '3.9'
services:
rabbit:
build: env/
container_name: "rabbit-mqtt"
container_name: "rabbitmq"
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS}
ports:
- "${RABBITMQ_PORT}:5672"
- "${RABBITMQ_API_PORT}:15672"
- "${RABBITMQ_MQTT_PORT}:1883"
networks:
rabbit.mqtt:
aliases:
- "rabbit.mqtt.broker"
rabbitmq:

networks:
rabbit.mqtt:
rabbitmq:
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/nicollaspetrelli/declarator
go 1.20

require (
github.com/rabbitmq/amqp091-go v1.8.1
github.com/sirupsen/logrus v1.9.0
github.com/streadway/amqp v1.0.0
)

require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
18 changes: 14 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rabbitmq/amqp091-go v1.8.1 h1:RejT1SBUim5doqcL6s7iN6SBmsQqyTgXb1xMlH0h1hA=
github.com/rabbitmq/amqp091-go v1.8.1/go.mod h1:+jPrT9iY2eLjRaMSRHUhc3z14E/l85kv/f+6luSD3pc=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo=
github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package main

import (
"github.com/nicollaspetrelli/declarator/rabbitmq"
"github.com/streadway/amqp"
amqp "github.com/rabbitmq/amqp091-go"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/binding.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package rabbitmq

import (
amqp "github.com/rabbitmq/amqp091-go"
log "github.com/sirupsen/logrus"
"github.com/streadway/amqp"
)

// DeclareBindings declares all bindings from a list of bindings
Expand Down
2 changes: 1 addition & 1 deletion rabbitmq/declarator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"io"
"os"

amqp "github.com/rabbitmq/amqp091-go"
log "github.com/sirupsen/logrus"
"github.com/streadway/amqp"
)

type Declarator struct {
Expand Down
4 changes: 1 addition & 3 deletions rabbitmq/definitions.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package rabbitmq

import (
"github.com/streadway/amqp"
)
import amqp "github.com/rabbitmq/amqp091-go"

// BrokerDefinition is the structure of a broker definition json file
type BrokerDefinition struct {
Expand Down

0 comments on commit cf6ce2d

Please sign in to comment.