Skip to content
Snippets Groups Projects
Verified Commit dd6ef2a2 authored by Divya Rani's avatar Divya Rani Committed by GitLab
Browse files

Merge branch 'qmnguyen0711/bundle-raftpb' into 'master'

Embed raftpb to Gitaly for direct use

See merge request !7561



Merged-by: default avatarDivya Rani <drani@gitlab.com>
Approved-by: default avatarDivya Rani <drani@gitlab.com>
Reviewed-by: Quang-Minh Nguyen's avatarQuang-Minh Nguyen <qmnguyen@gitlab.com>
Reviewed-by: James Liu's avatarJames Liu <jliu@gitlab.com>
Reviewed-by: default avatarDivya Rani <drani@gitlab.com>
Co-authored-by: Quang-Minh Nguyen's avatarQuang-Minh Nguyen <qmnguyen@gitlab.com>
parents 2e250e74 d6fb5677
No related branches found
No related tags found
1 merge request!7561Embed raftpb to Gitaly for direct use
Pipeline #1627864605 failed
Showing
with 404 additions and 570 deletions
......@@ -107,6 +107,13 @@ ifeq ($(origin PROTOC_BUILD_OPTIONS),undefined)
PROTOC_BUILD_OPTIONS += -DCMAKE_CXX_STANDARD=14
endif
# This target is a part of the pipeline because some of Gitaly's protobufs consist of etcd's raftpb.
RAFTPB_REPO_URL ?= https://github.com/etcd-io/raft
RAFTPB_SOURCE_DIR ?= ${DEPENDENCY_DIR}/raft
# gogoproto is a dependency of raftpb.
GOGOPROTO_REPO_URL ?= https://github.com/gogo/protobuf
GOGOPROTO_SOURCE_DIR ?= ${DEPENDENCY_DIR}/gogo-protobuf
# Git target
GIT_REPO_URL ?= https://gitlab.com/gitlab-org/git.git
GIT_QUIET :=
......@@ -478,17 +485,31 @@ clean:
.PHONY: proto
## Regenerate protobuf definitions.
proto: SHARED_PROTOC_OPTS = --plugin=${PROTOC_GEN_GO} --plugin=${PROTOC_GEN_GO_GRPC} --plugin=${PROTOC_GEN_GITALY_PROTOLIST} --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative
proto: ${PROTOC} ${PROTOC_GEN_GO} ${PROTOC_GEN_GO_GRPC} ${PROTOC_GEN_GITALY_PROTOLIST}
proto: ${PROTOC} ${PROTOC_GEN_GO} ${PROTOC_GEN_GO_GRPC} ${PROTOC_GEN_GITALY_PROTOLIST} ${DEPENDENCY_DIR}/raftpb
${Q}rm -rf ${PROTO_DEST_DIR} && mkdir -p ${PROTO_DEST_DIR}/gitalypb
${Q}${PROTOC} ${SHARED_PROTOC_OPTS} -I ${SOURCE_DIR}/proto -I ${PROTOC_INSTALL_DIR}/include --go_out=${PROTO_DEST_DIR}/gitalypb --gitaly-protolist_out=proto_dir=${SOURCE_DIR}/proto,gitalypb_dir=${PROTO_DEST_DIR}/gitalypb:${SOURCE_DIR} --go-grpc_out=${PROTO_DEST_DIR}/gitalypb ${SOURCE_DIR}/proto/*.proto ${SOURCE_DIR}/proto/testproto/*.proto
${Q}${PROTOC} \
--plugin=${PROTOC_GEN_GO} \
--plugin=${PROTOC_GEN_GO_GRPC} \
--plugin=${PROTOC_GEN_GITALY_PROTOLIST} \
--go_opt=paths=source_relative \
--go_opt=Mraftpb/raft.proto=go.etcd.io/etcd/raft/v3/raftpb \
--go-grpc_opt=paths=source_relative \
--go-grpc_opt=Mraftpb/raft.proto=go.etcd.io/etcd/raft/v3/raftpb \
--go_out=${PROTO_DEST_DIR}/gitalypb \
--gitaly-protolist_out=proto_dir=${SOURCE_DIR}/proto,gitalypb_dir=${PROTO_DEST_DIR}/gitalypb:${SOURCE_DIR} \
--go-grpc_out=${PROTO_DEST_DIR}/gitalypb \
-I ${SOURCE_DIR}/proto \
-I ${PROTOC_INSTALL_DIR}/include \
-I ${RAFTPB_SOURCE_DIR} \
-I ${GOGOPROTO_SOURCE_DIR} \
${SOURCE_DIR}/proto/*.proto \
${SOURCE_DIR}/proto/testproto/*.proto
.PHONY: check-proto
check-proto: no-proto-changes lint-proto
.PHONY: lint-proto
lint-proto: ${PROTOC} ${PROTOLINT} ${PROTOC_GEN_GITALY_LINT}
${Q}${PROTOC} -I ${SOURCE_DIR}/proto -I ${PROTOC_INSTALL_DIR}/include --plugin=${PROTOC_GEN_GITALY_LINT} --gitaly-lint_out=${SOURCE_DIR} ${SOURCE_DIR}/proto/*.proto
lint-proto: ${PROTOC} ${PROTOLINT} ${PROTOC_GEN_GITALY_LINT} proto
${Q}${PROTOLINT} lint -config_dir_path=${SOURCE_DIR}/proto ${SOURCE_DIR}/proto/*.proto
.PHONY: build-proto-gem
......@@ -648,6 +669,20 @@ ${PROTOC_GEN_GITALY_LINT}: proto | ${TOOLS_DIR}
${PROTOC_GEN_GITALY_PROTOLIST}: | ${TOOLS_DIR}
${Q}go build -o $@ ${SOURCE_DIR}/tools/protoc-gen-gitaly-protolist
${DEPENDENCY_DIR}/gogoproto:
${Q}${GIT} -c init.defaultBranch=master init ${GIT_QUIET} "${GOGOPROTO_SOURCE_DIR}"
${Q}${GIT} -C "${GOGOPROTO_SOURCE_DIR}" config remote.origin.url ${GOGOPROTO_REPO_URL}
${Q}${GIT} -C "${GOGOPROTO_SOURCE_DIR}" config remote.origin.tagOpt --no-tags
${Q}${GIT} -C "${GOGOPROTO_SOURCE_DIR}" fetch --depth 1 ${GIT_QUIET} origin master
${Q}${GIT} -C "${GOGOPROTO_SOURCE_DIR}" checkout ${GIT_QUIET} --detach FETCH_HEAD
${DEPENDENCY_DIR}/raftpb: ${DEPENDENCY_DIR}/gogoproto
${Q}${GIT} -c init.defaultBranch=master init ${GIT_QUIET} "${RAFTPB_SOURCE_DIR}"
${Q}${GIT} -C "${RAFTPB_SOURCE_DIR}" config remote.origin.url ${RAFTPB_REPO_URL}
${Q}${GIT} -C "${RAFTPB_SOURCE_DIR}" config remote.origin.tagOpt --no-tags
${Q}${GIT} -C "${RAFTPB_SOURCE_DIR}" fetch --depth 1 ${GIT_QUIET} origin main
${Q}${GIT} -C "${RAFTPB_SOURCE_DIR}" checkout ${GIT_QUIET} --detach FETCH_HEAD
${GIT_FILTER_REPO}: ${DEPENDENCY_DIR}/git-filter-repo.version | ${BUILD_DIR}/bin
${Q}${GIT} -c init.defaultBranch=master init ${GIT_QUIET} "${GIT_FILTER_REPO_SOURCE_DIR}"
${Q}${GIT} -C "${GIT_FILTER_REPO_SOURCE_DIR}" config remote.origin.url ${GIT_FILTER_REPO_REPO_URL}
......
......@@ -50,7 +50,7 @@ func (t *NoopTransport) Send(ctx context.Context, pathForLSN func(storage.LSN) s
if messages[i].Entries[j].Type != raftpb.EntryNormal {
continue
}
var msg gitalypb.RaftMessageV1
var msg gitalypb.RaftEntry
if err := proto.Unmarshal(messages[i].Entries[j].Data, &msg); err != nil {
return fmt.Errorf("unmarshalling entry type: %w", err)
......@@ -63,10 +63,7 @@ func (t *NoopTransport) Send(ctx context.Context, pathForLSN func(storage.LSN) s
// purpose. A real implementation of Transaction will likely use an optimized method
// (such as sidechannel) to deliver the data. It does not necessarily store the data in
// the memory.
switch msg.GetLogData().(type) {
case *gitalypb.RaftMessageV1_Packed:
continue
case *gitalypb.RaftMessageV1_Referenced:
if len(msg.GetData().GetPacked()) == 0 {
lsn := storage.LSN(messages[i].Entries[j].Index)
path := pathForLSN(lsn)
if err := t.packLogData(ctx, lsn, &msg, path); err != nil {
......@@ -96,7 +93,7 @@ func (t *NoopTransport) Send(ctx context.Context, pathForLSN func(storage.LSN) s
return nil
}
func (t *NoopTransport) packLogData(ctx context.Context, lsn storage.LSN, message *gitalypb.RaftMessageV1, logEntryPath string) error {
func (t *NoopTransport) packLogData(ctx context.Context, lsn storage.LSN, message *gitalypb.RaftEntry, logEntryPath string) error {
var logData bytes.Buffer
if err := archive.WriteTarball(ctx, t.logger.WithFields(log.Fields{
"raft.component": "WAL archiver",
......@@ -105,10 +102,9 @@ func (t *NoopTransport) packLogData(ctx context.Context, lsn storage.LSN, messag
}), &logData, logEntryPath, "."); err != nil {
return fmt.Errorf("archiving WAL log entry")
}
message.LogData = &gitalypb.RaftMessageV1_Packed{
Packed: &gitalypb.RaftMessageV1_PackedLogData{
Data: logData.Bytes(),
},
message.Data = &gitalypb.RaftEntry_LogData{
LocalPath: message.GetData().GetLocalPath(),
Packed: logData.Bytes(),
}
return nil
}
......
......@@ -30,18 +30,18 @@ func TestNoopTransport_Send(t *testing.T) {
tests := []struct {
name string
setupFunc func(tempDir string) ([]*gitalypb.LogEntry, []raftpb.Message, testhelper.DirectoryState)
setupFunc func(tempDir string) ([]raftpb.Message, testhelper.DirectoryState)
}{
{
name: "No messages",
setupFunc: func(tempDir string) ([]*gitalypb.LogEntry, []raftpb.Message, testhelper.DirectoryState) {
return nil, []raftpb.Message{}, nil
setupFunc: func(tempDir string) ([]raftpb.Message, testhelper.DirectoryState) {
return []raftpb.Message{}, nil
},
},
{
name: "Empty Entries",
setupFunc: func(tempDir string) ([]*gitalypb.LogEntry, []raftpb.Message, testhelper.DirectoryState) {
return nil, []raftpb.Message{
setupFunc: func(tempDir string) ([]raftpb.Message, testhelper.DirectoryState) {
return []raftpb.Message{
{
Type: raftpb.MsgApp,
From: 2,
......@@ -54,27 +54,10 @@ func TestNoopTransport_Send(t *testing.T) {
},
{
name: "Messages with already packed data",
setupFunc: func(tempDir string) ([]*gitalypb.LogEntry, []raftpb.Message, testhelper.DirectoryState) {
logEntry := &gitalypb.LogEntry{
RelativePath: "relative-path",
Operations: []*gitalypb.LogEntry_Operation{
{
Operation: &gitalypb.LogEntry_Operation_CreateHardLink_{
CreateHardLink: &gitalypb.LogEntry_Operation_CreateHardLink{
SourcePath: []byte("source"),
DestinationPath: []byte("destination"),
},
},
},
},
}
initialMessage := gitalypb.RaftMessageV1{
Id: 1,
ClusterId: "44c58f50-0a8b-4849-bf8b-d5a56198ea7c",
AuthorityName: "sample-storage",
PartitionId: 1,
LogEntry: logEntry,
LogData: &gitalypb.RaftMessageV1_Packed{Packed: &gitalypb.RaftMessageV1_PackedLogData{Data: []byte("already packed data")}},
setupFunc: func(tempDir string) ([]raftpb.Message, testhelper.DirectoryState) {
initialMessage := gitalypb.RaftEntry{
Id: 1,
Data: &gitalypb.RaftEntry_LogData{Packed: []byte("already packed data")},
}
messages := []raftpb.Message{
{
......@@ -86,12 +69,12 @@ func TestNoopTransport_Send(t *testing.T) {
Entries: []raftpb.Entry{{Index: uint64(1), Type: raftpb.EntryNormal, Data: mustMarshalProto(&initialMessage)}},
},
}
return []*gitalypb.LogEntry{logEntry}, messages, nil
return messages, nil
},
},
{
name: "Messages with referenced data",
setupFunc: func(tempDir string) ([]*gitalypb.LogEntry, []raftpb.Message, testhelper.DirectoryState) {
setupFunc: func(tempDir string) ([]raftpb.Message, testhelper.DirectoryState) {
// Simulate a log entry dir with files
fileContents := testhelper.DirectoryState{
".": {Mode: archive.TarFileMode | archive.ExecuteMode | fs.ModeDir},
......@@ -106,27 +89,9 @@ func TestNoopTransport_Send(t *testing.T) {
}
}
// Construct message with ReferencedLogData
logEntry := &gitalypb.LogEntry{
RelativePath: "relative-path",
Operations: []*gitalypb.LogEntry_Operation{
{
Operation: &gitalypb.LogEntry_Operation_CreateHardLink_{
CreateHardLink: &gitalypb.LogEntry_Operation_CreateHardLink{
SourcePath: []byte("source"),
DestinationPath: []byte("destination"),
},
},
},
},
}
initialMessage := gitalypb.RaftMessageV1{
Id: 1,
ClusterId: "44c58f50-0a8b-4849-bf8b-d5a56198ea7c",
AuthorityName: "sample-storage",
PartitionId: 1,
LogEntry: logEntry,
LogData: &gitalypb.RaftMessageV1_Referenced{Referenced: &gitalypb.RaftMessageV1_ReferencedLogData{}},
initialMessage := gitalypb.RaftEntry{
Id: 1,
Data: &gitalypb.RaftEntry_LogData{LocalPath: []byte(tempDir)},
}
messages := []raftpb.Message{
......@@ -141,7 +106,7 @@ func TestNoopTransport_Send(t *testing.T) {
},
},
}
return []*gitalypb.LogEntry{logEntry}, messages, fileContents
return messages, fileContents
},
},
}
......@@ -154,7 +119,7 @@ func TestNoopTransport_Send(t *testing.T) {
tempDir := testhelper.TempDir(t)
// Execute setup function to prepare messages and any necessary file contents
entries, messages, expectedContents := tc.setupFunc(tempDir)
messages, expectedContents := tc.setupFunc(tempDir)
// Setup logger and transport
logger := testhelper.SharedLogger(t)
......@@ -179,27 +144,17 @@ func TestNoopTransport_Send(t *testing.T) {
if len(messages[i].Entries) == 0 {
require.Empty(t, recordedMessages[i].Entries)
} else {
var resultMessage gitalypb.RaftMessageV1
var resultMessage gitalypb.RaftEntry
require.NoError(t, proto.Unmarshal(recordedMessages[i].Entries[0].Data, &resultMessage))
testhelper.ProtoEqual(t, entries[i], resultMessage.GetLogEntry())
packedData, ok := resultMessage.GetLogData().(*gitalypb.RaftMessageV1_Packed)
require.True(t, ok)
tarballData := packedData.Packed.GetData()
require.True(t, len(resultMessage.GetData().GetPacked()) > 0, "packed data must have packed type")
tarballData := resultMessage.GetData().GetPacked()
require.NotEmpty(t, tarballData)
// Optionally verify packed data if expected
if expectedContents != nil {
var resultMessage gitalypb.RaftMessageV1
require.NoError(t, proto.Unmarshal(recordedMessages[0].Entries[0].Data, &resultMessage))
packedData, ok := resultMessage.GetLogData().(*gitalypb.RaftMessageV1_Packed)
require.True(t, ok, "packed data must have packed type")
// Verify tarball content matches expectations
reader := bytes.NewReader(packedData.Packed.GetData())
reader := bytes.NewReader(tarballData)
testhelper.RequireTarState(t, reader, expectedContents)
}
}
......
syntax = "proto3";
package gitaly;
import "log.proto";
option go_package = "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb";
import "lint.proto";
import "raftpb/raft.proto"; // Upstream go.etcd.io/etcd/raft/v3/raftpb/raft.proto
// RaftMessageType defines the types of messages that can be used within the Raft protocol.
// These types help in identifying the nature of the message being processed.
enum RaftMessageType {
// UNSPECIFIED is used to indicate unspecified message type enum.
UNSPECIFIED = 0; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX
// NORMAL represents a standard Raft log entry proposed by the application.
NORMAL = 1; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX
// VERIFICATION refers to a special type of no-op entries during leader
// confirmation. Raft inserts such entries for verification.
VERIFICATION = 2; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX
// CONFIG_CHANGE signifies a change in the configuration of the Raft cluster,
// typically involving node additions or removals.
CONFIG_CHANGE = 3; // protolint:disable:this ENUM_FIELD_NAMES_PREFIX
}
option go_package = "gitlab.com/gitlab-org/gitaly/v16/proto/go/gitalypb";
// RaftMessageV1 serves as a wrapper for messages exchanged in the Raft protocol,
// encapsulating essential information such as the log entry and related metadata.
message RaftMessageV1 {
// ReferencedLogData holds a reference path to the log data stored externally,
// which can be used to access large log entries without including them directly.
message ReferencedLogData {
// path represents the external storage location of the log data.
bytes path = 1;
}
// PackedLogData contains serialized log data including log entry itself and
// all attached files in the log entry directory. Those data are exchanged at
// the Transport layer before sending after after receiving messages. Hence,
// they are transparent to the core Raft engine.
message PackedLogData {
// data is serialized form of the log entry data. Transport implementations
// can choose to populate this data or read the data directly on disk. The
// latter approach is recommended.
bytes data = 1;
// RaftEntry encapsulates critical data for replication using etcd/raft library.
// It has a request ID allowing the primary to track when the action is
// effectively applied.
message RaftEntry {
// LogData contains serialized log data, including the log entry itself
// and all attached files in the log entry's directory. These data are
// exchanged at the Transport layer before sending and after receiving
// messages. They remain transparent to the core Raft engine.
message LogData {
// local_path is the path to the staging log entry directory. Before the
// request is sent to other nodes, this whole directory of the entry is
// serialized. So, this field is only relevant to the primary node who
// issues the request.
bytes local_path = 1;
// packed is the serialized form of the log entry data. Transport
// implementations populates this field before sending out messages to other
// members of a Raft group.
bytes packed = 2;
}
// id is unique identifier for the Raft message. This ID is generated by an
// in-memory revent registry. Raft uses this ID to notify the committment
// status of a log entry.
// id is the unique identifier for the Raft message. This ID is generated by
// an in-memory event registry. Raft uses this ID to track the commit status
// of a log entry.
uint64 id = 1;
// cluster_id is the identifier of the Raft cluster to which this message belongs.
string cluster_id = 2;
// authority_name is the storage name of storage that creates a partition.
string authority_name = 3;
// data represents packed and serialized log data.
LogData data = 2;
}
// partition_id is the local incremental ID of the specific partition within a
// storage. (authority_name, partition_id) can be used as a unique identifier
// of a partition across the cluster.
uint64 partition_id = 4;
// RaftMessageRequest is a request for the SendMessage RPC. It serves as a
// wrapper for raftpb.Message. etcd/raft's state machines on each member emit
// this message. Since Gitaly employs multi-raft, routing metadata is attached
// to ensure the message reaches the correct Raft group inside the receiving
// Gitaly server.
message RaftMessageRequest {
// cluster_id is the identifier of the Raft cluster to which this message belongs.
string cluster_id = 1;
// log_entry is the actual log entry being processed or transmitted.
LogEntry log_entry = 5;
// authority_name is the storage name of the authority that creates a partition.
string authority_name = 2 [(gitaly.storage) = true];
// log_data holds files inside log entry dir in one of two possible forms:
// referenced or packed.
oneof log_data {
// referenced represents reference to on-disk log data.
ReferencedLogData referenced = 6;
// partition_id is the local incrementing ID of a specific partition within a
// storage. Together with `authority_name`, this forms a unique identifier for
// a partition across the cluster. A partition belongs to a Raft group.
uint64 partition_id = 3;
// packed represents packed and serialized log data.
PackedLogData packed = 7;
}
// message is the Raft message to be delivered.
raftpb.Message message = 4;
}
// RaftHardStateV1 is a wrapper for raftpb.HardState. The upstream uses proto2
// syntax while Gitaly uses proto3. In addition, the protobuf package in
// upstream is outdated. The generated structs are not compatible with Gitaly's
// protobuf utilities.
// Source:
// https://github.com/etcd-io/raft/blob/12f0e5dc1b5bfff9bc6886ef1be4cba19495d6f2/raftpb/raft.proto#L110-114
message RaftHardStateV1 {
// term represents the current term of the raft group.
uint64 term = 1;
// vote represents the vote of the raft group.
uint64 vote = 2;
// commit represents the latest commit index of the raft group.
uint64 commit = 3;
// RaftMessageResponse represents a response to the SendMessage RPC.
message RaftMessageResponse {
}
// RaftConfStateV1 is a wrapper for raftpb.ConfState. For more information,
// please refer to RaftHardStateV1. Source:
// https://github.com/etcd-io/raft/blob/12f0e5dc1b5bfff9bc6886ef1be4cba19495d6f2/raftpb/raft.proto#L136
message RaftConfStateV1 {
// voters in the incoming config. (If the configuration is not joint,
// then the outgoing config is empty).
repeated uint64 voters = 1;
// learners in the incoming config.
repeated uint64 learners = 2;
// voters_outgoing in the outgoing config.
repeated uint64 voters_outgoing = 3; // protolint:disable:this REPEATED_FIELD_NAMES_PLURALIZED
// learners_next is the nodes that will become learners when the outgoing
// config is removed. These nodes are necessarily currently in nodes_joint (or
// they would have been added to the incoming config right away).
repeated uint64 learners_next = 4; // protolint:disable:this REPEATED_FIELD_NAMES_PLURALIZED
// auto_leave is set when the config is joint and Raft will automatically
// transition into the final config (i.e. remove the outgoing config) when
// this is safe.
bool auto_leave = 5;
// RaftService manages the sending of Raft messages to peers.
service RaftService {
// SendMessage processes Raft messages and ensures they are handled by
// the receiving node to update its Raft state machine.
rpc SendMessage(stream RaftMessageRequest) returns (RaftMessageResponse) {
option (op_type) = {
op: MUTATOR
scope_level: STORAGE
};
}
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: analysis.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: blob.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: cleanup.proto
......
This diff is collapsed.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v4.23.1
// source: cluster.proto
package gitalypb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
RaftService_SendMessage_FullMethodName = "/gitaly.RaftService/SendMessage"
)
// RaftServiceClient is the client API for RaftService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// RaftService manages the sending of Raft messages to peers.
type RaftServiceClient interface {
// SendMessage processes Raft messages and ensures they are handled by
// the receiving node to update its Raft state machine.
SendMessage(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[RaftMessageRequest, RaftMessageResponse], error)
}
type raftServiceClient struct {
cc grpc.ClientConnInterface
}
func NewRaftServiceClient(cc grpc.ClientConnInterface) RaftServiceClient {
return &raftServiceClient{cc}
}
func (c *raftServiceClient) SendMessage(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[RaftMessageRequest, RaftMessageResponse], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &RaftService_ServiceDesc.Streams[0], RaftService_SendMessage_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &grpc.GenericClientStream[RaftMessageRequest, RaftMessageResponse]{ClientStream: stream}
return x, nil
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type RaftService_SendMessageClient = grpc.ClientStreamingClient[RaftMessageRequest, RaftMessageResponse]
// RaftServiceServer is the server API for RaftService service.
// All implementations must embed UnimplementedRaftServiceServer
// for forward compatibility.
//
// RaftService manages the sending of Raft messages to peers.
type RaftServiceServer interface {
// SendMessage processes Raft messages and ensures they are handled by
// the receiving node to update its Raft state machine.
SendMessage(grpc.ClientStreamingServer[RaftMessageRequest, RaftMessageResponse]) error
mustEmbedUnimplementedRaftServiceServer()
}
// UnimplementedRaftServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedRaftServiceServer struct{}
func (UnimplementedRaftServiceServer) SendMessage(grpc.ClientStreamingServer[RaftMessageRequest, RaftMessageResponse]) error {
return status.Errorf(codes.Unimplemented, "method SendMessage not implemented")
}
func (UnimplementedRaftServiceServer) mustEmbedUnimplementedRaftServiceServer() {}
func (UnimplementedRaftServiceServer) testEmbeddedByValue() {}
// UnsafeRaftServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to RaftServiceServer will
// result in compilation errors.
type UnsafeRaftServiceServer interface {
mustEmbedUnimplementedRaftServiceServer()
}
func RegisterRaftServiceServer(s grpc.ServiceRegistrar, srv RaftServiceServer) {
// If the following call pancis, it indicates UnimplementedRaftServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&RaftService_ServiceDesc, srv)
}
func _RaftService_SendMessage_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(RaftServiceServer).SendMessage(&grpc.GenericServerStream[RaftMessageRequest, RaftMessageResponse]{ServerStream: stream})
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type RaftService_SendMessageServer = grpc.ClientStreamingServer[RaftMessageRequest, RaftMessageResponse]
// RaftService_ServiceDesc is the grpc.ServiceDesc for RaftService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RaftService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "gitaly.RaftService",
HandlerType: (*RaftServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "SendMessage",
Handler: _RaftService_SendMessage_Handler,
ClientStreams: true,
},
},
Metadata: "cluster.proto",
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: commit.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: conflicts.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: diff.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: errors.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: hook.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: internal.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: lint.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: log.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: objectpool.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: operations.proto
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.0
// protoc-gen-go v1.36.2
// protoc v4.23.1
// source: packfile.proto
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment