// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc             v4.23.1
// source: praefect.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.32.0 or later.
const _ = grpc.SupportPackageIsVersion7

const (
	PraefectInfoService_RepositoryReplicas_FullMethodName      = "/gitaly.PraefectInfoService/RepositoryReplicas"
	PraefectInfoService_Dataloss_FullMethodName                = "/gitaly.PraefectInfoService/Dataloss"
	PraefectInfoService_SetAuthoritativeStorage_FullMethodName = "/gitaly.PraefectInfoService/SetAuthoritativeStorage"
	PraefectInfoService_MarkUnverified_FullMethodName          = "/gitaly.PraefectInfoService/MarkUnverified"
	PraefectInfoService_SetReplicationFactor_FullMethodName    = "/gitaly.PraefectInfoService/SetReplicationFactor"
	PraefectInfoService_GetRepositoryMetadata_FullMethodName   = "/gitaly.PraefectInfoService/GetRepositoryMetadata"
)

// PraefectInfoServiceClient is the client API for PraefectInfoService 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 PraefectInfoServiceClient interface {
	// RepositoryReplicas ...
	RepositoryReplicas(ctx context.Context, in *RepositoryReplicasRequest, opts ...grpc.CallOption) (*RepositoryReplicasResponse, error)
	// Dataloss provides information on repositories in Praefect that are in a degraded state and
	// thus susceptible to dataloss. A repository is considered degraded when its replicas are
	// outdated and/or unavailable.
	Dataloss(ctx context.Context, in *DatalossRequest, opts ...grpc.CallOption) (PraefectInfoService_DatalossClient, error)
	// SetAuthoritativeStorage sets the authoritative storage for a repository on a given virtual storage.
	// This causes the current version of the repository on the authoritative storage to be considered the
	// latest and overwrite any other version on the virtual storage.
	SetAuthoritativeStorage(ctx context.Context, in *SetAuthoritativeStorageRequest, opts ...grpc.CallOption) (*SetAuthoritativeStorageResponse, error)
	// MarkUnverified marks replicas as unverified. This will trigger verification as Praefect's metadata
	// verifier prioritizes unverified replicas.
	MarkUnverified(ctx context.Context, in *MarkUnverifiedRequest, opts ...grpc.CallOption) (*MarkUnverifiedResponse, error)
	// SetReplicationFactor assigns or unassigns host nodes from the repository to meet the desired replication factor.
	// SetReplicationFactor returns an error when trying to set a replication factor that exceeds the storage node count
	// in the virtual storage. An error is also returned when trying to set a replication factor below one. The primary node
	// won't be unassigned as it needs a copy of the repository to accept writes. Likewise, the primary is the first storage
	// that gets assigned when setting a replication factor for a repository. Assignments of unconfigured storages are ignored.
	// This might cause the actual replication factor to be higher than desired if the replication factor is set during an upgrade
	// from a Praefect node that does not yet know about a new node. As assignments of unconfigured storages are ignored, replication
	// factor of repositories assigned to a storage node removed from the cluster is effectively decreased.
	SetReplicationFactor(ctx context.Context, in *SetReplicationFactorRequest, opts ...grpc.CallOption) (*SetReplicationFactorResponse, error)
	// GetRepositoryMetadata returns the cluster metadata for a repository. Returns NotFound if the repository does not exist.
	GetRepositoryMetadata(ctx context.Context, in *GetRepositoryMetadataRequest, opts ...grpc.CallOption) (*GetRepositoryMetadataResponse, error)
}

type praefectInfoServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewPraefectInfoServiceClient(cc grpc.ClientConnInterface) PraefectInfoServiceClient {
	return &praefectInfoServiceClient{cc}
}

