// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

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

package proto

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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9

const (
	Simple_Something_FullMethodName = "/hashicorp.consul.internal.protoc_gen_grpc_clone.testing.Simple/Something"
	Simple_Flow_FullMethodName      = "/hashicorp.consul.internal.protoc_gen_grpc_clone.testing.Simple/Flow"
)

// SimpleClient is the client API for Simple 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 SimpleClient interface {
	Something(ctx context.Context, in *Req, opts ...grpc.CallOption) (*Resp, error)
	Flow(ctx context.Context, in *Req, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Resp], error)
}

type simpleClient struct {
	cc grpc.ClientConnInterface
}

func NewSimpleClient(cc grpc.ClientConnInterface) SimpleClient {
	return &simpleClient{cc}
}

func (c *simpleClient) Something(ctx context.Context, in *Req, opts ...grpc.CallOption) (*Resp, error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	out := new(Resp)
	err := c.cc.Invoke(ctx, Simple_Something_FullMethodName, in, out, cOpts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

func (c *simpleClient) Flow(ctx context.Context, in *Req, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Resp], error) {
	cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
	stream, err := c.cc.NewStream(ctx, &Simple_ServiceDesc.Streams[0], Simple_Flow_FullMethodName, cOpts...)
	if err != nil {
		return nil, err
	}
	x := &grpc.GenericClientStream[Req, Resp]{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
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type Simple_FlowClient = grpc.ServerStreamingClient[Resp]

// SimpleServer is the server API for Simple service.
// All implementations should embed UnimplementedSimpleServer
// for forward compatibility.
type SimpleServer interface {
	Something(context.Context, *Req) (*Resp, error)
	Flow(*Req, grpc.ServerStreamingServer[Resp]) error
}

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

func (UnimplementedSimpleServer) Something(context.Context, *Req) (*Resp, error) {
	return nil, status.Errorf(codes.Unimplemented, "method Something not implemented")
}
func (UnimplementedSimpleServer) Flow(*Req, grpc.ServerStreamingServer[Resp]) error {
	return status.Errorf(codes.Unimplemented, "method Flow not implemented")
}
func (UnimplementedSimpleServer) testEmbeddedByValue() {}

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

func RegisterSimpleServer(s grpc.ServiceRegistrar, srv SimpleServer) {
	// If the following call pancis, it indicates UnimplementedSimpleServer 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(&Simple_ServiceDesc, srv)
}

func _Simple_Something_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
	in := new(Req)
	if err := dec(in); err != nil {
		return nil, err
	}
	if interceptor == nil {
		return srv.(SimpleServer).Something(ctx, in)
	}
	info := &grpc.UnaryServerInfo{
		Server:     srv,
		FullMethod: Simple_Something_FullMethodName,
	}
	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
		return srv.(SimpleServer).Something(ctx, req.(*Req))
	}
	return interceptor(ctx, in, info, handler)
}

func _Simple_Flow_Handler(srv interface{}, stream grpc.ServerStream) error {
	m := new(Req)
	if err := stream.RecvMsg(m); err != nil {
		return err
	}
	return srv.(SimpleServer).Flow(m, &grpc.GenericServerStream[Req, Resp]{ServerStream: stream})
}

// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type Simple_FlowServer = grpc.ServerStreamingServer[Resp]

// Simple_ServiceDesc is the grpc.ServiceDesc for Simple service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Simple_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "hashicorp.consul.internal.protoc_gen_grpc_clone.testing.Simple",
	HandlerType: (*SimpleServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Something",
			Handler:    _Simple_Something_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Flow",
			Handler:       _Simple_Flow_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "service.proto",
}
