// 使用的语法版本

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc             v4.22.3
// source: pkgs/grpc/hub/hub.proto

package hub

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

const (
	Hub_ExecuteIOPlan_FullMethodName = "/Hub/ExecuteIOPlan"
	Hub_SendStream_FullMethodName    = "/Hub/SendStream"
	Hub_GetStream_FullMethodName     = "/Hub/GetStream"
	Hub_SendVar_FullMethodName       = "/Hub/SendVar"
	Hub_GetVar_FullMethodName        = "/Hub/GetVar"
	Hub_Ping_FullMethodName          = "/Hub/Ping"
)

// HubClient is the client API for Hub 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 HubClient interface {
	ExecuteIOPlan(ctx context.Context, in *ExecuteIOPlanReq, opts ...grpc.CallOption) (*ExecuteIOPlanResp, error)
	SendStream(ctx context.Context, opts ...grpc.CallOption) (Hub_SendStreamClient, error)
	GetStream(ctx context.Context, in *GetStreamReq, opts ...grpc.CallOption) (Hub_GetStreamClient, error)
	SendVar(ctx context.Context, in *SendVarReq, opts ...grpc.CallOption) (*SendVarResp, error)
	GetVar(ctx context.Context, in *GetVarReq, opts ...grpc.CallOption) (*GetVarResp, error)
	Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingResp, error)
}

type hubClient struct {
	cc grpc.ClientConnInterface
}

func NewHubClient(cc grpc.ClientConnInterface) HubClient {
	return &hubClient{cc}
}

