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/05/16 01:07:27 UTC
(skywalking-banyandb) branch replica-protocol created (now e01e9e1d)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a change to branch replica-protocol
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
at e01e9e1d Replica: Replace Any with []byte Between Liaison and Data Nodes
This branch includes the following new commits:
new e01e9e1d Replica: Replace Any with []byte Between Liaison and Data Nodes
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(skywalking-banyandb) 01/01: Replica: Replace Any with []byte Between Liaison and Data Nodes
Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch replica-protocol
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit e01e9e1dc4bbf81c4756e0d79bf4455b7f10d267
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Fri May 16 00:43:28 2025 +0000
Replica: Replace Any with []byte Between Liaison and Data Nodes
Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
CHANGES.md | 1 +
api/proto/banyandb/cluster/v1/rpc.proto | 5 ++---
banyand/measure/write.go | 8 ++++----
banyand/queue/pub/pub.go | 7 +++----
banyand/queue/pub/pub_suite_test.go | 12 ++++++------
banyand/queue/pub/pub_tls_test.go | 28 ++++------------------------
banyand/queue/sub/sub.go | 7 +++----
banyand/stream/write.go | 8 ++++----
docs/api-reference.md | 4 ++--
9 files changed, 29 insertions(+), 51 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 895dff29..89edece2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -51,6 +51,7 @@ Release Notes.
- Add time range return value from stream local index filter.
- Deduplicate the documents on building the series index.
- Implement multiple groups query in one request.
+- Replica: Replace Any with []byte Between Liaison and Data Nodes
### Bug Fixes
diff --git a/api/proto/banyandb/cluster/v1/rpc.proto b/api/proto/banyandb/cluster/v1/rpc.proto
index 261fae89..1d922f8c 100644
--- a/api/proto/banyandb/cluster/v1/rpc.proto
+++ b/api/proto/banyandb/cluster/v1/rpc.proto
@@ -20,21 +20,20 @@ syntax = "proto3";
package banyandb.cluster.v1;
import "banyandb/model/v1/write.proto";
-import "google/protobuf/any.proto";
option go_package = "github.com/apache/skywalking-banyandb/api/proto/banyandb/cluster/v1";
message SendRequest {
string topic = 1;
uint64 message_id = 2;
- google.protobuf.Any body = 3;
+ bytes body = 3;
bool batch_mod = 4;
}
message SendResponse {
uint64 message_id = 1;
string error = 2;
- google.protobuf.Any body = 3;
+ bytes body = 3;
model.v1.Status status = 4;
}
diff --git a/banyand/measure/write.go b/banyand/measure/write.go
index 5261f810..e567132c 100644
--- a/banyand/measure/write.go
+++ b/banyand/measure/write.go
@@ -23,7 +23,7 @@ import (
"fmt"
"time"
- "google.golang.org/protobuf/types/known/anypb"
+ "google.golang.org/protobuf/proto"
"github.com/apache/skywalking-banyandb/api/common"
databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
@@ -425,10 +425,10 @@ func (w *writeCallback) Rev(_ context.Context, message bus.Message) (resp bus.Me
switch e := events[i].(type) {
case *measurev1.InternalWriteRequest:
writeEvent = e
- case *anypb.Any:
+ case []byte:
writeEvent = &measurev1.InternalWriteRequest{}
- if err := e.UnmarshalTo(writeEvent); err != nil {
- w.l.Error().Err(err).RawJSON("written", logger.Proto(e)).Msg("fail to unmarshal event")
+ if err := proto.Unmarshal(e, writeEvent); err != nil {
+ w.l.Error().Err(err).RawJSON("written", e).Msg("fail to unmarshal event")
continue
}
default:
diff --git a/banyand/queue/pub/pub.go b/banyand/queue/pub/pub.go
index ae63065d..e4b89744 100644
--- a/banyand/queue/pub/pub.go
+++ b/banyand/queue/pub/pub.go
@@ -31,7 +31,6 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/types/known/anypb"
"github.com/apache/skywalking-banyandb/api/common"
"github.com/apache/skywalking-banyandb/api/data"
@@ -285,11 +284,11 @@ func messageToRequest(topic bus.Topic, m bus.Message) (*clusterv1.SendRequest, e
if !ok {
return nil, fmt.Errorf("invalid message type %T", m.Data())
}
- anyMessage, err := anypb.New(message)
+ data, err := proto.Marshal(message)
if err != nil {
return nil, fmt.Errorf("failed to marshal message %T: %w", m, err)
}
- r.Body = anyMessage
+ r.Body = data
return r, nil
}
@@ -323,7 +322,7 @@ func (l *future) Get() (bus.Message, error) {
}
if messageSupplier, ok := data.TopicResponseMap[t]; ok {
m := messageSupplier()
- err = resp.Body.UnmarshalTo(m)
+ err = proto.Unmarshal(resp.Body, m)
if err != nil {
return bus.Message{}, err
}
diff --git a/banyand/queue/pub/pub_suite_test.go b/banyand/queue/pub/pub_suite_test.go
index e6bb424a..1405bb34 100644
--- a/banyand/queue/pub/pub_suite_test.go
+++ b/banyand/queue/pub/pub_suite_test.go
@@ -33,7 +33,7 @@ import (
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
- "google.golang.org/protobuf/types/known/anypb"
+ "google.golang.org/protobuf/proto"
"github.com/apache/skywalking-banyandb/api/data"
clusterv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/cluster/v1"
@@ -82,14 +82,14 @@ func (s *mockServer) Send(stream clusterv1.Service_SendServer) (err error) {
f := data.TopicResponseMap[topic]
- var body *anypb.Any
+ var body []byte
+ var errMarshal error
if f == nil {
body = first.Body
} else {
- var errAny error
- body, errAny = anypb.New(f())
- if errAny != nil {
- panic(errAny)
+ body, errMarshal = proto.Marshal(f())
+ if errMarshal != nil {
+ panic(errMarshal)
}
}
res := &clusterv1.SendResponse{
diff --git a/banyand/queue/pub/pub_tls_test.go b/banyand/queue/pub/pub_tls_test.go
index 6cc8c9c2..a68c070f 100644
--- a/banyand/queue/pub/pub_tls_test.go
+++ b/banyand/queue/pub/pub_tls_test.go
@@ -21,6 +21,10 @@ package pub
import (
"context"
"crypto/tls"
+ "net"
+ "path/filepath"
+ "testing"
+
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/onsi/gomega/gleak"
@@ -28,11 +32,6 @@ import (
"google.golang.org/grpc/credentials"
health "google.golang.org/grpc/health"
healthv1 "google.golang.org/grpc/health/grpc_health_v1"
- "google.golang.org/protobuf/types/known/anypb"
- "io"
- "net"
- "path/filepath"
- "testing"
"github.com/apache/skywalking-banyandb/api/data"
clusterv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/cluster/v1"
@@ -46,25 +45,6 @@ func TestPubTLS(t *testing.T) {
ginkgo.RunSpecs(t, "queue‑pub TLS dial‑out Suite")
}
-type mockService struct {
- clusterv1.UnimplementedServiceServer
-}
-
-func (m *mockService) Send(stream clusterv1.Service_SendServer) error {
- _, err := stream.Recv()
- if err != nil {
- return err
- }
- anyBody, err := anypb.New(&streamv1.QueryResponse{})
- if err != nil {
- return err
- }
- if err := stream.Send(&clusterv1.SendResponse{Body: anyBody}); err != nil {
- return err
- }
- return io.EOF
-}
-
func tlsServer(addr string) func() {
crtDir := filepath.Join("testdata", "certs")
cert, err := tls.LoadX509KeyPair(
diff --git a/banyand/queue/sub/sub.go b/banyand/queue/sub/sub.go
index 7343b199..cd646883 100644
--- a/banyand/queue/sub/sub.go
+++ b/banyand/queue/sub/sub.go
@@ -25,7 +25,6 @@ import (
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
- "google.golang.org/protobuf/types/known/anypb"
"github.com/apache/skywalking-banyandb/api/common"
"github.com/apache/skywalking-banyandb/api/data"
@@ -76,7 +75,7 @@ func (s *server) Send(stream clusterv1.Service_SendServer) error {
if reqSupplier, ok := data.TopicRequestMap[*topic]; ok {
req := reqSupplier()
- if errUnmarshal := writeEntity.Body.UnmarshalTo(req); errUnmarshal != nil {
+ if errUnmarshal := proto.Unmarshal(writeEntity.Body, req); errUnmarshal != nil {
s.reply(stream, writeEntity, errUnmarshal, "failed to unmarshal message")
continue
}
@@ -129,14 +128,14 @@ func (s *server) Send(stream clusterv1.Service_SendServer) error {
s.reply(stream, writeEntity, nil, fmt.Sprintf("invalid response: %T", d))
continue
}
- anyMessage, err := anypb.New(message)
+ data, err := proto.Marshal(message)
if err != nil {
s.reply(stream, writeEntity, err, "failed to marshal message")
continue
}
if err := stream.Send(&clusterv1.SendResponse{
MessageId: writeEntity.MessageId,
- Body: anyMessage,
+ Body: data,
}); err != nil {
s.log.Error().Stringer("request", writeEntity).Dur("latency", time.Since(start)).Err(err).Msg("failed to send query response")
s.metrics.totalMsgSentErr.Inc(1, writeEntity.Topic)
diff --git a/banyand/stream/write.go b/banyand/stream/write.go
index 52287354..23503cc9 100644
--- a/banyand/stream/write.go
+++ b/banyand/stream/write.go
@@ -23,7 +23,7 @@ import (
"fmt"
"strings"
- "google.golang.org/protobuf/types/known/anypb"
+ "google.golang.org/protobuf/proto"
"github.com/apache/skywalking-banyandb/api/common"
databasev1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
@@ -245,10 +245,10 @@ func (w *writeCallback) Rev(_ context.Context, message bus.Message) (resp bus.Me
switch e := events[i].(type) {
case *streamv1.InternalWriteRequest:
writeEvent = e
- case *anypb.Any:
+ case []byte:
writeEvent = &streamv1.InternalWriteRequest{}
- if err := e.UnmarshalTo(writeEvent); err != nil {
- w.l.Error().Err(err).RawJSON("written", logger.Proto(e)).Msg("fail to unmarshal event")
+ if err := proto.Unmarshal(e, writeEvent); err != nil {
+ w.l.Error().Err(err).RawJSON("written", e).Msg("fail to unmarshal event")
continue
}
default:
diff --git a/docs/api-reference.md b/docs/api-reference.md
index ed3ec970..c755c559 100644
--- a/docs/api-reference.md
+++ b/docs/api-reference.md
@@ -342,7 +342,7 @@ Status is the response status for write
| ----- | ---- | ----- | ----------- |
| topic | [string](#string) | | |
| message_id | [uint64](#uint64) | | |
-| body | [google.protobuf.Any](#google-protobuf-Any) | | |
+| body | [bytes](#bytes) | | |
| batch_mod | [bool](#bool) | | |
@@ -360,7 +360,7 @@ Status is the response status for write
| ----- | ---- | ----- | ----------- |
| message_id | [uint64](#uint64) | | |
| error | [string](#string) | | |
-| body | [google.protobuf.Any](#google-protobuf-Any) | | |
+| body | [bytes](#bytes) | | |
| status | [banyandb.model.v1.Status](#banyandb-model-v1-Status) | | |