// 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/publication_service.proto

package v1

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

const (
	PublicationService_CreatePublication_FullMethodName = "/agntcy.dir.routing.v1.PublicationService/CreatePublication"
	PublicationService_ListPublications_FullMethodName  = "/agntcy.dir.routing.v1.PublicationService/ListPublications"
	PublicationService_GetPublication_FullMethodName    = "/agntcy.dir.routing.v1.PublicationService/GetPublication"
)

// PublicationServiceClient is the client API for PublicationService 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.
//
// PublicationService manages publication requests for announcing records to the DHT.
//
// Publications are stored in the database and processed by a worker that runs every hour.
// The publication workflow:
// 1. Publications are created via routing's Publish RPC by specifying either a query, a list of CIDs, or all records
// 2. Publication requests are added to the database
// 3. PublicationWorker queries the data using the publication request from the database to get the list of CIDs to be published
// 4. PublicationWorker announces the records with these CIDs to the DHT
type PublicationServiceClient interface {
	// CreatePublication creates a new publication request that will be processed by the PublicationWorker.
	// The publication request can specify either a query, a list of specific CIDs, or all records to be announced to the DHT.
	CreatePublication(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*CreatePublicationResponse, error)
	// ListPublications returns a stream of all publication requests in the system.
	// This allows monitoring of pending, processing, and completed publication requests.
	ListPublications(ctx context.Context, in *ListPublicationsRequest, opts ...grpc.CallOption) (PublicationService_ListPublicationsClient, error)
	// GetPublication retrieves details of a specific publication request by its identifier.
	// This includes the current status and any associated metadata.
	GetPublication(ctx context.Context, in *GetPublicationRequest, opts ...grpc.CallOption) (*GetPublicationResponse, error)
}

type publicationServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewPublicationServiceClient(cc grpc.ClientConnInterface) PublicationServiceClient {
	return &publicationServiceClient{cc}
}

func (c *publicationServiceClient) CreatePublication(ctx context.Context, in *PublishRequest, opts ...grpc.CallOption) (*CreatePublicationResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(CreatePublicationResponse)
	err := c.cc.Invoke(ctx, PublicationService_CreatePublication_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *publicationServiceClient) ListPublications(ctx context.Context, in *ListPublicationsRequest, opts ...grpc.CallOption) (PublicationService_ListPublicationsClient, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &PublicationService_ServiceDesc.Streams[0], PublicationService_ListPublications_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &publicationServiceListPublicationsClient{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 PublicationService_ListPublicationsClient interface {
	Recv() (*ListPublicationsItem, error)
	grpc.ClientStream
}

type publicationServiceListPublicationsClient struct {
	grpc.ClientStream
}

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

func (c *publicationServiceClient) GetPublication(ctx context.Context, in *GetPublicationRequest, opts ...grpc.CallOption) (*GetPublicationResponse, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(GetPublicationResponse)
	err := c.cc.Invoke(ctx, PublicationService_GetPublication_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// PublicationServiceServer is the server API for PublicationService service.
// All implementations should embed UnimplementedPublicationServiceServer
// for forward compatibility.
//
// PublicationService manages publication requests for announcing records to the DHT.
//
// Publications are stored in the database and processed by a worker that runs every hour.
// The publication workflow:
// 1. Publications are created via routing's Publish RPC by specifying either a query, a list of CIDs, or all records
// 2. Publication requests are added to the database
// 3. PublicationWorker queries the data using the publication request from the database to get the list of CIDs to be published
// 4. PublicationWorker announces the records with these CIDs to the DHT
type PublicationServiceServer interface {
	// CreatePublication creates a new publication request that will be processed by the PublicationWorker.
	// The publication request can specify either a query, a list of specific CIDs, or all records to be announced to the DHT.
	CreatePublication(context.Context, *PublishRequest) (*CreatePublicationResponse, error)
	// ListPublications returns a stream of all publication requests in the system.
	// This allows monitoring of pending, processing, and completed publication requests.
	ListPublications(*ListPublicationsRequest, PublicationService_ListPublicationsServer) error
	// GetPublication retrieves details of a specific publication request by its identifier.
	// This includes the current status and any associated metadata.
	GetPublication(context.Context, *GetPublicationRequest) (*GetPublicationResponse, error)
}

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

func (UnimplementedPublicationServiceServer) CreatePublication(context.Context, *PublishRequest) (*CreatePublicationResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method CreatePublication not implemented")
}
func (UnimplementedPublicationServiceServer) ListPublications(*ListPublicationsRequest, PublicationService_ListPublicationsServer) error {
	return status.Errorf(codes.Unimplemented, "method ListPublications not implemented")
}
func (UnimplementedPublicationServiceServer) GetPublication(context.Context, *GetPublicationRequest) (*GetPublicationResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetPublication not implemented")
}
func (UnimplementedPublicationServiceServer) testEmbeddedByValue() {}

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

func RegisterPublicationServiceServer(s grpc.ServiceRegistrar, srv PublicationServiceServer) {
	// If the following call pancis, it indicates UnimplementedPublicationServiceServer 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(&PublicationService_ServiceDesc, srv)
}

func _PublicationService_CreatePublication_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.(PublicationServiceServer).CreatePublication(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PublicationService_CreatePublication_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PublicationServiceServer).CreatePublication(ctx, req.(*PublishRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _PublicationService_ListPublications_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(ListPublicationsRequest)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(PublicationServiceServer).ListPublications(m, &publicationServiceListPublicationsServer{ServerStream: stream})
}

type PublicationService_ListPublicationsServer interface {
	Send(*ListPublicationsItem) error
	grpc.ServerStream
}

type publicationServiceListPublicationsServer struct {
	grpc.ServerStream
}

func (x *publicationServiceListPublicationsServer) Send(m *ListPublicationsItem) error {
	return x.ServerStream.SendMsg(m)
}

func _PublicationService_GetPublication_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetPublicationRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(PublicationServiceServer).GetPublication(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: PublicationService_GetPublication_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(PublicationServiceServer).GetPublication(ctx, req.(*GetPublicationRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// PublicationService_ServiceDesc is the grpc.ServiceDesc for PublicationService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var PublicationService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "agntcy.dir.routing.v1.PublicationService",
	HandlerType: (*PublicationServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CreatePublication",
			Handler:    _PublicationService_CreatePublication_Handler,
		},
		{
			MethodName: "GetPublication",
			Handler:    _PublicationService_GetPublication_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListPublications",
			Handler:       _PublicationService_ListPublications_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "agntcy/dir/routing/v1/publication_service.proto",
}