func (c *hubClient) ExecuteIOPlan(ctx context.Context, in *ExecuteIOPlanReq, opts ...grpc.CallOption) (*ExecuteIOPlanResp, error) {
	out := new(ExecuteIOPlanResp)
	err := c.cc.Invoke(ctx, Hub_ExecuteIOPlan_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *hubClient) SendStream(ctx context.Context, opts ...grpc.CallOption) (Hub_SendStreamClient, error) {
	stream, err := c.cc.NewStream(ctx, &Hub_ServiceDesc.Streams[0], Hub_SendStream_FullMethodName, opts...)
	if err != nil {
		return nil, err
	}
	x := &hubSendStreamClient{stream}
	return x, nil
}

type Hub_SendStreamClient interface {
	Send(*StreamDataPacket) error
	CloseAndRecv() (*SendStreamResp, error)
	grpc.ClientStream
}

type hubSendStreamClient struct {
	grpc.ClientStream
}

func (x *hubSendStreamClient) Send(m *StreamDataPacket) error {
	return x.ClientStream.SendMsg(m)
}

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

func (c *hubClient) GetStream(ctx context.Context, in *GetStreamReq, opts ...grpc.CallOption) (Hub_GetStreamClient, error) {
	stream, err := c.cc.NewStream(ctx, &Hub_ServiceDesc.Streams[1], Hub_GetStream_FullMethodName, opts...)
	if err != nil {
		return nil, err
	}
	x := &hubGetStreamClient{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 Hub_GetStreamClient interface {
	Recv() (*StreamDataPacket, error)
	grpc.ClientStream
}

type hubGetStreamClient struct {
	grpc.ClientStream
}

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

func (c *hubClient) SendVar(ctx context.Context, in *SendVarReq, opts ...grpc.CallOption) (*SendVarResp, error) {
	out := new(SendVarResp)
	err := c.cc.Invoke(ctx, Hub_SendVar_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *hubClient) GetVar(ctx context.Context, in *GetVarReq, opts ...grpc.CallOption) (*GetVarResp, error) {
	out := new(GetVarResp)
	err := c.cc.Invoke(ctx, Hub_GetVar_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *hubClient) Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingResp, error) {
	out := new(PingResp)
	err := c.cc.Invoke(ctx, Hub_Ping_FullMethodName, in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// HubServer is the server API for Hub service.
// All implementations must embed UnimplementedHubServer
// for forward compatibility
type HubServer interface {
	ExecuteIOPlan(context.Context, *ExecuteIOPlanReq) (*ExecuteIOPlanResp, error)
	SendStream(Hub_SendStreamServer) error
	GetStream(*GetStreamReq, Hub_GetStreamServer) error
	SendVar(context.Context, *SendVarReq) (*SendVarResp, error)
	GetVar(context.Context, *GetVarReq) (*GetVarResp, error)
	Ping(context.Context, *PingReq) (*PingResp, error)
	mustEmbedUnimplementedHubServer()
}

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

func (UnimplementedHubServer) ExecuteIOPlan(context.Context, *ExecuteIOPlanReq) (*ExecuteIOPlanResp, error) {
	return nil, status.Errorf(codes.Unimplemented, "method ExecuteIOPlan not implemented")
}
func (UnimplementedHubServer) SendStream(Hub_SendStreamServer) error {
	return status.Errorf(codes.Unimplemented, "method SendStream not implemented")
}
func (UnimplementedHubServer) GetStream(*GetStreamReq, Hub_GetStreamServer) error {
	return status.Errorf(codes.Unimplemented, "method GetStream not implemented")
}
func (UnimplementedHubServer) SendVar(context.Context, *SendVarReq) (*SendVarResp, error) {
	return nil, status.Errorf(codes.Unimplemented, "method SendVar not implemented")
}
func (UnimplementedHubServer) GetVar(context.Context, *GetVarReq) (*GetVarResp, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetVar not implemented")
}
func (UnimplementedHubServer) Ping(context.Context, *PingReq) (*PingResp, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
}
func (UnimplementedHubServer) mustEmbedUnimplementedHubServer() {}

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

func RegisterHubServer(s grpc.ServiceRegistrar, srv HubServer) {
	s.RegisterService(&Hub_ServiceDesc, srv)
}

func _Hub_ExecuteIOPlan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(ExecuteIOPlanReq)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(HubServer).ExecuteIOPlan(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: Hub_ExecuteIOPlan_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(HubServer).ExecuteIOPlan(ctx, req.(*ExecuteIOPlanReq))
	}
	return interceptor(ctx, in, info, handler)
}

func _Hub_SendStream_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(HubServer).SendStream(&hubSendStreamServer{stream})
}

type Hub_SendStreamServer interface {
	SendAndClose(*SendStreamResp) error
	Recv() (*StreamDataPacket, error)
	grpc.ServerStream
}

type hubSendStreamServer struct {
	grpc.ServerStream
}

func (x *hubSendStreamServer) SendAndClose(m *SendStreamResp) error {
	return x.ServerStream.SendMsg(m)
}

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

func _Hub_GetStream_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(GetStreamReq)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(HubServer).GetStream(m, &hubGetStreamServer{stream})
}

type Hub_GetStreamServer interface {
	Send(*StreamDataPacket) error
	grpc.ServerStream
}

type hubGetStreamServer struct {
	grpc.ServerStream
}

func (x *hubGetStreamServer) Send(m *StreamDataPacket) error {
	return x.ServerStream.SendMsg(m)
}

func _Hub_SendVar_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(SendVarReq)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(HubServer).SendVar(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: Hub_SendVar_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(HubServer).SendVar(ctx, req.(*SendVarReq))
	}
	return interceptor(ctx, in, info, handler)
}

func _Hub_GetVar_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(GetVarReq)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(HubServer).GetVar(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: Hub_GetVar_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(HubServer).GetVar(ctx, req.(*GetVarReq))
	}
	return interceptor(ctx, in, info, handler)
}

func _Hub_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(PingReq)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(HubServer).Ping(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: Hub_Ping_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(HubServer).Ping(ctx, req.(*PingReq))
	}
	return interceptor(ctx, in, info, handler)
}

// Hub_ServiceDesc is the grpc.ServiceDesc for Hub service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Hub_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "Hub",
	HandlerType: (*HubServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ExecuteIOPlan",
			Handler:    _Hub_ExecuteIOPlan_Handler,
		},
		{
			MethodName: "SendVar",
			Handler:    _Hub_SendVar_Handler,
		},
		{
			MethodName: "GetVar",
			Handler:    _Hub_GetVar_Handler,
		},
		{
			MethodName: "Ping",
			Handler:    _Hub_Ping_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "SendStream",
			Handler:       _Hub_SendStream_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "GetStream",
			Handler:       _Hub_GetStream_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "pkgs/grpc/hub/hub.proto",
}
