// Code generated by thriftrw-plugin-yarpc
// @generated

package matchingserviceserver

import (
	context "context"

	stream "go.uber.org/thriftrw/protocol/stream"
	wire "go.uber.org/thriftrw/wire"
	transport "go.uber.org/yarpc/api/transport"
	thrift "go.uber.org/yarpc/encoding/thrift"
	yarpcerrors "go.uber.org/yarpc/yarpcerrors"

	matching "github.com/uber/cadence/.gen/go/matching"
	shared "github.com/uber/cadence/.gen/go/shared"
)

// Interface is the server-side interface for the MatchingService service.
type Interface interface {
	AddActivityTask(
		ctx context.Context,
		AddRequest *matching.AddActivityTaskRequest,
	) error

	AddDecisionTask(
		ctx context.Context,
		AddRequest *matching.AddDecisionTaskRequest,
	) error

	CancelOutstandingPoll(
		ctx context.Context,
		Request *matching.CancelOutstandingPollRequest,
	) error

	DescribeTaskList(
		ctx context.Context,
		Request *matching.DescribeTaskListRequest,
	) (*shared.DescribeTaskListResponse, error)

	GetTaskListsByDomain(
		ctx context.Context,
		Request *shared.GetTaskListsByDomainRequest,
	) (*shared.GetTaskListsByDomainResponse, error)

	ListTaskListPartitions(
		ctx context.Context,
		Request *matching.ListTaskListPartitionsRequest,
	) (*shared.ListTaskListPartitionsResponse, error)

	PollForActivityTask(
		ctx context.Context,
		PollRequest *matching.PollForActivityTaskRequest,
	) (*shared.PollForActivityTaskResponse, error)

	PollForDecisionTask(
		ctx context.Context,
		PollRequest *matching.PollForDecisionTaskRequest,
	) (*matching.PollForDecisionTaskResponse, error)

	QueryWorkflow(
		ctx context.Context,
		QueryRequest *matching.QueryWorkflowRequest,
	) (*shared.QueryWorkflowResponse, error)

	RespondQueryTaskCompleted(
		ctx context.Context,
		Request *matching.RespondQueryTaskCompletedRequest,
	) error
}

// New prepares an implementation of the MatchingService service for
// registration.
//
//	handler := MatchingServiceHandler{}
//	dispatcher.Register(matchingserviceserver.New(handler))
func New(impl Interface, opts ...thrift.RegisterOption) []transport.Procedure {
	h := handler{impl}
	service := thrift.Service{
		Name: "MatchingService",
		Methods: []thrift.Method{

			thrift.Method{
				Name: "AddActivityTask",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.AddActivityTask),
					NoWire: addactivitytask_NoWireHandler{impl},
				},
				Signature:    "AddActivityTask(AddRequest *matching.AddActivityTaskRequest)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "AddDecisionTask",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.AddDecisionTask),
					NoWire: adddecisiontask_NoWireHandler{impl},
				},
				Signature:    "AddDecisionTask(AddRequest *matching.AddDecisionTaskRequest)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "CancelOutstandingPoll",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.CancelOutstandingPoll),
					NoWire: canceloutstandingpoll_NoWireHandler{impl},
				},
				Signature:    "CancelOutstandingPoll(Request *matching.CancelOutstandingPollRequest)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "DescribeTaskList",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.DescribeTaskList),
					NoWire: describetasklist_NoWireHandler{impl},
				},
				Signature:    "DescribeTaskList(Request *matching.DescribeTaskListRequest) (*shared.DescribeTaskListResponse)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "GetTaskListsByDomain",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.GetTaskListsByDomain),
					NoWire: gettasklistsbydomain_NoWireHandler{impl},
				},
				Signature:    "GetTaskListsByDomain(Request *shared.GetTaskListsByDomainRequest) (*shared.GetTaskListsByDomainResponse)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "ListTaskListPartitions",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.ListTaskListPartitions),
					NoWire: listtasklistpartitions_NoWireHandler{impl},
				},
				Signature:    "ListTaskListPartitions(Request *matching.ListTaskListPartitionsRequest) (*shared.ListTaskListPartitionsResponse)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "PollForActivityTask",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.PollForActivityTask),
					NoWire: pollforactivitytask_NoWireHandler{impl},
				},
				Signature:    "PollForActivityTask(PollRequest *matching.PollForActivityTaskRequest) (*shared.PollForActivityTaskResponse)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "PollForDecisionTask",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.PollForDecisionTask),
					NoWire: pollfordecisiontask_NoWireHandler{impl},
				},
				Signature:    "PollForDecisionTask(PollRequest *matching.PollForDecisionTaskRequest) (*matching.PollForDecisionTaskResponse)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "QueryWorkflow",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.QueryWorkflow),
					NoWire: queryworkflow_NoWireHandler{impl},
				},
				Signature:    "QueryWorkflow(QueryRequest *matching.QueryWorkflowRequest) (*shared.QueryWorkflowResponse)",
				ThriftModule: matching.ThriftModule,
			},

			thrift.Method{
				Name: "RespondQueryTaskCompleted",
				HandlerSpec: thrift.HandlerSpec{

					Type:   transport.Unary,
					Unary:  thrift.UnaryHandler(h.RespondQueryTaskCompleted),
					NoWire: respondquerytaskcompleted_NoWireHandler{impl},
				},
				Signature:    "RespondQueryTaskCompleted(Request *matching.RespondQueryTaskCompletedRequest)",
				ThriftModule: matching.ThriftModule,
			},
		},
	}

	procedures := make([]transport.Procedure, 0, 10)
	procedures = append(procedures, thrift.BuildProcedures(service, opts...)...)
	return procedures
}

