// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc             v6.30.2
// source: smarthttp.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 (
	SmartHTTPService_InfoRefsUploadPack_FullMethodName            = "/gitaly.SmartHTTPService/InfoRefsUploadPack"
	SmartHTTPService_InfoRefsReceivePack_FullMethodName           = "/gitaly.SmartHTTPService/InfoRefsReceivePack"
	SmartHTTPService_PostUploadPackWithSidechannel_FullMethodName = "/gitaly.SmartHTTPService/PostUploadPackWithSidechannel"
	SmartHTTPService_PostReceivePack_FullMethodName               = "/gitaly.SmartHTTPService/PostReceivePack"
)

// SmartHTTPServiceClient is the client API for SmartHTTPService 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.
//
// SmartHTTPService is a service that provides RPCs required for HTTP-based Git
// clones via the smart HTTP protocol.
type SmartHTTPServiceClient interface {
	// InfoRefsUploadPack provides the response for GET /info/refs?service=git-upload-pack.
	// It is invoked when the client fetches packs from the server, meaning the server will
	// upload the packs to that client. The client doesn't upload new objects. This is used
	// to advertise the references available on the server to the client via
	// git-upload-pack(1)'s `--advertise-refs` option.
	InfoRefsUploadPack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[InfoRefsResponse], error)
	// InfoRefsReceivePack provides the response for GET /info/refs?service=git-receive-pack.
	// It is invoked when the client pushes packs to the server, meaning the server
	// will fetch the packs from the client. This is used to advertise the references
	// available on the server to the client via git-receive-pack(1)'s `--advertise-refs`
	// option.
	InfoRefsReceivePack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[InfoRefsResponse], error)
	// PostUploadPackWithSidechannel provides the response for POST /upload-pack. It
	// used to transfer pack files from the server to the client via sidechannels. This
	// is invoked when the client executes `git fetch`.
	//
	// More info on sidechannels: https://gitlab.com/gitlab-org/gitaly/-/blob/master/doc/sidechannel.md
	PostUploadPackWithSidechannel(ctx context.Context, in *PostUploadPackWithSidechannelRequest, opts ...grpc.CallOption) (*PostUploadPackWithSidechannelResponse, error)
	// PostReceivePack provides the response for POST /receive-pack. It used to transfer
	// pack files from the client to the server. This is invoked when the client executes `git push`.
	PostReceivePack(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PostReceivePackRequest, PostReceivePackResponse], error)
}

type smartHTTPServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewSmartHTTPServiceClient(cc grpc.ClientConnInterface) SmartHTTPServiceClient {
	return &smartHTTPServiceClient{cc}
}

