// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc             v3.21.6
// source: greptime/v1/meta/heartbeat.proto

package meta

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

// HeartbeatClient is the client API for Heartbeat 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 HeartbeatClient interface {
	// Heartbeat, there may be many contents of the heartbeat, such as:
	//  1. Metadata to be registered to meta server and discoverable by other
	//     nodes.
	//  2. Some performance metrics, such as Load, CPU usage, etc.
	//  3. The number of computing tasks being executed.
	Heartbeat(ctx context.Context, opts ...grpc.CallOption) (Heartbeat_HeartbeatClient, error)
	// Ask leader's endpoint.
	AskLeader(ctx context.Context, in *AskLeaderRequest, opts ...grpc.CallOption) (*AskLeaderResponse, error)
}

type heartbeatClient struct {
	cc grpc.ClientConnInterface
}

func NewHeartbeatClient(cc grpc.ClientConnInterface) HeartbeatClient {
	return &heartbeatClient{cc}
}

func (c *heartbeatClient) Heartbeat(ctx context.Context, opts ...grpc.CallOption) (Heartbeat_HeartbeatClient, error) {
	stream, err := c.cc.NewStream(ctx, &Heartbeat_ServiceDesc.Streams[0], "/greptime.v1.meta.Heartbeat/Heartbeat", opts...)
	if err != nil {
		return nil, err
	}
	x := &heartbeatHeartbeatClient{stream}
	return x, nil
}

type Heartbeat_HeartbeatClient interface {
	Send(*HeartbeatRequest) error
	Recv() (*HeartbeatResponse, error)
	grpc.ClientStream
}

type heartbeatHeartbeatClient struct {
	grpc.ClientStream
}

func (x *heartbeatHeartbeatClient) Send(m *HeartbeatRequest) error {
	return x.ClientStream.SendMsg(m)
}

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

func (c *heartbeatClient) AskLeader(ctx context.Context, in *AskLeaderRequest, opts ...grpc.CallOption) (*AskLeaderResponse, error) {
	out := new(AskLeaderResponse)
	err := c.cc.Invoke(ctx, "/greptime.v1.meta.Heartbeat/AskLeader", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// HeartbeatServer is the server API for Heartbeat service.
// All implementations must embed UnimplementedHeartbeatServer
// for forward compatibility
type HeartbeatServer interface {
	// Heartbeat, there may be many contents of the heartbeat, such as:
	//  1. Metadata to be registered to meta server and discoverable by other
	//     nodes.
	//  2. Some performance metrics, such as Load, CPU usage, etc.
	//  3. The number of computing tasks being executed.
	Heartbeat(Heartbeat_HeartbeatServer) error
	// Ask leader's endpoint.
	AskLeader(context.Context, *AskLeaderRequest) (*AskLeaderResponse, error)
	mustEmbedUnimplementedHeartbeatServer()
}

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

func (UnimplementedHeartbeatServer) Heartbeat(Heartbeat_HeartbeatServer) error {
	return status.Errorf(codes.Unimplemented, "method Heartbeat not implemented")
}
func (UnimplementedHeartbeatServer) AskLeader(context.Context, *AskLeaderRequest) (*AskLeaderResponse, error) {
	return nil, status.Errorf(codes.Unimplemented, "method AskLeader not implemented")
}
func (UnimplementedHeartbeatServer) mustEmbedUnimplementedHeartbeatServer() {}

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

func RegisterHeartbeatServer(s grpc.ServiceRegistrar, srv HeartbeatServer) {
	s.RegisterService(&Heartbeat_ServiceDesc, srv)
}

func _Heartbeat_Heartbeat_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(HeartbeatServer).Heartbeat(&heartbeatHeartbeatServer{stream})
}

type Heartbeat_HeartbeatServer interface {
	Send(*HeartbeatResponse) error
	Recv() (*HeartbeatRequest, error)
	grpc.ServerStream
}

type heartbeatHeartbeatServer struct {
	grpc.ServerStream
}

func (x *heartbeatHeartbeatServer) Send(m *HeartbeatResponse) error {
	return x.ServerStream.SendMsg(m)
}

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

func _Heartbeat_AskLeader_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(AskLeaderRequest)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(HeartbeatServer).AskLeader(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/greptime.v1.meta.Heartbeat/AskLeader",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(HeartbeatServer).AskLeader(ctx, req.(*AskLeaderRequest))
	}
	return interceptor(ctx, in, info, handler)
}

// Heartbeat_ServiceDesc is the grpc.ServiceDesc for Heartbeat service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Heartbeat_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "greptime.v1.meta.Heartbeat",
	HandlerType: (*HeartbeatServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "AskLeader",
			Handler:    _Heartbeat_AskLeader_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Heartbeat",
			Handler:       _Heartbeat_Heartbeat_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "greptime/v1/meta/heartbeat.proto",
}
