Skip to content

Commit

Permalink
shorten env variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
clezag committed Nov 19, 2024
1 parent 6c21a2d commit 0c5399f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions dc/dc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (

type Env struct {
ms.Env
PROVIDER string
RABBITMQ_URI string
RABBITMQ_EXCHANGE string `default:"ingress"`
RABBITMQ_CLIENT string
PROVIDER string
MQ_URI string
MQ_EXCHANGE string `default:"ingress"`
MQ_CLIENT string
}

func PubFromEnv(e Env) (chan<- dto.RawAny, error) {
return Pub(e.RABBITMQ_URI, e.RABBITMQ_EXCHANGE, e.RABBITMQ_CLIENT)
return Pub(e.MQ_URI, e.MQ_EXCHANGE, e.MQ_CLIENT)
}

func Pub(uri string, client string, exchange string) (chan<- dto.RawAny, error) {
Expand Down
3 changes: 3 additions & 0 deletions mq/mq.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func Connect(uri string, client string) (R, error) {
return r, err
}

prefetch := 3
ch.Qos(prefetch, 0, true)

r.Ch = ch
r.Con = con

Expand Down
14 changes: 7 additions & 7 deletions tr/tr.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (

type Env struct {
ms.Env
RABBITMQ_URI string
RABBITMQ_EXCHANGE string `default:"routed"`
RABBITMQ_CLIENT string
RABBITMQ_QUEUE string
RABBITMQ_KEY string
MONGO_URI string
MQ_URI string
MQ_EXCHANGE string `default:"routed"`
MQ_CLIENT string
MQ_QUEUE string
MQ_KEY string
MONGO_URI string
}

func getMongo[Raw any](uri string, m dto.Notification) (*dto.Raw[Raw], error) {
Expand Down Expand Up @@ -67,7 +67,7 @@ func msgReject(d *amqp091.Delivery) {

// Default configuration for transformers with one queue
func ListenFromEnv[Raw any](e Env, handler func(*dto.Raw[Raw]) error) error {
return Listen(e.RABBITMQ_URI, e.RABBITMQ_CLIENT, e.RABBITMQ_EXCHANGE, e.RABBITMQ_QUEUE, e.RABBITMQ_KEY, e.MONGO_URI, handler)
return Listen(e.MQ_URI, e.MQ_CLIENT, e.MQ_EXCHANGE, e.MQ_QUEUE, e.MQ_KEY, e.MONGO_URI, handler)
}

// Configurable listen for transformers with multiple queues
Expand Down

0 comments on commit 0c5399f

Please sign in to comment.