func (c *smartHTTPServiceClient) InfoRefsUploadPack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[InfoRefsResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &SmartHTTPService_ServiceDesc.Streams[0], SmartHTTPService_InfoRefsUploadPack_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[InfoRefsRequest, InfoRefsResponse]{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 SmartHTTPService_InfoRefsUploadPackClient = grpc.ServerStreamingClient[InfoRefsResponse]

func (c *smartHTTPServiceClient) InfoRefsReceivePack(ctx context.Context, in *InfoRefsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[InfoRefsResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &SmartHTTPService_ServiceDesc.Streams[1], SmartHTTPService_InfoRefsReceivePack_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[InfoRefsRequest, InfoRefsResponse]{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 SmartHTTPService_InfoRefsReceivePackClient = grpc.ServerStreamingClient[InfoRefsResponse]

func (c *smartHTTPServiceClient) PostUploadPackWithSidechannel(ctx context.Context, in *PostUploadPackWithSidechannelRequest, opts ...grpc.CallOption) (*PostUploadPackWithSidechannelResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(PostUploadPackWithSidechannelResponse)
	err := c.cc.Invoke(ctx, SmartHTTPService_PostUploadPackWithSidechannel_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *smartHTTPServiceClient) PostReceivePack(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PostReceivePackRequest, PostReceivePackResponse], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &SmartHTTPService_ServiceDesc.Streams[2], SmartHTTPService_PostReceivePack_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[PostReceivePackRequest, PostReceivePackResponse]{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 SmartHTTPService_PostReceivePackClient = grpc.BidiStreamingClient[PostReceivePackRequest, PostReceivePackResponse]

// SmartHTTPServiceServer is the server API for SmartHTTPService service.
// All implementations must embed UnimplementedSmartHTTPServiceServer
// for forward compatibility.
//
// SmartHTTPService is a service that provides RPCs required for HTTP-based Git
// clones via the smart HTTP protocol.
type SmartHTTPServiceServer interface {
	// InfoRefsUploadPack provides the response for GET /info/refs?service=git-upload-pack.
	// It is invoked when the client fetches packs from the server, meaning the server will
	// upload the packs to that client. The client doesn't upload new objects. This is used
	// to advertise the references available on the server to the client via
	// git-upload-pack(1)'s `--advertise-refs` option.
	InfoRefsUploadPack(*InfoRefsRequest, grpc.ServerStreamingServer[InfoRefsResponse]) error
	// InfoRefsReceivePack provides the response for GET /info/refs?service=git-receive-pack.
	// It is invoked when the client pushes packs to the server, meaning the server
	// will fetch the packs from the client. This is used to advertise the references
	// available on the server to the client via git-receive-pack(1)'s `--advertise-refs`
	// option.
	InfoRefsReceivePack(*InfoRefsRequest, grpc.ServerStreamingServer[InfoRefsResponse]) error
	// PostUploadPackWithSidechannel provides the response for POST /upload-pack. It
	// used to transfer pack files from the server to the client via sidechannels. This
	// is invoked when the client executes `git fetch`.
	//
	// More info on sidechannels: https://gitlab.com/gitlab-org/gitaly/-/blob/master/doc/sidechannel.md
	PostUploadPackWithSidechannel(context.Context, *PostUploadPackWithSidechannelRequest) (*PostUploadPackWithSidechannelResponse, error)
	// PostReceivePack provides the response for POST /receive-pack. It used to transfer
	// pack files from the client to the server. This is invoked when the client executes `git push`.
	PostReceivePack(grpc.BidiStreamingServer[PostReceivePackRequest, PostReceivePackResponse]) error
	mustEmbedUnimplementedSmartHTTPServiceServer()
}

// UnimplementedSmartHTTPServiceServer 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 UnimplementedSmartHTTPServiceServer struct{}

func (UnimplementedSmartHTTPServiceServer) InfoRefsUploadPack(*InfoRefsRequest, grpc.ServerStreamingServer[InfoRefsResponse]) error {
	return status.Error(codes.Unimplemented, "method InfoRefsUploadPack not implemented")
}
func (UnimplementedSmartHTTPServiceServer) InfoRefsReceivePack(*InfoRefsRequest, grpc.ServerStreamingServer[InfoRefsResponse]) error {
	return status.Error(codes.Unimplemented, "method InfoRefsReceivePack not implemented")
}
func (UnimplementedSmartHTTPServiceServer) PostUploadPackWithSidechannel(context.Context, *PostUploadPackWithSidechannelRequest) (*PostUploadPackWithSidechannelResponse, error) {
	return nil, status.Error(codes.Unimplemented, "method PostUploadPackWithSidechannel not implemented")
}
func (UnimplementedSmartHTTPServiceServer) PostReceivePack(grpc.BidiStreamingServer[PostReceivePackRequest, PostReceivePackResponse]) error {
	return status.Error(codes.Unimplemented, "method PostReceivePack not implemented")
}
func (UnimplementedSmartHTTPServiceServer) mustEmbedUnimplementedSmartHTTPServiceServer() {}
func (UnimplementedSmartHTTPServiceServer) testEmbeddedByValue()                          {}

// UnsafeSmartHTTPServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to SmartHTTPServiceServer will
// result in compilation errors.
type UnsafeSmartHTTPServiceServer interface {
	mustEmbedUnimplementedSmartHTTPServiceServer()
}

func RegisterSmartHTTPServiceServer(s grpc.ServiceRegistrar, srv SmartHTTPServiceServer) {
	// If the following call panics, it indicates UnimplementedSmartHTTPServiceServer 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(&SmartHTTPService_ServiceDesc, srv)
}

func _SmartHTTPService_InfoRefsUploadPack_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(InfoRefsRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(SmartHTTPServiceServer).InfoRefsUploadPack(m, &grpc.GenericServerStream[InfoRefsRequest, InfoRefsResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type SmartHTTPService_InfoRefsUploadPackServer = grpc.ServerStreamingServer[InfoRefsResponse]

func _SmartHTTPService_InfoRefsReceivePack_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(InfoRefsRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(SmartHTTPServiceServer).InfoRefsReceivePack(m, &grpc.GenericServerStream[InfoRefsRequest, InfoRefsResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type SmartHTTPService_InfoRefsReceivePackServer = grpc.ServerStreamingServer[InfoRefsResponse]

func _SmartHTTPService_PostUploadPackWithSidechannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(PostUploadPackWithSidechannelRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(SmartHTTPServiceServer).PostUploadPackWithSidechannel(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: SmartHTTPService_PostUploadPackWithSidechannel_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(SmartHTTPServiceServer).PostUploadPackWithSidechannel(ctx, req.(*PostUploadPackWithSidechannelRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _SmartHTTPService_PostReceivePack_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(SmartHTTPServiceServer).PostReceivePack(&grpc.GenericServerStream[PostReceivePackRequest, PostReceivePackResponse]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type SmartHTTPService_PostReceivePackServer = grpc.BidiStreamingServer[PostReceivePackRequest, PostReceivePackResponse]

// SmartHTTPService_ServiceDesc is the grpc.ServiceDesc for SmartHTTPService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var SmartHTTPService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "gitaly.SmartHTTPService",
	HandlerType: (*SmartHTTPServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "PostUploadPackWithSidechannel",
			Handler:    _SmartHTTPService_PostUploadPackWithSidechannel_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "InfoRefsUploadPack",
			Handler:       _SmartHTTPService_InfoRefsUploadPack_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "InfoRefsReceivePack",
			Handler:       _SmartHTTPService_InfoRefsReceivePack_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "PostReceivePack",
			Handler:       _SmartHTTPService_PostReceivePack_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "smarthttp.proto",
}