func (c *praefectInfoServiceClient) RepositoryReplicas(ctx context.Context, in *RepositoryReplicasRequest, opts ...grpc.CallOption) (*RepositoryReplicasResponse, error) {
	out := new(RepositoryReplicasResponse)
	err := c.cc.Invoke(ctx, PraefectInfoService_RepositoryReplicas_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *praefectInfoServiceClient) Dataloss(ctx context.Context, in *DatalossRequest, opts ...grpc.CallOption) (PraefectInfoService_DatalossClient, error) {
	stream, err := c.cc.NewStream(ctx, &PraefectInfoService_ServiceDesc.Streams[0], PraefectInfoService_Dataloss_FullMethodName, opts...)
	if err != nil {
		return nil, err
	}
	x := &praefectInfoServiceDatalossClient{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
}

type PraefectInfoService_DatalossClient interface {
	Recv() (*DatalossResponse, error)
	grpc.ClientStream
}

type praefectInfoServiceDatalossClient struct {
	grpc.ClientStream
}

func (x *praefectInfoServiceDatalossClient) Recv() (*DatalossResponse, error) {
	m := new(DatalossResponse)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *praefectInfoServiceClient) SetAuthoritativeStorage(ctx context.Context, in *SetAuthoritativeStorageRequest, opts ...grpc.CallOption) (*SetAuthoritativeStorageResponse, error) {
	out := new(SetAuthoritativeStorageResponse)
	err := c.cc.Invoke(ctx, PraefectInfoService_SetAuthoritativeStorage_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *praefectInfoServiceClient) MarkUnverified(ctx context.Context, in *MarkUnverifiedRequest, opts ...grpc.CallOption) (*MarkUnverifiedResponse, error) {
	out := new(MarkUnverifiedResponse)
	err := c.cc.Invoke(ctx, PraefectInfoService_MarkUnverified_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *praefectInfoServiceClient) SetReplicationFactor(ctx context.Context, in *SetReplicationFactorRequest, opts ...grpc.CallOption) (*SetReplicationFactorResponse, error) {
	out := new(SetReplicationFactorResponse)
	err := c.cc.Invoke(ctx, PraefectInfoService_SetReplicationFactor_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *praefectInfoServiceClient) GetRepositoryMetadata(ctx context.Context, in *GetRepositoryMetadataRequest, opts ...grpc.CallOption) (*GetRepositoryMetadataResponse, error) {
	out := new(GetRepositoryMetadataResponse)
	err := c.cc.Invoke(ctx, PraefectInfoService_GetRepositoryMetadata_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// PraefectInfoServiceServer is the server API for PraefectInfoService service.
// All implementations must embed UnimplementedPraefectInfoServiceServer
// for forward compatibility
type PraefectInfoServiceServer interface {
	// RepositoryReplicas ...
	RepositoryReplicas(context.Context, *RepositoryReplicasRequest) (*RepositoryReplicasResponse, error)
	// Dataloss provides information on repositories in Praefect that are in a degraded state and
	// thus susceptible to dataloss. A repository is considered degraded when its replicas are
	// outdated and/or unavailable.
	Dataloss(*DatalossRequest, PraefectInfoService_DatalossServer) error
	// SetAuthoritativeStorage sets the authoritative storage for a repository on a given virtual storage.
	// This causes the current version of the repository on the authoritative storage to be considered the
	// latest and overwrite any other version on the virtual storage.
	SetAuthoritativeStorage(context.Context, *SetAuthoritativeStorageRequest) (*SetAuthoritativeStorageResponse, error)
	// MarkUnverified marks replicas as unverified. This will trigger verification as Praefect's metadata
	// verifier prioritizes unverified replicas.
	MarkUnverified(context.Context, *MarkUnverifiedRequest) (*MarkUnverifiedResponse, error)
	// SetReplicationFactor assigns or unassigns host nodes from the repository to meet the desired replication factor.
	// SetReplicationFactor returns an error when trying to set a replication factor that exceeds the storage node count
	// in the virtual storage. An error is also returned when trying to set a replication factor below one. The primary node
	// won't be unassigned as it needs a copy of the repository to accept writes. Likewise, the primary is the first storage
	// that gets assigned when setting a replication factor for a repository. Assignments of unconfigured storages are ignored.
	// This might cause the actual replication factor to be higher than desired if the replication factor is set during an upgrade
	// from a Praefect node that does not yet know about a new node. As assignments of unconfigured storages are ignored, replication
	// factor of repositories assigned to a storage node removed from the cluster is effectively decreased.
	SetReplicationFactor(context.Context, *SetReplicationFactorRequest) (*SetReplicationFactorResponse, error)
	// GetRepositoryMetadata returns the cluster metadata for a repository. Returns NotFound if the repository does not exist.
	GetRepositoryMetadata(context.Context, *GetRepositoryMetadataRequest) (*GetRepositoryMetadataResponse, error)
	mustEmbedUnimplementedPraefectInfoServiceServer()
}

// UnimplementedPraefectInfoServiceServer must be embedded to have forward compatible implementations.
type UnimplementedPraefectInfoServiceServer struct {
}

func (UnimplementedPraefectInfoServiceServer) RepositoryReplicas(context.Context, *RepositoryReplicasRequest) (*RepositoryReplicasResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method RepositoryReplicas not implemented")
}
func (UnimplementedPraefectInfoServiceServer) Dataloss(*DatalossRequest, PraefectInfoService_DatalossServer) error {
	return status.Errorf(codes.Unimplemented, "method Dataloss not implemented")
}
func (UnimplementedPraefectInfoServiceServer) SetAuthoritativeStorage(context.Context, *SetAuthoritativeStorageRequest) (*SetAuthoritativeStorageResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetAuthoritativeStorage not implemented")
}
func (UnimplementedPraefectInfoServiceServer) MarkUnverified(context.Context, *MarkUnverifiedRequest) (*MarkUnverifiedResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method MarkUnverified not implemented")
}
func (UnimplementedPraefectInfoServiceServer) SetReplicationFactor(context.Context, *SetReplicationFactorRequest) (*SetReplicationFactorResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SetReplicationFactor not implemented")
}
func (UnimplementedPraefectInfoServiceServer) GetRepositoryMetadata(context.Context, *GetRepositoryMetadataRequest) (*GetRepositoryMetadataResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetRepositoryMetadata not implemented")
}
func (UnimplementedPraefectInfoServiceServer) mustEmbedUnimplementedPraefectInfoServiceServer() {}

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

func RegisterPraefectInfoServiceServer(s grpc.ServiceRegistrar, srv PraefectInfoServiceServer) {
	s.RegisterService(&PraefectInfoService_ServiceDesc, srv)
}

func _PraefectInfoService_RepositoryReplicas_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(RepositoryReplicasRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PraefectInfoServiceServer).RepositoryReplicas(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PraefectInfoService_RepositoryReplicas_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PraefectInfoServiceServer).RepositoryReplicas(ctx, req.(*RepositoryReplicasRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _PraefectInfoService_Dataloss_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(DatalossRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(PraefectInfoServiceServer).Dataloss(m, &praefectInfoServiceDatalossServer{stream})
}

type PraefectInfoService_DatalossServer interface {
	Send(*DatalossResponse) error
	grpc.ServerStream
}

type praefectInfoServiceDatalossServer struct {
	grpc.ServerStream
}

func (x *praefectInfoServiceDatalossServer) Send(m *DatalossResponse) error {
	return x.ServerStream.SendMsg(m)
}

func _PraefectInfoService_SetAuthoritativeStorage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SetAuthoritativeStorageRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PraefectInfoServiceServer).SetAuthoritativeStorage(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PraefectInfoService_SetAuthoritativeStorage_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PraefectInfoServiceServer).SetAuthoritativeStorage(ctx, req.(*SetAuthoritativeStorageRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _PraefectInfoService_MarkUnverified_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(MarkUnverifiedRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PraefectInfoServiceServer).MarkUnverified(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PraefectInfoService_MarkUnverified_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PraefectInfoServiceServer).MarkUnverified(ctx, req.(*MarkUnverifiedRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _PraefectInfoService_SetReplicationFactor_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SetReplicationFactorRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PraefectInfoServiceServer).SetReplicationFactor(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PraefectInfoService_SetReplicationFactor_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PraefectInfoServiceServer).SetReplicationFactor(ctx, req.(*SetReplicationFactorRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _PraefectInfoService_GetRepositoryMetadata_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetRepositoryMetadataRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PraefectInfoServiceServer).GetRepositoryMetadata(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PraefectInfoService_GetRepositoryMetadata_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PraefectInfoServiceServer).GetRepositoryMetadata(ctx, req.(*GetRepositoryMetadataRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// PraefectInfoService_ServiceDesc is the grpc.ServiceDesc for PraefectInfoService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PraefectInfoService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "gitaly.PraefectInfoService",
	HandlerType: (*PraefectInfoServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "RepositoryReplicas",
			Handler:    _PraefectInfoService_RepositoryReplicas_Handler,
		},
		{
			MethodName: "SetAuthoritativeStorage",
			Handler:    _PraefectInfoService_SetAuthoritativeStorage_Handler,
		},
		{
			MethodName: "MarkUnverified",
			Handler:    _PraefectInfoService_MarkUnverified_Handler,
		},
		{
			MethodName: "SetReplicationFactor",
			Handler:    _PraefectInfoService_SetReplicationFactor_Handler,
		},
		{
			MethodName: "GetRepositoryMetadata",
			Handler:    _PraefectInfoService_GetRepositoryMetadata_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Dataloss",
			Handler:       _PraefectInfoService_Dataloss_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "praefect.proto",
}
