// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc             (unknown)
// source: count/v1/count.proto

package countv1

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

// CountServiceClient is the client API for CountService 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 CountServiceClient interface {
	// Add datapoints for request counting, over a streaming RPC.
	// Datapoints are stored asynchronous, to prevent blocking at the client side.
	// The stream is terminated by the server after the first error,
	// which might result in some datapoints not being stored.
	Add(ctx context.Context, opts ...grpc.CallOption) (CountService_AddClient, error)
	// CountDailyTotals triggers a count of daily requests.
	// Request entries for specified date are deleted, while being counted against
	// method and path pairs.
	// This method is meant to be called once a day in a cron-like job.
	// Repeated calls for the same date will not overwrite existing counts,
	// and may fail if additional request entries are found for a method and path pair.
	CountDailyTotals(ctx context.Context, in *CountDailyTotalsRequest, opts ...grpc.CallOption) (*CountDailyTotalsResponse, error)
	// ListDailyTotals returns a list of daily counts for each method and path pair.
	// Only entries which are previously created by CountDailyTotals can be returned.
	// When the requested interval does not result in any entries,
	// a NotFound error will be returned.
	ListDailyTotals(ctx context.Context, in *ListDailyTotalsRequest, opts ...grpc.CallOption) (*ListDailyTotalsResponse, error)
	// GetPeriodTotals returns a list of count for each method and path pair.
	// Only entries which are previously created by CountDailyTotals can be returned.
	// The inverval is determined by the fields in period. When:
	//   - day and month are zero, a list of totals for the requested year is returned.
	//   - only day is zero, a list of totals for the requested month and year is returned.
	//   - day and month are non zero, a list of totals for the request date is returned.
	//
	// When the requested period does not result in any entries,
	// a NotFound error will be returned.
	GetPeriodTotals(ctx context.Context, in *GetPeriodTotalsRequest, opts ...grpc.CallOption) (*GetPeriodTotalsResponse, error)
}

type countServiceClient struct {
	cc grpc.ClientConnInterface
}

func NewCountServiceClient(cc grpc.ClientConnInterface) CountServiceClient {
	return &countServiceClient{cc}
}

func (c *countServiceClient) Add(ctx context.Context, opts ...grpc.CallOption) (CountService_AddClient, error) {
	stream, err := c.cc.NewStream(ctx, &CountService_ServiceDesc.Streams[0], "/count.v1.CountService/Add", opts...)
	if err != nil {
		return nil, err
	}
	x := &countServiceAddClient{stream}
	return x, nil
}

type CountService_AddClient interface {
	Send(*AddRequest) error
	CloseAndRecv() (*AddResponse, error)
	grpc.ClientStream
}

type countServiceAddClient struct {
	grpc.ClientStream
}

func (x *countServiceAddClient) Send(m *AddRequest) error {
	return x.ClientStream.SendMsg(m)
}

