// Code generated by protoc-gen-go-grpc. DO NOT EDIT.

package v10

import (
	context "context"
	grpc "google.golang.org/grpc"
	codes "google.golang.org/grpc/codes"
	status "google.golang.org/grpc/status"
	v3 "github.com/apache/skywalking-go/protocols/collect/common/v3"
)

// 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

// AsyncProfilerTaskClient is the client API for AsyncProfilerTask 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 AsyncProfilerTaskClient interface {
	// collect sends JFR data to the OAP server
	Collect(ctx context.Context, opts ...grpc.CallOption) (AsyncProfilerTask_CollectClient, error)
	// getAsyncProfilerTaskCommands sends query to the OAP server for all AsyncProfiler tasks to be executed for the given Java Agent instance
	GetAsyncProfilerTaskCommands(ctx context.Context, in *AsyncProfilerTaskCommandQuery, opts ...grpc.CallOption) (*v3.Commands, error)
}

type asyncProfilerTaskClient struct {
	cc grpc.ClientConnInterface
}

func NewAsyncProfilerTaskClient(cc grpc.ClientConnInterface) AsyncProfilerTaskClient {
	return &asyncProfilerTaskClient{cc}
}

func (c *asyncProfilerTaskClient) Collect(ctx context.Context, opts ...grpc.CallOption) (AsyncProfilerTask_CollectClient, error) {
	stream, err := c.cc.NewStream(ctx, &AsyncProfilerTask_ServiceDesc.Streams[0], "/skywalking.v10.AsyncProfilerTask/collect", opts...)
	if err != nil {
		return nil, err
	}
	x := &asyncProfilerTaskCollectClient{stream}
	return x, nil
}

type AsyncProfilerTask_CollectClient interface {
	Send(*AsyncProfilerData) error
	Recv() (*AsyncProfilerCollectionResponse, error)
	grpc.ClientStream
}

type asyncProfilerTaskCollectClient struct {
	grpc.ClientStream
}

func (x *asyncProfilerTaskCollectClient) Send(m *AsyncProfilerData) error {
	return x.ClientStream.SendMsg(m)
}

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

func (c *asyncProfilerTaskClient) GetAsyncProfilerTaskCommands(ctx context.Context, in *AsyncProfilerTaskCommandQuery, opts ...grpc.CallOption) (*v3.Commands, error) {
	out := new(v3.Commands)
	err := c.cc.Invoke(ctx, "/skywalking.v10.AsyncProfilerTask/getAsyncProfilerTaskCommands", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

// AsyncProfilerTaskServer is the server API for AsyncProfilerTask service.
// All implementations must embed UnimplementedAsyncProfilerTaskServer
// for forward compatibility
type AsyncProfilerTaskServer interface {
	// collect sends JFR data to the OAP server
	Collect(AsyncProfilerTask_CollectServer) error
	// getAsyncProfilerTaskCommands sends query to the OAP server for all AsyncProfiler tasks to be executed for the given Java Agent instance
	GetAsyncProfilerTaskCommands(context.Context, *AsyncProfilerTaskCommandQuery) (*v3.Commands, error)
	mustEmbedUnimplementedAsyncProfilerTaskServer()
}

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

func (UnimplementedAsyncProfilerTaskServer) Collect(AsyncProfilerTask_CollectServer) error {
	return status.Errorf(codes.Unimplemented, "method Collect not implemented")
}
func (UnimplementedAsyncProfilerTaskServer) GetAsyncProfilerTaskCommands(context.Context, *AsyncProfilerTaskCommandQuery) (*v3.Commands, error) {
	return nil, status.Errorf(codes.Unimplemented, "method GetAsyncProfilerTaskCommands not implemented")
}
func (UnimplementedAsyncProfilerTaskServer) mustEmbedUnimplementedAsyncProfilerTaskServer() {}

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

func RegisterAsyncProfilerTaskServer(s grpc.ServiceRegistrar, srv AsyncProfilerTaskServer) {
	s.RegisterService(&AsyncProfilerTask_ServiceDesc, srv)
}

func _AsyncProfilerTask_Collect_Handler(srv interface{}, stream grpc.ServerStream) error {
	return srv.(AsyncProfilerTaskServer).Collect(&asyncProfilerTaskCollectServer{stream})
}

type AsyncProfilerTask_CollectServer interface {
	Send(*AsyncProfilerCollectionResponse) error
	Recv() (*AsyncProfilerData, error)
	grpc.ServerStream
}

type asyncProfilerTaskCollectServer struct {
	grpc.ServerStream
}

func (x *asyncProfilerTaskCollectServer) Send(m *AsyncProfilerCollectionResponse) error {
	return x.ServerStream.SendMsg(m)
}

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

func _AsyncProfilerTask_GetAsyncProfilerTaskCommands_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(AsyncProfilerTaskCommandQuery)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(AsyncProfilerTaskServer).GetAsyncProfilerTaskCommands(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: "/skywalking.v10.AsyncProfilerTask/getAsyncProfilerTaskCommands",
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(AsyncProfilerTaskServer).GetAsyncProfilerTaskCommands(ctx, req.(*AsyncProfilerTaskCommandQuery))
	}
	return interceptor(ctx, in, info, handler)
}

// AsyncProfilerTask_ServiceDesc is the grpc.ServiceDesc for AsyncProfilerTask service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AsyncProfilerTask_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "skywalking.v10.AsyncProfilerTask",
	HandlerType: (*AsyncProfilerTaskServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "getAsyncProfilerTaskCommands",
			Handler:    _AsyncProfilerTask_GetAsyncProfilerTaskCommands_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "collect",
			Handler:       _AsyncProfilerTask_Collect_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "asyncprofiler/AsyncProfiler.proto",
}
