- WAL package now can notify observers when it writes entries - WAL can retrieve entries by sequence number - WAL implements file retention management - Add replication protocol defined using protobufs - Implemented compression support for zstd and snappy - State machine for replication added - Batch management for streaming from the WAL
222 lines
9.9 KiB
Go
222 lines
9.9 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.5.1
|
|
// - protoc v3.20.3
|
|
// source: kevo/replication.proto
|
|
|
|
package replication_proto
|
|
|
|
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 (
|
|
WALReplicationService_StreamWAL_FullMethodName = "/kevo.replication.WALReplicationService/StreamWAL"
|
|
WALReplicationService_Acknowledge_FullMethodName = "/kevo.replication.WALReplicationService/Acknowledge"
|
|
WALReplicationService_NegativeAcknowledge_FullMethodName = "/kevo.replication.WALReplicationService/NegativeAcknowledge"
|
|
)
|
|
|
|
// WALReplicationServiceClient is the client API for WALReplicationService 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.
|
|
//
|
|
// WALReplicationService defines the gRPC service for Kevo's primary-replica replication protocol.
|
|
// It enables replicas to stream WAL entries from a primary node in real-time, maintaining
|
|
// a consistent, crash-resilient, and ordered copy of the data.
|
|
type WALReplicationServiceClient interface {
|
|
// StreamWAL allows replicas to request WAL entries starting from a specific sequence number.
|
|
// The primary responds with a stream of WAL entries in strict logical order.
|
|
StreamWAL(ctx context.Context, in *WALStreamRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WALStreamResponse], error)
|
|
// Acknowledge allows replicas to inform the primary about entries that have been
|
|
// successfully applied and persisted, enabling the primary to manage WAL retention.
|
|
Acknowledge(ctx context.Context, in *Ack, opts ...grpc.CallOption) (*AckResponse, error)
|
|
// NegativeAcknowledge allows replicas to request retransmission
|
|
// of entries when a gap is detected in the sequence numbers.
|
|
NegativeAcknowledge(ctx context.Context, in *Nack, opts ...grpc.CallOption) (*NackResponse, error)
|
|
}
|
|
|
|
type wALReplicationServiceClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewWALReplicationServiceClient(cc grpc.ClientConnInterface) WALReplicationServiceClient {
|
|
return &wALReplicationServiceClient{cc}
|
|
}
|
|
|
|
func (c *wALReplicationServiceClient) StreamWAL(ctx context.Context, in *WALStreamRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[WALStreamResponse], error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
stream, err := c.cc.NewStream(ctx, &WALReplicationService_ServiceDesc.Streams[0], WALReplicationService_StreamWAL_FullMethodName, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
x := &grpc.GenericClientStream[WALStreamRequest, WALStreamResponse]{ClientStream: stream}
|
|
if err := x.ClientStream.SendMsg(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := x.ClientStream.CloseSend(); err != nil {
|
|
return nil, err
|
|
}
|
|
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 WALReplicationService_StreamWALClient = grpc.ServerStreamingClient[WALStreamResponse]
|
|
|
|
func (c *wALReplicationServiceClient) Acknowledge(ctx context.Context, in *Ack, opts ...grpc.CallOption) (*AckResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(AckResponse)
|
|
err := c.cc.Invoke(ctx, WALReplicationService_Acknowledge_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *wALReplicationServiceClient) NegativeAcknowledge(ctx context.Context, in *Nack, opts ...grpc.CallOption) (*NackResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(NackResponse)
|
|
err := c.cc.Invoke(ctx, WALReplicationService_NegativeAcknowledge_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// WALReplicationServiceServer is the server API for WALReplicationService service.
|
|
// All implementations must embed UnimplementedWALReplicationServiceServer
|
|
// for forward compatibility.
|
|
//
|
|
// WALReplicationService defines the gRPC service for Kevo's primary-replica replication protocol.
|
|
// It enables replicas to stream WAL entries from a primary node in real-time, maintaining
|
|
// a consistent, crash-resilient, and ordered copy of the data.
|
|
type WALReplicationServiceServer interface {
|
|
// StreamWAL allows replicas to request WAL entries starting from a specific sequence number.
|
|
// The primary responds with a stream of WAL entries in strict logical order.
|
|
StreamWAL(*WALStreamRequest, grpc.ServerStreamingServer[WALStreamResponse]) error
|
|
// Acknowledge allows replicas to inform the primary about entries that have been
|
|
// successfully applied and persisted, enabling the primary to manage WAL retention.
|
|
Acknowledge(context.Context, *Ack) (*AckResponse, error)
|
|
// NegativeAcknowledge allows replicas to request retransmission
|
|
// of entries when a gap is detected in the sequence numbers.
|
|
NegativeAcknowledge(context.Context, *Nack) (*NackResponse, error)
|
|
mustEmbedUnimplementedWALReplicationServiceServer()
|
|
}
|
|
|
|
// UnimplementedWALReplicationServiceServer 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 UnimplementedWALReplicationServiceServer struct{}
|
|
|
|
func (UnimplementedWALReplicationServiceServer) StreamWAL(*WALStreamRequest, grpc.ServerStreamingServer[WALStreamResponse]) error {
|
|
return status.Errorf(codes.Unimplemented, "method StreamWAL not implemented")
|
|
}
|
|
func (UnimplementedWALReplicationServiceServer) Acknowledge(context.Context, *Ack) (*AckResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method Acknowledge not implemented")
|
|
}
|
|
func (UnimplementedWALReplicationServiceServer) NegativeAcknowledge(context.Context, *Nack) (*NackResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method NegativeAcknowledge not implemented")
|
|
}
|
|
func (UnimplementedWALReplicationServiceServer) mustEmbedUnimplementedWALReplicationServiceServer() {}
|
|
func (UnimplementedWALReplicationServiceServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafeWALReplicationServiceServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to WALReplicationServiceServer will
|
|
// result in compilation errors.
|
|
type UnsafeWALReplicationServiceServer interface {
|
|
mustEmbedUnimplementedWALReplicationServiceServer()
|
|
}
|
|
|
|
func RegisterWALReplicationServiceServer(s grpc.ServiceRegistrar, srv WALReplicationServiceServer) {
|
|
// If the following call pancis, it indicates UnimplementedWALReplicationServiceServer 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(&WALReplicationService_ServiceDesc, srv)
|
|
}
|
|
|
|
func _WALReplicationService_StreamWAL_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
m := new(WALStreamRequest)
|
|
if err := stream.RecvMsg(m); err != nil {
|
|
return err
|
|
}
|
|
return srv.(WALReplicationServiceServer).StreamWAL(m, &grpc.GenericServerStream[WALStreamRequest, WALStreamResponse]{ServerStream: stream})
|
|
}
|
|
|
|
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
|
type WALReplicationService_StreamWALServer = grpc.ServerStreamingServer[WALStreamResponse]
|
|
|
|
func _WALReplicationService_Acknowledge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(Ack)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(WALReplicationServiceServer).Acknowledge(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: WALReplicationService_Acknowledge_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(WALReplicationServiceServer).Acknowledge(ctx, req.(*Ack))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _WALReplicationService_NegativeAcknowledge_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(Nack)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(WALReplicationServiceServer).NegativeAcknowledge(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: WALReplicationService_NegativeAcknowledge_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(WALReplicationServiceServer).NegativeAcknowledge(ctx, req.(*Nack))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
// WALReplicationService_ServiceDesc is the grpc.ServiceDesc for WALReplicationService service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var WALReplicationService_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "kevo.replication.WALReplicationService",
|
|
HandlerType: (*WALReplicationServiceServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "Acknowledge",
|
|
Handler: _WALReplicationService_Acknowledge_Handler,
|
|
},
|
|
{
|
|
MethodName: "NegativeAcknowledge",
|
|
Handler: _WALReplicationService_NegativeAcknowledge_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{
|
|
{
|
|
StreamName: "StreamWAL",
|
|
Handler: _WALReplicationService_StreamWAL_Handler,
|
|
ServerStreams: true,
|
|
},
|
|
},
|
|
Metadata: "kevo/replication.proto",
|
|
}
|