优化结构
This commit is contained in:
@@ -191,6 +191,9 @@ func (c *RabbitMQ) Publish(ctx context.Context, topic string, payload []byte, qo
|
||||
if c == nil {
|
||||
return ErrUnavailable
|
||||
}
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
if c != nil && strings.TrimSpace(topic) == "" {
|
||||
topic = c.config.RoutingKey
|
||||
}
|
||||
@@ -231,6 +234,9 @@ func (c *RabbitMQ) Subscribe(ctx context.Context, topic string, qos byte, handle
|
||||
if c == nil {
|
||||
return ErrUnavailable
|
||||
}
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
if c != nil && strings.TrimSpace(topic) == "" {
|
||||
topic = c.config.RoutingKey
|
||||
}
|
||||
@@ -331,6 +337,9 @@ func (c *RabbitMQ) Unsubscribe(ctx context.Context, topics ...string) error {
|
||||
if c == nil {
|
||||
return ErrUnavailable
|
||||
}
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
}
|
||||
if len(topics) == 0 {
|
||||
return errors.New("rabbitmq routing keys are empty")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user