func (x *countServiceAddClient) CloseAndRecv() (*AddResponse, error) {
	if err := x.ClientStream.CloseSend(); err != nil {
		return nil, err
	}
	m := new(AddResponse)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func (c *countServiceClient) CountDailyTotals(ctx context.Context, in *CountDailyTotalsRequest, opts ...grpc.CallOption) (*CountDailyTotalsResponse, error) {
	out := new(CountDailyTotalsResponse)
	err := c.cc.Invoke(ctx, "/count.v1.CountService/CountDailyTotals", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *countServiceClient) ListDailyTotals(ctx context.Context, in *ListDailyTotalsRequest, opts ...grpc.CallOption) (*ListDailyTotalsResponse, error) {
	out := new(ListDailyTotalsResponse)
	err := c.cc.Invoke(ctx, "/count.v1.CountService/ListDailyTotals", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *countServiceClient) GetPeriodTotals(ctx context.Context, in *GetPeriodTotalsRequest, opts ...grpc.CallOption) (*GetPeriodTotalsResponse, error) {
	out := new(GetPeriodTotalsResponse)
	err := c.cc.Invoke(ctx, "/count.v1.CountService/GetPeriodTotals", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// CountServiceServer is the server API for CountService service.
// All implementations must embed UnimplementedCountServiceServer
// for forward compatibility
type CountServiceServer interface {
	// Add datapoints for request counting, over a streaming RPC.
	// Datapoints are stored asynchronous, to prevent blocking at the client side.
	// The stream is terminated by the server after the first error,
	// which might result in some datapoints not being stored.
	Add(CountService_AddServer) error
	// CountDailyTotals triggers a count of daily requests.
	// Request entries for specified date are deleted, while being counted against
	// method and path pairs.
	// This method is meant to be called once a day in a cron-like job.
	// Repeated calls for the same date will not overwrite existing counts,
	// and may fail if additional request entries are found for a method and path pair.
	CountDailyTotals(context.Context, *CountDailyTotalsRequest) (*CountDailyTotalsResponse, error)
	// ListDailyTotals returns a list of daily counts for each method and path pair.
	// Only entries which are previously created by CountDailyTotals can be returned.
	// When the requested interval does not result in any entries,
	// a NotFound error will be returned.
	ListDailyTotals(context.Context, *ListDailyTotalsRequest) (*ListDailyTotalsResponse, error)
	// GetPeriodTotals returns a list of count for each method and path pair.
	// Only entries which are previously created by CountDailyTotals can be returned.
	// The inverval is determined by the fields in period. When:
	//   - day and month are zero, a list of totals for the requested year is returned.
	//   - only day is zero, a list of totals for the requested month and year is returned.
	//   - day and month are non zero, a list of totals for the request date is returned.
	//
	// When the requested period does not result in any entries,
	// a NotFound error will be returned.
	GetPeriodTotals(context.Context, *GetPeriodTotalsRequest) (*GetPeriodTotalsResponse, error)
	mustEmbedUnimplementedCountServiceServer()
}

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

func (UnimplementedCountServiceServer) Add(CountService_AddServer) error {
	return status.Errorf(codes.Unimplemented, "method Add not implemented")
}
func (UnimplementedCountServiceServer) CountDailyTotals(context.Context, *CountDailyTotalsRequest) (*CountDailyTotalsResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method CountDailyTotals not implemented")
}
func (UnimplementedCountServiceServer) ListDailyTotals(context.Context, *ListDailyTotalsRequest) (*ListDailyTotalsResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method ListDailyTotals not implemented")
}
func (UnimplementedCountServiceServer) GetPeriodTotals(context.Context, *GetPeriodTotalsRequest) (*GetPeriodTotalsResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetPeriodTotals not implemented")
}
func (UnimplementedCountServiceServer) mustEmbedUnimplementedCountServiceServer() {}

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

func RegisterCountServiceServer(s grpc.ServiceRegistrar, srv CountServiceServer) {
	s.RegisterService(&CountService_ServiceDesc, srv)
}

func _CountService_Add_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(CountServiceServer).Add(&countServiceAddServer{stream})
}

type CountService_AddServer interface {
	SendAndClose(*AddResponse) error
	Recv() (*AddRequest, error)
	grpc.ServerStream
}

type countServiceAddServer struct {
	grpc.ServerStream
}

func (x *countServiceAddServer) SendAndClose(m *AddResponse) error {
	return x.ServerStream.SendMsg(m)
}

func (x *countServiceAddServer) Recv() (*AddRequest, error) {
	m := new(AddRequest)
	if err := x.ServerStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}

func _CountService_CountDailyTotals_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(CountDailyTotalsRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(CountServiceServer).CountDailyTotals(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/count.v1.CountService/CountDailyTotals",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(CountServiceServer).CountDailyTotals(ctx, req.(*CountDailyTotalsRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _CountService_ListDailyTotals_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(ListDailyTotalsRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(CountServiceServer).ListDailyTotals(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/count.v1.CountService/ListDailyTotals",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(CountServiceServer).ListDailyTotals(ctx, req.(*ListDailyTotalsRequest))
	}
	return interceptor(ctx, in, info, handler)
}

func _CountService_GetPeriodTotals_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetPeriodTotalsRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(CountServiceServer).GetPeriodTotals(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/count.v1.CountService/GetPeriodTotals",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(CountServiceServer).GetPeriodTotals(ctx, req.(*GetPeriodTotalsRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// CountService_ServiceDesc is the grpc.ServiceDesc for CountService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var CountService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "count.v1.CountService",
	HandlerType: (*CountServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "CountDailyTotals",
			Handler:    _CountService_CountDailyTotals_Handler,
		},
		{
			MethodName: "ListDailyTotals",
			Handler:    _CountService_ListDailyTotals_Handler,
		},
		{
			MethodName: "GetPeriodTotals",
			Handler:    _CountService_GetPeriodTotals_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Add",
			Handler:       _CountService_Add_Handler,
			ClientStreams: true,
		},
	},
	Metadata: "count/v1/count.proto",
}
