func NewWorkflowHandler(
	resource resource.Resource,
	config *Config,
	replicationMessageSink messaging.Producer,
	versionChecker client.VersionChecker,
) *WorkflowHandler {
	return &WorkflowHandler{
		Resource:        resource,
		config:          config,
		healthStatus:    int32(HealthStatusWarmingUp),
		tokenSerializer: common.NewJSONTaskTokenSerializer(),
		userRateLimiter: quotas.NewMultiStageRateLimiter(
			quotas.NewDynamicRateLimiter(config.UserRPS.AsFloat64()),
			quotas.NewCollection(func(domain string) quotas.Limiter {
				return quotas.NewDynamicRateLimiter(quotas.PerMemberDynamic(
					service.Frontend,
					config.GlobalDomainUserRPS.AsFloat64(domain),
					config.MaxDomainUserRPSPerInstance.AsFloat64(domain),
					resource.GetMembershipResolver(),
				))
			}),
		),
		workerRateLimiter: quotas.NewMultiStageRateLimiter(
			quotas.NewDynamicRateLimiter(config.WorkerRPS.AsFloat64()),
			quotas.NewCollection(func(domain string) quotas.Limiter {
				return quotas.NewDynamicRateLimiter(quotas.PerMemberDynamic(
					service.Frontend,
					config.GlobalDomainWorkerRPS.AsFloat64(domain),
					config.MaxDomainWorkerRPSPerInstance.AsFloat64(domain),
					resource.GetMembershipResolver(),
				))
			}),
		),
		versionChecker: versionChecker,
		domainHandler: domain.NewHandler(
			config.domainConfig,
			resource.GetLogger(),
			resource.GetDomainManager(),
			resource.GetClusterMetadata(),
			domain.NewDomainReplicator(replicationMessageSink, resource.GetLogger()),
			resource.GetArchivalMetadata(),
			resource.GetArchiverProvider(),
			resource.GetTimeSource(),
		),
		visibilityQueryValidator: validator.NewQueryValidator(config.ValidSearchAttributes),
		searchAttributesValidator: validator.NewSearchAttributesValidator(
			resource.GetLogger(),
			config.ValidSearchAttributes,
			config.SearchAttributesNumberOfKeysLimit,
			config.SearchAttributesSizeOfValueLimit,
			config.SearchAttributesTotalSizeLimit,
		),
		throttleRetry: backoff.NewThrottleRetry(
			backoff.WithRetryPolicy(frontendServiceRetryPolicy),
			backoff.WithRetryableError(common.IsServiceTransientError),
		),
	}
}
// NewWorkflowHandler creates a thrift handler for the cadence service
NewWorkflowHandler creates a thrift handler for the cadence service
// NewWorkflowHandler creates a thrift handler for the cadence service
func NewWorkflowHandler(
	resource resource.Resource,
	config *Config,
	replicationMessageSink messaging.Producer,
	versionChecker client.VersionChecker,
) *WorkflowHandler {
	return &WorkflowHandler{
		Resource:        resource,
		config:          config,
		healthStatus:    int32(HealthStatusWarmingUp),
		tokenSerializer: common.NewJSONTaskTokenSerializer(),
		userRateLimiter: quotas.NewMultiStageRateLimiter(
			quotas.NewDynamicRateLimiter(config.UserRPS.AsFloat64()),
			quotas.NewCollection(func(domain string) quotas.Limiter {
				return quotas.NewDynamicRateLimiter(quotas.PerMemberDynamic(
					service.Frontend,
					config.GlobalDomainUserRPS.AsFloat64(domain),
					config.MaxDomainUserRPSPerInstance.AsFloat64(domain),
					resource.GetMembershipResolver(),
				))
			}),
		),
		workerRateLimiter: quotas.NewMultiStageRateLimiter(
			quotas.NewDynamicRateLimiter(config.WorkerRPS.AsFloat64()),
			quotas.NewCollection(func(domain string) quotas.Limiter {
				return quotas.NewDynamicRateLimiter(quotas.PerMemberDynamic(
					service.Frontend,
					config.GlobalDomainWorkerRPS.AsFloat64(domain),
					config.MaxDomainWorkerRPSPerInstance.AsFloat64(domain),
					resource.GetMembershipResolver(),
				))
			}),
		),
		versionChecker: versionChecker,
		domainHandler: domain.NewHandler(
			config.domainConfig,
			resource.GetLogger(),
			resource.GetDomainManager(),
			resource.GetClusterMetadata(),
			domain.NewDomainReplicator(replicationMessageSink, resource.GetLogger()),
			resource.GetArchivalMetadata(),
			resource.GetArchiverProvider(),
			resource.GetTimeSource(),
		),
		visibilityQueryValidator: validator.NewQueryValidator(config.ValidSearchAttributes),
		searchAttributesValidator: validator.NewSearchAttributesValidator(
			resource.GetLogger(),
			config.ValidSearchAttributes,
			config.SearchAttributesNumberOfKeysLimit,
			config.SearchAttributesSizeOfValueLimit,
			config.SearchAttributesTotalSizeLimit,
		),
		throttleRetry: backoff.NewThrottleRetry(
			backoff.WithRetryPolicy(frontendServiceRetryPolicy),
			backoff.WithRetryableError(common.IsServiceTransientError),
		),
	}
}
func NewWorkflowHandler ( resource resource . Resource , config * Config , replicationMessageSink messaging . Producer , versionChecker client . VersionChecker , ) * WorkflowHandler { return & WorkflowHandler { Resource : resource , config : config , healthStatus : int32 ( HealthStatusWarmingUp ) , tokenSerializer : common . NewJSONTaskTokenSerializer ( ) , userRateLimiter : quotas . NewMultiStageRateLimiter ( quotas . NewDynamicRateLimiter ( config . UserRPS . AsFloat64 ( ) ) , quotas . NewCollection ( func ( domain string ) quotas . Limiter { return quotas . NewDynamicRateLimiter ( quotas . PerMemberDynamic ( service . Frontend , config . GlobalDomainUserRPS . AsFloat64 ( domain ) , config . MaxDomainUserRPSPerInstance . AsFloat64 ( domain ) , resource . GetMembershipResolver ( ) , ) ) } ) , ) , workerRateLimiter : quotas . NewMultiStageRateLimiter ( quotas . NewDynamicRateLimiter ( config . WorkerRPS . AsFloat64 ( ) ) , quotas . NewCollection ( func ( domain string ) quotas . Limiter { return quotas . NewDynamicRateLimiter ( quotas . PerMemberDynamic ( service . Frontend , config . GlobalDomainWorkerRPS . AsFloat64 ( domain ) , config . MaxDomainWorkerRPSPerInstance . AsFloat64 ( domain ) , resource . GetMembershipResolver ( ) , ) ) } ) , ) , versionChecker : versionChecker , domainHandler : domain . NewHandler ( config . domainConfig , resource . GetLogger ( ) , resource . GetDomainManager ( ) , resource . GetClusterMetadata ( ) , domain . NewDomainReplicator ( replicationMessageSink , resource . GetLogger ( ) ) , resource . GetArchivalMetadata ( ) , resource . GetArchiverProvider ( ) , resource . GetTimeSource ( ) , ) , visibilityQueryValidator : validator . NewQueryValidator ( config . ValidSearchAttributes ) , searchAttributesValidator : validator . NewSearchAttributesValidator ( resource . GetLogger ( ) , config . ValidSearchAttributes , config . SearchAttributesNumberOfKeysLimit , config . SearchAttributesSizeOfValueLimit , config . SearchAttributesTotalSizeLimit , ) , throttleRetry : backoff . NewThrottleRetry ( backoff . WithRetryPolicy ( frontendServiceRetryPolicy ) , backoff . WithRetryableError ( common . IsServiceTransientError ) , ) , } }
NewWorkflowHandler creates a thrift handler for the cadence service
NewWorkflowHandler creates a thrift handler for the cadence service