// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             v3.5.0
// source: felixbackend.proto

package 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 (
	PolicySync_Sync_FullMethodName   = "/felix.PolicySync/Sync"
	PolicySync_Report_FullMethodName = "/felix.PolicySync/Report"
)

// PolicySyncClient is the client API for PolicySync 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 PolicySyncClient interface {
	// On this API, only the following payloads will be sent:
	//   - InSync
	//   - IPSetUpdate
	//   - IPSetDeltaUpdate
	//   - IPSetRemove
	//   - ActiveProfileUpdate
	//   - ActiveProfileRemove
	//   - ActivePolicyUpdate
	//   - ActivePolicyRemove
	//   - WorkloadEndpointUpdate
	//   - WorkloadEndpointRemove
	//   - ServiceAccountUpdate
	//   - ServiceAccountRemove
	//   - NamespaceUpdate
	//   - NamespaceRemove
	//   - RouteUpdate
	//   - RouteRemove
	//   - VXLANTunnelEndpointUpdate
	//   - VXLANTunnelEndpointRemove
	Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ToDataplane], error)
	// Report dataplane statistics to Felix.
	Report(ctx context.Context, in *DataplaneStats, opts ...grpc.CallOption) (*ReportResult, error)
}

type policySyncClient struct {
	cc grpc.ClientConnInterface
}

func NewPolicySyncClient(cc grpc.ClientConnInterface) PolicySyncClient {
	return &policySyncClient{cc}
}

func (c *policySyncClient) Sync(ctx context.Context, in *SyncRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[ToDataplane], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &PolicySync_ServiceDesc.Streams[0], PolicySync_Sync_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[SyncRequest, ToDataplane]{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 PolicySync_SyncClient = grpc.ServerStreamingClient[ToDataplane]

func (c *policySyncClient) Report(ctx context.Context, in *DataplaneStats, opts ...grpc.CallOption) (*ReportResult, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(ReportResult)
	err := c.cc.Invoke(ctx, PolicySync_Report_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// PolicySyncServer is the server API for PolicySync service.
// All implementations must embed UnimplementedPolicySyncServer
// for forward compatibility.
type PolicySyncServer interface {
	// On this API, only the following payloads will be sent:
	//   - InSync
	//   - IPSetUpdate
	//   - IPSetDeltaUpdate
	//   - IPSetRemove
	//   - ActiveProfileUpdate
	//   - ActiveProfileRemove
	//   - ActivePolicyUpdate
	//   - ActivePolicyRemove
	//   - WorkloadEndpointUpdate
	//   - WorkloadEndpointRemove
	//   - ServiceAccountUpdate
	//   - ServiceAccountRemove
	//   - NamespaceUpdate
	//   - NamespaceRemove
	//   - RouteUpdate
	//   - RouteRemove
	//   - VXLANTunnelEndpointUpdate
	//   - VXLANTunnelEndpointRemove
	Sync(*SyncRequest, grpc.ServerStreamingServer[ToDataplane]) error
	// Report dataplane statistics to Felix.
	Report(context.Context, *DataplaneStats) (*ReportResult, error)
	mustEmbedUnimplementedPolicySyncServer()
}

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

func (UnimplementedPolicySyncServer) Sync(*SyncRequest, grpc.ServerStreamingServer[ToDataplane]) error {
	return status.Errorf(codes.Unimplemented, "method Sync not implemented")
}
func (UnimplementedPolicySyncServer) Report(context.Context, *DataplaneStats) (*ReportResult, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Report not implemented")
}
func (UnimplementedPolicySyncServer) mustEmbedUnimplementedPolicySyncServer() {}
func (UnimplementedPolicySyncServer) testEmbeddedByValue()                    {}

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

func RegisterPolicySyncServer(s grpc.ServiceRegistrar, srv PolicySyncServer) {
	// If the following call pancis, it indicates UnimplementedPolicySyncServer 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(&PolicySync_ServiceDesc, srv)
}

func _PolicySync_Sync_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SyncRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(PolicySyncServer).Sync(m, &grpc.GenericServerStream[SyncRequest, ToDataplane]{ServerStream: stream})
}

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

func _PolicySync_Report_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(DataplaneStats)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PolicySyncServer).Report(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PolicySync_Report_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PolicySyncServer).Report(ctx, req.(*DataplaneStats))
	}
	return interceptor(ctx, in, info, handler)
}

// PolicySync_ServiceDesc is the grpc.ServiceDesc for PolicySync service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PolicySync_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "felix.PolicySync",
	HandlerType: (*PolicySyncServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Report",
			Handler:    _PolicySync_Report_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Sync",
			Handler:       _PolicySync_Sync_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "felixbackend.proto",
}
