// Code generated by protoc-gen-yarpc-go. DO NOT EDIT.
// source: uber/cadence/sharddistributor/v1/service.proto

package sharddistributorv1

import (
	"context"
	"io/ioutil"
	"reflect"

	"github.com/gogo/protobuf/jsonpb"
	"github.com/gogo/protobuf/proto"
	"go.uber.org/fx"
	"go.uber.org/yarpc"
	"go.uber.org/yarpc/api/transport"
	"go.uber.org/yarpc/api/x/restriction"
	"go.uber.org/yarpc/encoding/protobuf"
	"go.uber.org/yarpc/encoding/protobuf/reflection"
)

var _ = ioutil.NopCloser

// ShardDistributorAPIYARPCClient is the YARPC client-side interface for the ShardDistributorAPI service.
type ShardDistributorAPIYARPCClient interface {
	GetShardOwner(context.Context, *GetShardOwnerRequest, ...yarpc.CallOption) (*GetShardOwnerResponse, error)
}

func newShardDistributorAPIYARPCClient(clientConfig transport.ClientConfig, anyResolver jsonpb.AnyResolver, options ...protobuf.ClientOption) ShardDistributorAPIYARPCClient {
	return &_ShardDistributorAPIYARPCCaller{protobuf.NewStreamClient(
		protobuf.ClientParams{
			ServiceName:  "uber.cadence.sharddistributor.v1.ShardDistributorAPI",
			ClientConfig: clientConfig,
			AnyResolver:  anyResolver,
			Options:      options,
		},
	)}
}

// NewShardDistributorAPIYARPCClient builds a new YARPC client for the ShardDistributorAPI service.
func NewShardDistributorAPIYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) ShardDistributorAPIYARPCClient {
	return newShardDistributorAPIYARPCClient(clientConfig, nil, options...)
}

// ShardDistributorAPIYARPCServer is the YARPC server-side interface for the ShardDistributorAPI service.
type ShardDistributorAPIYARPCServer interface {
	GetShardOwner(context.Context, *GetShardOwnerRequest) (*GetShardOwnerResponse, error)
}

type buildShardDistributorAPIYARPCProceduresParams struct {
	Server      ShardDistributorAPIYARPCServer
	AnyResolver jsonpb.AnyResolver
}

func buildShardDistributorAPIYARPCProcedures(params buildShardDistributorAPIYARPCProceduresParams) []transport.Procedure {
	handler := &_ShardDistributorAPIYARPCHandler{params.Server}
	return protobuf.BuildProcedures(
		protobuf.BuildProceduresParams{
			ServiceName: "uber.cadence.sharddistributor.v1.ShardDistributorAPI",
			UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{
				{
					MethodName: "GetShardOwner",
					Handler: protobuf.NewUnaryHandler(
						protobuf.UnaryHandlerParams{
							Handle:      handler.GetShardOwner,
							NewRequest:  newShardDistributorAPIServiceGetShardOwnerYARPCRequest,
							AnyResolver: params.AnyResolver,
						},
					),
				},
			},
			OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{},
			StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{},
		},
	)
}

// BuildShardDistributorAPIYARPCProcedures prepares an implementation of the ShardDistributorAPI service for YARPC registration.
func BuildShardDistributorAPIYARPCProcedures(server ShardDistributorAPIYARPCServer) []transport.Procedure {
	return buildShardDistributorAPIYARPCProcedures(buildShardDistributorAPIYARPCProceduresParams{Server: server})
}

// FxShardDistributorAPIYARPCClientParams defines the input
// for NewFxShardDistributorAPIYARPCClient. It provides the
// paramaters to get a ShardDistributorAPIYARPCClient in an
// Fx application.
type FxShardDistributorAPIYARPCClientParams struct {
	fx.In

	Provider    yarpc.ClientConfig
	AnyResolver jsonpb.AnyResolver  `name:"yarpcfx" optional:"true"`
	Restriction restriction.Checker `optional:"true"`
}

// FxShardDistributorAPIYARPCClientResult defines the output
// of NewFxShardDistributorAPIYARPCClient. It provides a
// ShardDistributorAPIYARPCClient to an Fx application.
type FxShardDistributorAPIYARPCClientResult struct {
	fx.Out

	Client ShardDistributorAPIYARPCClient

	// We are using an fx.Out struct here instead of just returning a client
	// so that we can add more values or add named versions of the client in
	// the future without breaking any existing code.
}

