You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2025/04/02 01:14:52 UTC

(skywalking-banyandb) 01/01: Fix the bug that the log doesn't get config

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch log
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit 1c6023684f0ae8a93ec0e601ccc30881a7373084
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Tue Apr 1 14:22:36 2025 +0000

    Fix the bug that the log doesn't get config
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 banyand/backup/lifecycle/steps.go   |  2 +-
 banyand/queue/pub/pub.go            | 13 +++++++++++--
 banyand/queue/pub/pub_suite_test.go |  3 +--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/banyand/backup/lifecycle/steps.go b/banyand/backup/lifecycle/steps.go
index 5a519a2a..7816b881 100644
--- a/banyand/backup/lifecycle/steps.go
+++ b/banyand/backup/lifecycle/steps.go
@@ -147,7 +147,7 @@ func parseGroup(ctx context.Context, g *commonv1.Group, nodeLabels map[string]st
 	if err = nodeSel.PreRun(ctx); err != nil {
 		return 0, nil, nil, errors.WithMessage(err, "failed to run node selector")
 	}
-	client := pub.New(nil)
+	client := pub.NewWithoutMetadata()
 	if g.Catalog == commonv1.Catalog_CATALOG_STREAM {
 		_ = grpc.NewClusterNodeRegistry(data.TopicStreamWrite, client, nodeSel)
 	} else {
diff --git a/banyand/queue/pub/pub.go b/banyand/queue/pub/pub.go
index a55995b7..8d32d6a0 100644
--- a/banyand/queue/pub/pub.go
+++ b/banyand/queue/pub/pub.go
@@ -225,16 +225,25 @@ func New(metadata metadata.Repo) queue.Client {
 		registered: make(map[string]*databasev1.Node),
 		handlers:   make(map[bus.Topic]schema.EventHandler),
 		closer:     run.NewCloser(1),
-		log:        logger.GetLogger("server-queue-pub"),
 	}
 }
 
+// NewWithoutMetadata returns a new queue client without metadata.
+func NewWithoutMetadata() queue.Client {
+	p := New(nil)
+	p.(*pub).log = logger.GetLogger("queue-client")
+	return p
+}
+
 func (*pub) Name() string {
 	return "queue-client"
 }
 
 func (p *pub) PreRun(context.Context) error {
-	p.metadata.RegisterHandler("queue-client", schema.KindNode, p)
+	if p.metadata != nil {
+		p.metadata.RegisterHandler("queue-client", schema.KindNode, p)
+	}
+	p.log = logger.GetLogger("server-queue-pub")
 	return nil
 }
 
diff --git a/banyand/queue/pub/pub_suite_test.go b/banyand/queue/pub/pub_suite_test.go
index 50ccfcc8..8a1001bb 100644
--- a/banyand/queue/pub/pub_suite_test.go
+++ b/banyand/queue/pub/pub_suite_test.go
@@ -215,8 +215,7 @@ func (m *mockHandler) OnDelete(_ schema.Metadata) {
 }
 
 func newPub() *pub {
-	p := New(nil).(*pub)
-	p.log = logger.GetLogger("pub")
+	p := NewWithoutMetadata().(*pub)
 	p.Register(data.TopicStreamWrite, &mockHandler{})
 	p.Register(data.TopicMeasureWrite, &mockHandler{})
 	return p