Introduces core functionality for the Agate library, including snapshot creation, restoration, listing, and deletion. Adds examples for basic usage, gRPC proto definitions, and build/configuration files such as `go.mod` and `Makefile`. The implementation establishes the framework for store integration and placeholder server functionality.
212 lines
9.2 KiB
Go
212 lines
9.2 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||
// versions:
|
||
// - protoc-gen-go-grpc v1.5.1
|
||
// - protoc v4.25.3
|
||
// source: snapshot.proto
|
||
|
||
package grpc
|
||
|
||
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 (
|
||
SnapshotService_ListSnapshots_FullMethodName = "/agate.grpc.SnapshotService/ListSnapshots"
|
||
SnapshotService_GetSnapshotDetails_FullMethodName = "/agate.grpc.SnapshotService/GetSnapshotDetails"
|
||
SnapshotService_DownloadFile_FullMethodName = "/agate.grpc.SnapshotService/DownloadFile"
|
||
)
|
||
|
||
// SnapshotServiceClient is the client API for SnapshotService 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.
|
||
//
|
||
// Сервис для управления снапшотами
|
||
type SnapshotServiceClient interface {
|
||
// Получить список доступных снапшотов (краткая информация)
|
||
ListSnapshots(ctx context.Context, in *ListSnapshotsRequest, opts ...grpc.CallOption) (*ListSnapshotsResponse, error)
|
||
// Получить детальную информацию о снапшоте, включая список файлов с хешами
|
||
GetSnapshotDetails(ctx context.Context, in *GetSnapshotDetailsRequest, opts ...grpc.CallOption) (*SnapshotDetails, error)
|
||
// Скачать конкретный файл из снапшота (потоковая передача)
|
||
DownloadFile(ctx context.Context, in *DownloadFileRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[DownloadFileResponse], error)
|
||
}
|
||
|
||
type snapshotServiceClient struct {
|
||
cc grpc.ClientConnInterface
|
||
}
|
||
|
||
func NewSnapshotServiceClient(cc grpc.ClientConnInterface) SnapshotServiceClient {
|
||
return &snapshotServiceClient{cc}
|
||
}
|
||
|
||
func (c *snapshotServiceClient) ListSnapshots(ctx context.Context, in *ListSnapshotsRequest, opts ...grpc.CallOption) (*ListSnapshotsResponse, error) {
|
||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||
out := new(ListSnapshotsResponse)
|
||
err := c.cc.Invoke(ctx, SnapshotService_ListSnapshots_FullMethodName, in, out, cOpts...)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
return out, nil
|
||
}
|
||
|
||
func (c *snapshotServiceClient) GetSnapshotDetails(ctx context.Context, in *GetSnapshotDetailsRequest, opts ...grpc.CallOption) (*SnapshotDetails, error) {
|
||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||
out := new(SnapshotDetails)
|
||
err := c.cc.Invoke(ctx, SnapshotService_GetSnapshotDetails_FullMethodName, in, out, cOpts...)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
return out, nil
|
||
}
|
||
|
||
func (c *snapshotServiceClient) DownloadFile(ctx context.Context, in *DownloadFileRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[DownloadFileResponse], error) {
|
||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||
stream, err := c.cc.NewStream(ctx, &SnapshotService_ServiceDesc.Streams[0], SnapshotService_DownloadFile_FullMethodName, cOpts...)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
x := &grpc.GenericClientStream[DownloadFileRequest, DownloadFileResponse]{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 SnapshotService_DownloadFileClient = grpc.ServerStreamingClient[DownloadFileResponse]
|
||
|
||
// SnapshotServiceServer is the server API for SnapshotService service.
|
||
// All implementations must embed UnimplementedSnapshotServiceServer
|
||
// for forward compatibility.
|
||
//
|
||
// Сервис для управления снапшотами
|
||
type SnapshotServiceServer interface {
|
||
// Получить список доступных снапшотов (краткая информация)
|
||
ListSnapshots(context.Context, *ListSnapshotsRequest) (*ListSnapshotsResponse, error)
|
||
// Получить детальную информацию о снапшоте, включая список файлов с хешами
|
||
GetSnapshotDetails(context.Context, *GetSnapshotDetailsRequest) (*SnapshotDetails, error)
|
||
// Скачать конкретный файл из снапшота (потоковая передача)
|
||
DownloadFile(*DownloadFileRequest, grpc.ServerStreamingServer[DownloadFileResponse]) error
|
||
mustEmbedUnimplementedSnapshotServiceServer()
|
||
}
|
||
|
||
// UnimplementedSnapshotServiceServer 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 UnimplementedSnapshotServiceServer struct{}
|
||
|
||
func (UnimplementedSnapshotServiceServer) ListSnapshots(context.Context, *ListSnapshotsRequest) (*ListSnapshotsResponse, error) {
|
||
return nil, status.Errorf(codes.Unimplemented, "method ListSnapshots not implemented")
|
||
}
|
||
func (UnimplementedSnapshotServiceServer) GetSnapshotDetails(context.Context, *GetSnapshotDetailsRequest) (*SnapshotDetails, error) {
|
||
return nil, status.Errorf(codes.Unimplemented, "method GetSnapshotDetails not implemented")
|
||
}
|
||
func (UnimplementedSnapshotServiceServer) DownloadFile(*DownloadFileRequest, grpc.ServerStreamingServer[DownloadFileResponse]) error {
|
||
return status.Errorf(codes.Unimplemented, "method DownloadFile not implemented")
|
||
}
|
||
func (UnimplementedSnapshotServiceServer) mustEmbedUnimplementedSnapshotServiceServer() {}
|
||
func (UnimplementedSnapshotServiceServer) testEmbeddedByValue() {}
|
||
|
||
// UnsafeSnapshotServiceServer may be embedded to opt out of forward compatibility for this service.
|
||
// Use of this interface is not recommended, as added methods to SnapshotServiceServer will
|
||
// result in compilation errors.
|
||
type UnsafeSnapshotServiceServer interface {
|
||
mustEmbedUnimplementedSnapshotServiceServer()
|
||
}
|
||
|
||
func RegisterSnapshotServiceServer(s grpc.ServiceRegistrar, srv SnapshotServiceServer) {
|
||
// If the following call pancis, it indicates UnimplementedSnapshotServiceServer 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(&SnapshotService_ServiceDesc, srv)
|
||
}
|
||
|
||
func _SnapshotService_ListSnapshots_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||
in := new(ListSnapshotsRequest)
|
||
if err := dec(in); err != nil {
|
||
return nil, err
|
||
}
|
||
if interceptor == nil {
|
||
return srv.(SnapshotServiceServer).ListSnapshots(ctx, in)
|
||
}
|
||
info := &grpc.UnaryServerInfo{
|
||
Server: srv,
|
||
FullMethod: SnapshotService_ListSnapshots_FullMethodName,
|
||
}
|
||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||
return srv.(SnapshotServiceServer).ListSnapshots(ctx, req.(*ListSnapshotsRequest))
|
||
}
|
||
return interceptor(ctx, in, info, handler)
|
||
}
|
||
|
||
func _SnapshotService_GetSnapshotDetails_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||
in := new(GetSnapshotDetailsRequest)
|
||
if err := dec(in); err != nil {
|
||
return nil, err
|
||
}
|
||
if interceptor == nil {
|
||
return srv.(SnapshotServiceServer).GetSnapshotDetails(ctx, in)
|
||
}
|
||
info := &grpc.UnaryServerInfo{
|
||
Server: srv,
|
||
FullMethod: SnapshotService_GetSnapshotDetails_FullMethodName,
|
||
}
|
||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||
return srv.(SnapshotServiceServer).GetSnapshotDetails(ctx, req.(*GetSnapshotDetailsRequest))
|
||
}
|
||
return interceptor(ctx, in, info, handler)
|
||
}
|
||
|
||
func _SnapshotService_DownloadFile_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||
m := new(DownloadFileRequest)
|
||
if err := stream.RecvMsg(m); err != nil {
|
||
return err
|
||
}
|
||
return srv.(SnapshotServiceServer).DownloadFile(m, &grpc.GenericServerStream[DownloadFileRequest, DownloadFileResponse]{ServerStream: stream})
|
||
}
|
||
|
||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||
type SnapshotService_DownloadFileServer = grpc.ServerStreamingServer[DownloadFileResponse]
|
||
|
||
// SnapshotService_ServiceDesc is the grpc.ServiceDesc for SnapshotService service.
|
||
// It's only intended for direct use with grpc.RegisterService,
|
||
// and not to be introspected or modified (even as a copy)
|
||
var SnapshotService_ServiceDesc = grpc.ServiceDesc{
|
||
ServiceName: "agate.grpc.SnapshotService",
|
||
HandlerType: (*SnapshotServiceServer)(nil),
|
||
Methods: []grpc.MethodDesc{
|
||
{
|
||
MethodName: "ListSnapshots",
|
||
Handler: _SnapshotService_ListSnapshots_Handler,
|
||
},
|
||
{
|
||
MethodName: "GetSnapshotDetails",
|
||
Handler: _SnapshotService_GetSnapshotDetails_Handler,
|
||
},
|
||
},
|
||
Streams: []grpc.StreamDesc{
|
||
{
|
||
StreamName: "DownloadFile",
|
||
Handler: _SnapshotService_DownloadFile_Handler,
|
||
ServerStreams: true,
|
||
},
|
||
},
|
||
Metadata: "snapshot.proto",
|
||
}
|