// NewFxShardDistributorAPIYARPCClient provides a ShardDistributorAPIYARPCClient
// to an Fx application using the given name for routing.
//
//	fx.Provide(
//	  sharddistributorv1.NewFxShardDistributorAPIYARPCClient("service-name"),
//	  ...
//	)
func NewFxShardDistributorAPIYARPCClient(name string, options ...protobuf.ClientOption) interface{} {
	return func(params FxShardDistributorAPIYARPCClientParams) FxShardDistributorAPIYARPCClientResult {
		cc := params.Provider.ClientConfig(name)

		if params.Restriction != nil {
			if namer, ok := cc.GetUnaryOutbound().(transport.Namer); ok {
				if err := params.Restriction.Check(protobuf.Encoding, namer.TransportName()); err != nil {
					panic(err.Error())
				}
			}
		}

		return FxShardDistributorAPIYARPCClientResult{
			Client: newShardDistributorAPIYARPCClient(cc, params.AnyResolver, options...),
		}
	}
}

// FxShardDistributorAPIYARPCProceduresParams defines the input
// for NewFxShardDistributorAPIYARPCProcedures. It provides the
// paramaters to get ShardDistributorAPIYARPCServer procedures in an
// Fx application.
type FxShardDistributorAPIYARPCProceduresParams struct {
	fx.In

	Server      ShardDistributorAPIYARPCServer
	AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"`
}

// FxShardDistributorAPIYARPCProceduresResult defines the output
// of NewFxShardDistributorAPIYARPCProcedures. It provides
// ShardDistributorAPIYARPCServer procedures to an Fx application.
//
// The procedures are provided to the "yarpcfx" value group.
// Dig 1.2 or newer must be used for this feature to work.
type FxShardDistributorAPIYARPCProceduresResult struct {
	fx.Out

	Procedures     []transport.Procedure `group:"yarpcfx"`
	ReflectionMeta reflection.ServerMeta `group:"yarpcfx"`
}

// NewFxShardDistributorAPIYARPCProcedures provides ShardDistributorAPIYARPCServer procedures to an Fx application.
// It expects a ShardDistributorAPIYARPCServer to be present in the container.
//
//	fx.Provide(
//	  sharddistributorv1.NewFxShardDistributorAPIYARPCProcedures(),
//	  ...
//	)
func NewFxShardDistributorAPIYARPCProcedures() interface{} {
	return func(params FxShardDistributorAPIYARPCProceduresParams) FxShardDistributorAPIYARPCProceduresResult {
		return FxShardDistributorAPIYARPCProceduresResult{
			Procedures: buildShardDistributorAPIYARPCProcedures(buildShardDistributorAPIYARPCProceduresParams{
				Server:      params.Server,
				AnyResolver: params.AnyResolver,
			}),
			ReflectionMeta: ShardDistributorAPIReflectionMeta,
		}
	}
}

// ShardDistributorAPIReflectionMeta is the reflection server metadata
// required for using the gRPC reflection protocol with YARPC.
//
// See https://github.com/grpc/grpc/blob/master/doc/server-reflection.md.
var ShardDistributorAPIReflectionMeta = reflection.ServerMeta{
	ServiceName:     "uber.cadence.sharddistributor.v1.ShardDistributorAPI",
	FileDescriptors: yarpcFileDescriptorClosure0055bfd59dff1f95,
}

type _ShardDistributorAPIYARPCCaller struct {
	streamClient protobuf.StreamClient
}

func (c *_ShardDistributorAPIYARPCCaller) GetShardOwner(ctx context.Context, request *GetShardOwnerRequest, options ...yarpc.CallOption) (*GetShardOwnerResponse, error) {
	responseMessage, err := c.streamClient.Call(ctx, "GetShardOwner", request, newShardDistributorAPIServiceGetShardOwnerYARPCResponse, options...)
	if responseMessage == nil {
		return nil, err
	}
	response, ok := responseMessage.(*GetShardOwnerResponse)
	if !ok {
		return nil, protobuf.CastError(emptyShardDistributorAPIServiceGetShardOwnerYARPCResponse, responseMessage)
	}
	return response, err
}

type _ShardDistributorAPIYARPCHandler struct {
	server ShardDistributorAPIYARPCServer
}

func (h *_ShardDistributorAPIYARPCHandler) GetShardOwner(ctx context.Context, requestMessage proto.Message) (proto.Message, error) {
	var request *GetShardOwnerRequest
	var ok bool
	if requestMessage != nil {
		request, ok = requestMessage.(*GetShardOwnerRequest)
		if !ok {
			return nil, protobuf.CastError(emptyShardDistributorAPIServiceGetShardOwnerYARPCRequest, requestMessage)
		}
	}
	response, err := h.server.GetShardOwner(ctx, request)
	if response == nil {
		return nil, err
	}
	return response, err
}

func newShardDistributorAPIServiceGetShardOwnerYARPCRequest() proto.Message {
	return &GetShardOwnerRequest{}
}