type handler struct{ impl Interface }

type yarpcErrorNamer interface{ YARPCErrorName() string }

type yarpcErrorCoder interface{ YARPCErrorCode() *yarpcerrors.Code }

func (h handler) AddActivityTask(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_AddActivityTask_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'AddActivityTask': %w", err)
	}

	appErr := h.impl.AddActivityTask(ctx, args.AddRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_AddActivityTask_Helper.WrapResponse(appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) AddDecisionTask(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_AddDecisionTask_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'AddDecisionTask': %w", err)
	}

	appErr := h.impl.AddDecisionTask(ctx, args.AddRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_AddDecisionTask_Helper.WrapResponse(appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) CancelOutstandingPoll(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_CancelOutstandingPoll_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'CancelOutstandingPoll': %w", err)
	}

	appErr := h.impl.CancelOutstandingPoll(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_CancelOutstandingPoll_Helper.WrapResponse(appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) DescribeTaskList(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_DescribeTaskList_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'DescribeTaskList': %w", err)
	}

	success, appErr := h.impl.DescribeTaskList(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_DescribeTaskList_Helper.WrapResponse(success, appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) GetTaskListsByDomain(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_GetTaskListsByDomain_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'GetTaskListsByDomain': %w", err)
	}

	success, appErr := h.impl.GetTaskListsByDomain(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_GetTaskListsByDomain_Helper.WrapResponse(success, appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) ListTaskListPartitions(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_ListTaskListPartitions_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'ListTaskListPartitions': %w", err)
	}

	success, appErr := h.impl.ListTaskListPartitions(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_ListTaskListPartitions_Helper.WrapResponse(success, appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) PollForActivityTask(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_PollForActivityTask_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'PollForActivityTask': %w", err)
	}

	success, appErr := h.impl.PollForActivityTask(ctx, args.PollRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_PollForActivityTask_Helper.WrapResponse(success, appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) PollForDecisionTask(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_PollForDecisionTask_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'PollForDecisionTask': %w", err)
	}

	success, appErr := h.impl.PollForDecisionTask(ctx, args.PollRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_PollForDecisionTask_Helper.WrapResponse(success, appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) QueryWorkflow(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_QueryWorkflow_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'QueryWorkflow': %w", err)
	}

	success, appErr := h.impl.QueryWorkflow(ctx, args.QueryRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_QueryWorkflow_Helper.WrapResponse(success, appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

func (h handler) RespondQueryTaskCompleted(ctx context.Context, body wire.Value) (thrift.Response, error) {
	var args matching.MatchingService_RespondQueryTaskCompleted_Args
	if err := args.FromWire(body); err != nil {
		return thrift.Response{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode Thrift request for service 'MatchingService' procedure 'RespondQueryTaskCompleted': %w", err)
	}

	appErr := h.impl.RespondQueryTaskCompleted(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_RespondQueryTaskCompleted_Helper.WrapResponse(appErr)

	var response thrift.Response
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}

	return response, err
}

type addactivitytask_NoWireHandler struct{ impl Interface }

func (h addactivitytask_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_AddActivityTask_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'AddActivityTask': %w", err)
	}

	appErr := h.impl.AddActivityTask(ctx, args.AddRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_AddActivityTask_Helper.WrapResponse(appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type adddecisiontask_NoWireHandler struct{ impl Interface }

func (h adddecisiontask_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_AddDecisionTask_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'AddDecisionTask': %w", err)
	}

	appErr := h.impl.AddDecisionTask(ctx, args.AddRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_AddDecisionTask_Helper.WrapResponse(appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type canceloutstandingpoll_NoWireHandler struct{ impl Interface }

func (h canceloutstandingpoll_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_CancelOutstandingPoll_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'CancelOutstandingPoll': %w", err)
	}

	appErr := h.impl.CancelOutstandingPoll(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_CancelOutstandingPoll_Helper.WrapResponse(appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type describetasklist_NoWireHandler struct{ impl Interface }

func (h describetasklist_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_DescribeTaskList_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'DescribeTaskList': %w", err)
	}

	success, appErr := h.impl.DescribeTaskList(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_DescribeTaskList_Helper.WrapResponse(success, appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type gettasklistsbydomain_NoWireHandler struct{ impl Interface }

func (h gettasklistsbydomain_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_GetTaskListsByDomain_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'GetTaskListsByDomain': %w", err)
	}

	success, appErr := h.impl.GetTaskListsByDomain(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_GetTaskListsByDomain_Helper.WrapResponse(success, appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type listtasklistpartitions_NoWireHandler struct{ impl Interface }

func (h listtasklistpartitions_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_ListTaskListPartitions_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'ListTaskListPartitions': %w", err)
	}

	success, appErr := h.impl.ListTaskListPartitions(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_ListTaskListPartitions_Helper.WrapResponse(success, appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type pollforactivitytask_NoWireHandler struct{ impl Interface }

func (h pollforactivitytask_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_PollForActivityTask_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'PollForActivityTask': %w", err)
	}

	success, appErr := h.impl.PollForActivityTask(ctx, args.PollRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_PollForActivityTask_Helper.WrapResponse(success, appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type pollfordecisiontask_NoWireHandler struct{ impl Interface }

func (h pollfordecisiontask_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_PollForDecisionTask_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'PollForDecisionTask': %w", err)
	}

	success, appErr := h.impl.PollForDecisionTask(ctx, args.PollRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_PollForDecisionTask_Helper.WrapResponse(success, appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type queryworkflow_NoWireHandler struct{ impl Interface }

func (h queryworkflow_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_QueryWorkflow_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'QueryWorkflow': %w", err)
	}

	success, appErr := h.impl.QueryWorkflow(ctx, args.QueryRequest)

	hadError := appErr != nil
	result, err := matching.MatchingService_QueryWorkflow_Helper.WrapResponse(success, appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}

type respondquerytaskcompleted_NoWireHandler struct{ impl Interface }

func (h respondquerytaskcompleted_NoWireHandler) HandleNoWire(ctx context.Context, nwc *thrift.NoWireCall) (thrift.NoWireResponse, error) {
	var (
		args matching.MatchingService_RespondQueryTaskCompleted_Args
		rw   stream.ResponseWriter
		err  error
	)

	rw, err = nwc.RequestReader.ReadRequest(ctx, nwc.EnvelopeType, nwc.Reader, &args)
	if err != nil {
		return thrift.NoWireResponse{}, yarpcerrors.InvalidArgumentErrorf(
			"could not decode (via no wire) Thrift request for service 'MatchingService' procedure 'RespondQueryTaskCompleted': %w", err)
	}

	appErr := h.impl.RespondQueryTaskCompleted(ctx, args.Request)

	hadError := appErr != nil
	result, err := matching.MatchingService_RespondQueryTaskCompleted_Helper.WrapResponse(appErr)
	response := thrift.NoWireResponse{ResponseWriter: rw}
	if err == nil {
		response.IsApplicationError = hadError
		response.Body = result
		if namer, ok := appErr.(yarpcErrorNamer); ok {
			response.ApplicationErrorName = namer.YARPCErrorName()
		}
		if extractor, ok := appErr.(yarpcErrorCoder); ok {
			response.ApplicationErrorCode = extractor.YARPCErrorCode()
		}
		if appErr != nil {
			response.ApplicationErrorDetails = appErr.Error()
		}
	}
	return response, err

}
