update for latest micro logger changes
Some checks failed
build / test (push) Failing after 4m54s
build / lint (push) Successful in 9m28s
codeql / analyze (go) (push) Failing after 14m54s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-10-16 23:24:23 +03:00
parent 78194a8863
commit 6315169aca
4 changed files with 40 additions and 23 deletions

18
go.mod
View File

@ -1,20 +1,20 @@
module go.unistack.org/micro-broker-service/v3
go 1.21
go 1.22
toolchain go1.23.1
toolchain go1.23.2
require (
go.unistack.org/micro-server-http/v3 v3.11.29
go.unistack.org/micro/v3 v3.10.91
google.golang.org/protobuf v1.34.2
go.unistack.org/micro-server-http/v3 v3.11.31
go.unistack.org/micro/v3 v3.10.97
google.golang.org/protobuf v1.35.1
)
require (
github.com/google/go-cmp v0.6.0 // indirect
go.unistack.org/micro-proto/v3 v3.4.1 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
google.golang.org/grpc v1.67.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/grpc v1.67.1 // indirect
)

14
go.sum
View File

@ -8,21 +8,35 @@ go.unistack.org/micro-proto/v3 v3.4.1/go.mod h1:okx/cnOhzuCX0ggl/vToatbCupi0O44d
go.unistack.org/micro-server-http/v3 v3.10.14 h1:yWeT/Ljag/ueiV6eSK3Xi620b+HzPOgZLCpwx+tQxns=
go.unistack.org/micro-server-http/v3 v3.11.29 h1:IncjMVunK3I4yJ8fIcUjy5ttEVaXskfGb6QXYOV3b5M=
go.unistack.org/micro-server-http/v3 v3.11.29/go.mod h1:GaVKQVMSeHlcBvL2l1kHRxOWuSJ/l+uhUCLHYGidaE0=
go.unistack.org/micro-server-http/v3 v3.11.31 h1:PVga/ICYj4+8vM7VI82q9/wFBvn/O2zkCzXO6lIbnn8=
go.unistack.org/micro-server-http/v3 v3.11.31/go.mod h1:3hlTQj3e6HQziJa2Coz/BwvVbt3oRejOevyAPUCuBEk=
go.unistack.org/micro/v3 v3.10.23 h1:4BE7NwwyJbCWOfzjzztamBxJSgRHHW1uQtMGNDLHG3s=
go.unistack.org/micro/v3 v3.10.91 h1:vuJY4tXwpqimwIkEJ3TozMYNVQQs+C5QMlQWPgSY/YM=
go.unistack.org/micro/v3 v3.10.91/go.mod h1:erMgt3Bl7vQQ0e9UpQyR5NlLiZ9pKeEJ9+1tfYFaqUg=
go.unistack.org/micro/v3 v3.10.97 h1:8l7fv+i06/PjPrBBhRC/ZQkWGIOuHPg3jJN0vktYE78=
go.unistack.org/micro/v3 v3.10.97/go.mod h1:YzMldzHN9Ei+zy5t/Psu7RUWDZwUfrNYiStSQtTz90g=
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E=
google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

View File

@ -98,8 +98,8 @@ func (b *serviceBroker) Publish(ctx context.Context, topic string, msg *broker.M
func (b *serviceBroker) publish(ctx context.Context, msgs []*broker.Message, opts ...broker.PublishOption) error {
for _, msg := range msgs {
topic, _ := msg.Header.Get(metadata.HeaderTopic)
if logger.V(logger.TraceLevel) {
logger.Tracef(ctx, "Publishing to topic %s broker %v", topic, b.addrs)
if b.opts.Logger.V(logger.TraceLevel) {
b.opts.Logger.Trace(ctx, fmt.Sprintf("Publishing to topic %s broker %v", topic, b.addrs))
}
_, err := b.client.Publish(ctx, &pb.PublishRequest{
Topic: topic,
@ -122,8 +122,8 @@ func (b *serviceBroker) BatchSubscribe(ctx context.Context, topic string, handle
func (b *serviceBroker) Subscribe(ctx context.Context, topic string, handler broker.Handler, opts ...broker.SubscribeOption) (broker.Subscriber, error) {
options := broker.NewSubscribeOptions(opts...)
if logger.V(logger.TraceLevel) {
logger.Tracef(ctx, "Subscribing to topic %s group %s broker %v", topic, options.Group, b.addrs)
if b.opts.Logger.V(logger.TraceLevel) {
b.opts.Logger.Trace(ctx, fmt.Sprintf("Subscribing to topic %s group %s broker %v", topic, options.Group, b.addrs))
}
stream, err := b.client.Subscribe(ctx, &pb.SubscribeRequest{
Topic: topic,
@ -140,32 +140,33 @@ func (b *serviceBroker) Subscribe(ctx context.Context, topic string, handler bro
stream: stream,
closed: make(chan bool),
options: options,
opts: b.opts,
}
go func() {
for {
select {
case <-sub.closed:
if logger.V(logger.TraceLevel) {
logger.Tracef(ctx, "Unsubscribed from topic %s", topic)
if b.opts.Logger.V(logger.TraceLevel) {
b.opts.Logger.Trace(ctx, "Unsubscribed from topic %s", topic)
}
return
default:
if logger.V(logger.TraceLevel) {
if b.opts.Logger.V(logger.TraceLevel) {
// run the subscriber
logger.Tracef(ctx, "Streaming from broker %v to topic [%s] group [%s]", b.addrs, topic, options.Group)
b.opts.Logger.Trace(ctx, fmt.Sprintf("Streaming from broker %v to topic [%s] group [%s]", b.addrs, topic, options.Group))
}
if err := sub.run(ctx); err != nil {
if logger.V(logger.TraceLevel) {
logger.Tracef(ctx, "Resubscribing to topic %s broker %v", topic, b.addrs)
if b.opts.Logger.V(logger.TraceLevel) {
b.opts.Logger.Trace(ctx, fmt.Sprintf("Resubscribing to topic %s broker %v", topic, b.addrs))
}
stream, err := b.client.Subscribe(ctx, &pb.SubscribeRequest{
Topic: topic,
Group: options.Group,
}, client.WithAddress(b.addrs...), client.WithRequestTimeout(time.Hour))
if err != nil {
if logger.V(logger.TraceLevel) {
logger.Tracef(ctx, "Failed to resubscribe to topic %s: %v", topic, err)
if b.opts.Logger.V(logger.TraceLevel) {
b.opts.Logger.Trace(ctx, fmt.Sprintf("Failed to resubscribe to topic %s: %v", topic, err))
}
time.Sleep(time.Second)
continue

View File

@ -2,6 +2,7 @@ package service
import (
"context"
"fmt"
pbmicro "go.unistack.org/micro-broker-service/v3/micro"
"go.unistack.org/micro/v3/broker"
@ -15,6 +16,7 @@ type serviceSub struct {
handler broker.Handler
stream pbmicro.BrokerService_SubscribeClient
closed chan bool
opts broker.Options
options broker.SubscribeOptions
}
@ -75,8 +77,8 @@ func (s *serviceSub) run(ctx context.Context) error {
msg, err := s.stream.Recv()
ctx := metadata.NewIncomingContext(context.Background(), msg.Header)
if err != nil {
if logger.V(logger.TraceLevel) {
logger.Tracef(ctx, "streaming error for subcription to topic %s: %v", s.Topic(), err)
if s.opts.Logger.V(logger.TraceLevel) {
s.opts.Logger.Trace(ctx, fmt.Sprintf("streaming error for subcription to topic %s: %v", s.Topic(), err))
}
// close the exit channel