func newShardDistributorAPIServiceGetShardOwnerYARPCResponse() proto.Message {
	return &GetShardOwnerResponse{}
}

var (
	emptyShardDistributorAPIServiceGetShardOwnerYARPCRequest  = &GetShardOwnerRequest{}
	emptyShardDistributorAPIServiceGetShardOwnerYARPCResponse = &GetShardOwnerResponse{}
)

var yarpcFileDescriptorClosure0055bfd59dff1f95 = [][]byte{
	// uber/cadence/sharddistributor/v1/service.proto
	[]byte{
		0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x4d, 0x4b, 0xc3, 0x40,
		0x14, 0x64, 0x0b, 0x8a, 0x79, 0xe0, 0x65, 0xad, 0x52, 0xd4, 0x43, 0xe9, 0xc9, 0xd3, 0x2e, 0x51,
		0xa8, 0x07, 0x4f, 0x8a, 0x1f, 0x94, 0x40, 0xab, 0xf5, 0xe6, 0x45, 0x92, 0xcd, 0xa3, 0x0d, 0xd2,
		0xdd, 0xb8, 0x1f, 0x91, 0xde, 0xfc, 0x19, 0xfe, 0x5c, 0xc9, 0xb6, 0xa5, 0x64, 0x29, 0x94, 0x1c,
		0x77, 0xde, 0xcc, 0xb0, 0x33, 0x0c, 0x30, 0x97, 0xa1, 0xe6, 0x22, 0xcd, 0x51, 0x0a, 0xe4, 0x66,
		0x9e, 0xea, 0x3c, 0x2f, 0x8c, 0xd5, 0x45, 0xe6, 0xac, 0xd2, 0xbc, 0x8a, 0xb9, 0x41, 0x5d, 0x15,
		0x02, 0x59, 0xa9, 0x95, 0x55, 0xb4, 0x5f, 0xf3, 0xd9, 0x9a, 0xcf, 0x42, 0x3e, 0xab, 0xe2, 0xc1,
		0x1b, 0x74, 0x5f, 0xd0, 0xbe, 0xd7, 0x97, 0xc9, 0x8f, 0x44, 0x3d, 0xc5, 0x6f, 0x87, 0xc6, 0xd2,
		0x0b, 0x88, 0x3c, 0xfd, 0xf3, 0x0b, 0x97, 0x3d, 0xd2, 0x27, 0x57, 0xd1, 0xf4, 0xc8, 0x03, 0x09,
		0x2e, 0xe9, 0x25, 0x44, 0x32, 0x5d, 0xa0, 0x29, 0x53, 0x81, 0xbd, 0x8e, 0x3f, 0x6e, 0x81, 0x41,
		0x02, 0xa7, 0x81, 0xa5, 0x29, 0x95, 0x34, 0x48, 0xbb, 0x70, 0xa0, 0x6a, 0x60, 0xed, 0xb7, 0x7a,
		0xec, 0x31, 0x1b, 0xc2, 0xd9, 0x78, 0xf3, 0x18, 0x2b, 0xfb, 0xac, 0x9c, 0xcc, 0x9f, 0xb4, 0x56,
		0x81, 0x8e, 0x84, 0xba, 0x09, 0x50, 0xff, 0x83, 0x16, 0x9a, 0x66, 0xe6, 0x4e, 0x33, 0xf3, 0xf5,
		0x1f, 0x81, 0x13, 0xef, 0xf8, 0xb8, 0x2d, 0xf0, 0xfe, 0x75, 0x44, 0x7f, 0x09, 0x1c, 0x37, 0xe2,
		0xd2, 0x21, 0xdb, 0xd7, 0x3a, 0xdb, 0x55, 0xf9, 0xf9, 0x6d, 0x6b, 0xdd, 0xaa, 0xd7, 0x87, 0xe4,
		0x63, 0x34, 0x2b, 0xec, 0xdc, 0x65, 0x4c, 0xa8, 0x05, 0x6f, 0x4c, 0x84, 0xcd, 0x50, 0x72, 0xbf,
		0x85, 0x5d, 0x6b, 0xb9, 0x0b, 0xb1, 0x2a, 0xce, 0x0e, 0x3d, 0xfb, 0xe6, 0x3f, 0x00, 0x00, 0xff,
		0xff, 0x22, 0xfe, 0xc8, 0x04, 0x6b, 0x02, 0x00, 0x00,
	},
}

func init() {
	yarpc.RegisterClientBuilder(
		func(clientConfig transport.ClientConfig, structField reflect.StructField) ShardDistributorAPIYARPCClient {
			return NewShardDistributorAPIYARPCClient(clientConfig, protobuf.ClientBuilderOptions(clientConfig, structField)...)
		},
	)
}
