refactor(rabbitmq): remove redundant publish mutex
This commit is contained in:
@@ -3,7 +3,6 @@ package rabbitmq
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
amqp "github.com/rabbitmq/amqp091-go"
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
@@ -22,7 +21,6 @@ type Client struct {
|
|||||||
conn *amqp.Connection
|
conn *amqp.Connection
|
||||||
channel *amqp.Channel
|
channel *amqp.Channel
|
||||||
returns <-chan amqp.Return
|
returns <-chan amqp.Return
|
||||||
mu sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(url string) (*Client, error) {
|
func New(url string) (*Client, error) {
|
||||||
@@ -54,10 +52,8 @@ func New(url string) (*Client, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Publish must not be called concurrently on the same client.
|
||||||
func (c *Client) Publish(ctx context.Context, messageID string, body []byte) error {
|
func (c *Client) Publish(ctx context.Context, messageID string, body []byte) error {
|
||||||
c.mu.Lock()
|
|
||||||
defer c.mu.Unlock()
|
|
||||||
|
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user