// Copyright AGNTCY Contributors (https://github.com/agntcy)
// SPDX-License-Identifier: Apache-2.0

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc             (unknown)
// source: agntcy/dir/routing/v1/routing_service.proto

package v1

import (
	context "context"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
	emptypb "google.golang.org/protobuf/types/known/emptypb"
)

// 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.62.0 or later.
const _ = grpc.SupportPackageIsVersion8

const (
	RoutingService_Publish_FullMethodName   = "/agntcy.dir.routing.v1.RoutingService/Publish"
	RoutingService_Unpublish_FullMethodName = "/agntcy.dir.routing.v1.RoutingService/Unpublish"
	RoutingService_Search_FullMethodName    = "/agntcy.dir.routing.v1.RoutingService/Search"
	RoutingService_List_FullMethodName      = "/agntcy.dir.routing.v1.RoutingService/List"
)

// RoutingServiceClient is the client API for RoutingService 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.
//
// Defines an interface for announcement and discovery
// of records across interconnected network.
//
// Middleware should be used to control who can perform these RPCs.
// Policies for the middleware can be handled via separate service.
type RoutingServiceClient interface {
	// Announce to the network that this peer is providing a given record.
	// This enables other peers to discover this record and retrieve it
	// from this peer. Listeners can use this event to perform custom operations,
	// for example by cloning the record.
	//
	// Items need to be periodically republished (eg. 24h) to the network
	// to avoid stale data. Republication should be done in the background.
	Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Stop serving this record to the network. If other peers try
	// to retrieve this record, the peer will refuse the request.
	Unpublish(ctx context.Context, in *UnpublishRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Search records based on the request across the network.
	// This will search the network for the record with the given parameters.
	//
	// It is possible that the records are stale or that they do not exist.
	// Some records may be provided by multiple peers.
	//
	// Results from the search can be used as an input
	// to Pull operation to retrieve the records.
	Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (RoutingService_SearchClient, error)
	// List all records that this peer is currently providing
	// that match the given parameters.
	// This operation does not interact with the network.
	List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (RoutingService_ListClient, error)
}

type routingServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient {
	return &routingServiceClient{cc}
}

func (c *routingServiceClient) Publish(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(emptypb.Empty)
	err := c.cc.Invoke(ctx, RoutingService_Publish_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *routingServiceClient) Unpublish(ctx context.Context, in *UnpublishRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(emptypb.Empty)
	err := c.cc.Invoke(ctx, RoutingService_Unpublish_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *routingServiceClient) Search(ctx context.Context, in *SearchRequest, opts ...grpc.CallOption) (RoutingService_SearchClient, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_Search_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &routingServiceSearchClient{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
}

type RoutingService_SearchClient interface {
	Recv() (*SearchResponse, error)
	grpc.ClientStream
}

type routingServiceSearchClient struct {
	grpc.ClientStream
}

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

func (c *routingServiceClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (RoutingService_ListClient, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[1], RoutingService_List_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &routingServiceListClient{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
}

type RoutingService_ListClient interface {
	Recv() (*ListResponse, error)
	grpc.ClientStream
}

type routingServiceListClient struct {
	grpc.ClientStream
}

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

// RoutingServiceServer is the server API for RoutingService service.
// All implementations should embed UnimplementedRoutingServiceServer
// for forward compatibility.
//
// Defines an interface for announcement and discovery
// of records across interconnected network.
//
// Middleware should be used to control who can perform these RPCs.
// Policies for the middleware can be handled via separate service.
type RoutingServiceServer interface {
	// Announce to the network that this peer is providing a given record.
	// This enables other peers to discover this record and retrieve it
	// from this peer. Listeners can use this event to perform custom operations,
	// for example by cloning the record.
	//
	// Items need to be periodically republished (eg. 24h) to the network
	// to avoid stale data. Republication should be done in the background.
	Publish(context.Context, *PublishRequest) (*emptypb.Empty, error)
	// Stop serving this record to the network. If other peers try
	// to retrieve this record, the peer will refuse the request.
	Unpublish(context.Context, *UnpublishRequest) (*emptypb.Empty, error)
	// Search records based on the request across the network.
	// This will search the network for the record with the given parameters.
	//
	// It is possible that the records are stale or that they do not exist.
	// Some records may be provided by multiple peers.
	//
	// Results from the search can be used as an input
	// to Pull operation to retrieve the records.
	Search(*SearchRequest, RoutingService_SearchServer) error
	// List all records that this peer is currently providing
	// that match the given parameters.
	// This operation does not interact with the network.
	List(*ListRequest, RoutingService_ListServer) error
}

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

func (UnimplementedRoutingServiceServer) Publish(context.Context, *PublishRequest) (*emptypb.Empty, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Publish not implemented")
}
func (UnimplementedRoutingServiceServer) Unpublish(context.Context, *UnpublishRequest) (*emptypb.Empty, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Unpublish not implemented")
}
func (UnimplementedRoutingServiceServer) Search(*SearchRequest, RoutingService_SearchServer) error {
	return status.Errorf(codes.Unimplemented, "method Search not implemented")
}
func (UnimplementedRoutingServiceServer) List(*ListRequest, RoutingService_ListServer) error {
	return status.Errorf(codes.Unimplemented, "method List not implemented")
}
func (UnimplementedRoutingServiceServer) testEmbeddedByValue() {}

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

func RegisterRoutingServiceServer(s grpc.ServiceRegistrar, srv RoutingServiceServer) {
	// If the following call pancis, it indicates UnimplementedRoutingServiceServer 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(&RoutingService_ServiceDesc, srv)
}

func _RoutingService_Publish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(PublishRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(RoutingServiceServer).Publish(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: RoutingService_Publish_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(RoutingServiceServer).Publish(ctx, req.(*PublishRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _RoutingService_Unpublish_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(UnpublishRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(RoutingServiceServer).Unpublish(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: RoutingService_Unpublish_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(RoutingServiceServer).Unpublish(ctx, req.(*UnpublishRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _RoutingService_Search_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(SearchRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(RoutingServiceServer).Search(m, &routingServiceSearchServer{ServerStream: stream})
}

type RoutingService_SearchServer interface {
	Send(*SearchResponse) error
	grpc.ServerStream
}

type routingServiceSearchServer struct {
	grpc.ServerStream
}

func (x *routingServiceSearchServer) Send(m *SearchResponse) error {
	return x.ServerStream.SendMsg(m)
}

func _RoutingService_List_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(ListRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(RoutingServiceServer).List(m, &routingServiceListServer{ServerStream: stream})
}

type RoutingService_ListServer interface {
	Send(*ListResponse) error
	grpc.ServerStream
}

type routingServiceListServer struct {
	grpc.ServerStream
}

func (x *routingServiceListServer) Send(m *ListResponse) error {
	return x.ServerStream.SendMsg(m)
}

// RoutingService_ServiceDesc is the grpc.ServiceDesc for RoutingService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RoutingService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "agntcy.dir.routing.v1.RoutingService",
	HandlerType: (*RoutingServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Publish",
			Handler:    _RoutingService_Publish_Handler,
		},
		{
			MethodName: "Unpublish",
			Handler:    _RoutingService_Unpublish_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Search",
			Handler:       _RoutingService_Search_Handler,
			ServerStreams: true,
		},
		{
			StreamName:    "List",
			Handler:       _RoutingService_List_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "agntcy/dir/routing/v1/routing_service.proto",
}
