11package transaction
22
33import (
4- "context"
4+ "context"
55
6- "github.com/golang/protobuf/proto"
7- "github.com/golang/protobuf/ptypes/empty"
8- "github.com/google/uuid"
9- "github.com/micro/go-micro/v2"
10- "github.com/micro/go-micro/v2/metadata"
11- "github.com/micro/go-micro/v2/server"
12- "github.com/rs/zerolog/log"
6+ "github.com/golang/protobuf/proto"
7+ "github.com/golang/protobuf/ptypes/empty"
8+ "github.com/micro/go-micro/v2"
9+ "github.com/micro/go-micro/v2/server"
10+ "github.com/rs/zerolog/log"
1311
14- transactionPB "github.com/xmlking/micro-starter-kit/service/recorder/proto/transaction"
15- "github.com/xmlking/micro-starter-kit/shared/constants"
12+ transactionPB "github.com/xmlking/micro-starter-kit/service/recorder/proto/transaction"
1613)
1714
1815func publish (ctx context.Context , publisher micro.Event , req , rsp proto.Message ) (err error ) {
@@ -37,9 +34,6 @@ func publish(ctx context.Context, publisher micro.Event, req, rsp proto.Message)
3734func NewHandlerWrapper (p micro.Event ) server.HandlerWrapper {
3835 return func (fn server.HandlerFunc ) server.HandlerFunc {
3936 return func (ctx context.Context , req server.Request , rsp interface {}) (err error ) {
40- // add TranID to context if not present
41- // ctx = metadata.Set(ctx, constants.TransID, uuid.New().String())
42- ctx = metadata .MergeContext (ctx , map [string ]string {constants .TransID : uuid .New ().String ()}, false )
4337 err = fn (ctx , req , rsp )
4438 // we already logged error in Publish. lets ignore error here. # Note: this is blocking call..
4539 _ = publish (ctx , p , req .Body ().(proto.Message ), rsp .(proto.Message ))
@@ -53,8 +47,6 @@ func NewHandlerWrapper(p micro.Event) server.HandlerWrapper {
5347func NewSubscriberWrapper (p micro.Event ) server.SubscriberWrapper {
5448 return func (fn server.SubscriberFunc ) server.SubscriberFunc {
5549 return func (ctx context.Context , req server.Message ) (err error ) {
56- // add TranID to context if not present
57- ctx = metadata .MergeContext (ctx , map [string ]string {constants .TransID : uuid .New ().String ()}, false )
5850 err = fn (ctx , req )
5951 // we already logged error in Publish. lets ignore error here.
6052 // FIXME: `Micro-From-Service` is not replaced
0 commit comments