Update order_client.go
Some checks failed
Build and Publish / BuildAndDeploy (push) Failing after 36s
Some checks failed
Build and Publish / BuildAndDeploy (push) Failing after 36s
This commit is contained in:
@@ -12,9 +12,7 @@ type UpdateHandler interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RabbitTransportClient struct {
|
type RabbitTransportClient struct {
|
||||||
Url string
|
Url string
|
||||||
|
|
||||||
OrderTopic string
|
|
||||||
ClientName string
|
ClientName string
|
||||||
handler UpdateHandler
|
handler UpdateHandler
|
||||||
connection *amqp.Connection
|
connection *amqp.Connection
|
||||||
@@ -22,7 +20,7 @@ type RabbitTransportClient struct {
|
|||||||
quit chan bool
|
quit chan bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RabbitTransportClient) declareBindAndConsume(topic string) (<-chan amqp.Delivery, error) {
|
func (t *RabbitTransportClient) declareBindAndConsume() (<-chan amqp.Delivery, error) {
|
||||||
q, err := t.channel.QueueDeclare(
|
q, err := t.channel.QueueDeclare(
|
||||||
"order-queue", // name
|
"order-queue", // name
|
||||||
false, // durable
|
false, // durable
|
||||||
@@ -34,10 +32,7 @@ func (t *RabbitTransportClient) declareBindAndConsume(topic string) (<-chan amqp
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = t.channel.QueueBind(q.Name, topic, topic, false, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return t.channel.Consume(
|
return t.channel.Consume(
|
||||||
q.Name,
|
q.Name,
|
||||||
"",
|
"",
|
||||||
@@ -65,11 +60,11 @@ func (t *RabbitTransportClient) Connect(handler UpdateHandler) error {
|
|||||||
}
|
}
|
||||||
t.handler = handler
|
t.handler = handler
|
||||||
t.channel = ch
|
t.channel = ch
|
||||||
toAdd, err := t.declareBindAndConsume(t.OrderTopic)
|
toAdd, err := t.declareBindAndConsume()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Printf("Connected to rabbit order topic: %s", t.OrderTopic)
|
log.Printf("Connected to rabbit order topic")
|
||||||
go func(msgs <-chan amqp.Delivery) {
|
go func(msgs <-chan amqp.Delivery) {
|
||||||
for d := range msgs {
|
for d := range msgs {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user