Add logging for broker handler
This commit is contained in:
parent
b80654bf7e
commit
05eacd74c8
@ -3,6 +3,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/micro/go-micro/util/log"
|
||||||
"github.com/micro/go-micro/broker"
|
"github.com/micro/go-micro/broker"
|
||||||
pb "github.com/micro/go-micro/broker/service/proto"
|
pb "github.com/micro/go-micro/broker/service/proto"
|
||||||
"github.com/micro/go-micro/errors"
|
"github.com/micro/go-micro/errors"
|
||||||
@ -13,6 +14,7 @@ type Broker struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Broker) Publish(ctx context.Context, req *pb.PublishRequest, rsp *pb.Empty) error {
|
func (b *Broker) Publish(ctx context.Context, req *pb.PublishRequest, rsp *pb.Empty) error {
|
||||||
|
log.Debugf("Publishing message to %s topic", req.Topic)
|
||||||
err := b.Broker.Publish(req.Topic, &broker.Message{
|
err := b.Broker.Publish(req.Topic, &broker.Message{
|
||||||
Header: req.Message.Header,
|
Header: req.Message.Header,
|
||||||
Body: req.Message.Body,
|
Body: req.Message.Body,
|
||||||
@ -42,6 +44,7 @@ func (b *Broker) Subscribe(ctx context.Context, req *pb.SubscribeRequest, stream
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debugf("Subscribing to %s topic", req.Topic)
|
||||||
sub, err := b.Broker.Subscribe(req.Topic, handler, broker.Queue(req.Queue))
|
sub, err := b.Broker.Subscribe(req.Topic, handler, broker.Queue(req.Queue))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.InternalServerError("go.micro.broker", err.Error())
|
return errors.InternalServerError("go.micro.broker", err.Error())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user