mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? - Add Subscribe method to dynamic config settings. - Support efficient notifications from FileBasedClient (old+new files are diffed and only changed keys are checked for subscriptions). - Move benchmark code to new file. - Change constrained defaults to pointer to slice since it's hardly ever used. ## Why? So that components can get notified on dynamic config changes instead of polling. ## How did you test it? unit tests
1403 lines
52 KiB
Go
1403 lines
52 KiB
Go
// The MIT License
|
|
//
|
|
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
|
|
//
|
|
// Copyright (c) 2020 Uber Technologies, Inc.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
// in the Software without restriction, including without limitation the rights
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
// THE SOFTWARE.
|
|
|
|
// Code generated by cmd/tools/gendynamicconfig. DO NOT EDIT.
|
|
|
|
package dynamicconfig
|
|
|
|
import (
|
|
"time"
|
|
|
|
enumspb "go.temporal.io/api/enums/v1"
|
|
enumsspb "go.temporal.io/server/api/enums/v1"
|
|
)
|
|
|
|
const PrecedenceUnknown Precedence = 0
|
|
|
|
const PrecedenceGlobal Precedence = 1
|
|
|
|
const PrecedenceNamespace Precedence = 2
|
|
|
|
const PrecedenceNamespaceID Precedence = 3
|
|
|
|
const PrecedenceTaskQueue Precedence = 4
|
|
|
|
const PrecedenceShardID Precedence = 5
|
|
|
|
const PrecedenceTaskType Precedence = 6
|
|
|
|
const PrecedenceDestination Precedence = 7
|
|
|
|
type GlobalBoolSetting = GlobalTypedSetting[bool]
|
|
|
|
func NewGlobalBoolSetting(key Key, def bool, description string) GlobalBoolSetting {
|
|
return NewGlobalTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewGlobalBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) GlobalBoolSetting {
|
|
return NewGlobalTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFn = TypedPropertyFn[bool]
|
|
|
|
func GetBoolPropertyFn(value bool) BoolPropertyFn {
|
|
return GetTypedPropertyFn(value)
|
|
}
|
|
|
|
type NamespaceBoolSetting = NamespaceTypedSetting[bool]
|
|
|
|
func NewNamespaceBoolSetting(key Key, def bool, description string) NamespaceBoolSetting {
|
|
return NewNamespaceTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewNamespaceBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) NamespaceBoolSetting {
|
|
return NewNamespaceTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[bool]
|
|
|
|
func GetBoolPropertyFnFilteredByNamespace(value bool) BoolPropertyFnWithNamespaceFilter {
|
|
return GetTypedPropertyFnFilteredByNamespace(value)
|
|
}
|
|
|
|
type NamespaceIDBoolSetting = NamespaceIDTypedSetting[bool]
|
|
|
|
func NewNamespaceIDBoolSetting(key Key, def bool, description string) NamespaceIDBoolSetting {
|
|
return NewNamespaceIDTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewNamespaceIDBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) NamespaceIDBoolSetting {
|
|
return NewNamespaceIDTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFnWithNamespaceIDFilter = TypedPropertyFnWithNamespaceIDFilter[bool]
|
|
|
|
func GetBoolPropertyFnFilteredByNamespaceID(value bool) BoolPropertyFnWithNamespaceIDFilter {
|
|
return GetTypedPropertyFnFilteredByNamespaceID(value)
|
|
}
|
|
|
|
type TaskQueueBoolSetting = TaskQueueTypedSetting[bool]
|
|
|
|
func NewTaskQueueBoolSetting(key Key, def bool, description string) TaskQueueBoolSetting {
|
|
return NewTaskQueueTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewTaskQueueBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) TaskQueueBoolSetting {
|
|
return NewTaskQueueTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[bool]
|
|
|
|
func GetBoolPropertyFnFilteredByTaskQueue(value bool) BoolPropertyFnWithTaskQueueFilter {
|
|
return GetTypedPropertyFnFilteredByTaskQueue(value)
|
|
}
|
|
|
|
type ShardIDBoolSetting = ShardIDTypedSetting[bool]
|
|
|
|
func NewShardIDBoolSetting(key Key, def bool, description string) ShardIDBoolSetting {
|
|
return NewShardIDTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewShardIDBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) ShardIDBoolSetting {
|
|
return NewShardIDTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFnWithShardIDFilter = TypedPropertyFnWithShardIDFilter[bool]
|
|
|
|
func GetBoolPropertyFnFilteredByShardID(value bool) BoolPropertyFnWithShardIDFilter {
|
|
return GetTypedPropertyFnFilteredByShardID(value)
|
|
}
|
|
|
|
type TaskTypeBoolSetting = TaskTypeTypedSetting[bool]
|
|
|
|
func NewTaskTypeBoolSetting(key Key, def bool, description string) TaskTypeBoolSetting {
|
|
return NewTaskTypeTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewTaskTypeBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) TaskTypeBoolSetting {
|
|
return NewTaskTypeTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFnWithTaskTypeFilter = TypedPropertyFnWithTaskTypeFilter[bool]
|
|
|
|
func GetBoolPropertyFnFilteredByTaskType(value bool) BoolPropertyFnWithTaskTypeFilter {
|
|
return GetTypedPropertyFnFilteredByTaskType(value)
|
|
}
|
|
|
|
type DestinationBoolSetting = DestinationTypedSetting[bool]
|
|
|
|
func NewDestinationBoolSetting(key Key, def bool, description string) DestinationBoolSetting {
|
|
return NewDestinationTypedSettingWithConverter[bool](key, convertBool, def, description)
|
|
}
|
|
|
|
func NewDestinationBoolSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[bool], description string) DestinationBoolSetting {
|
|
return NewDestinationTypedSettingWithConstrainedDefault[bool](key, convertBool, cdef, description)
|
|
}
|
|
|
|
type BoolPropertyFnWithDestinationFilter = TypedPropertyFnWithDestinationFilter[bool]
|
|
|
|
func GetBoolPropertyFnFilteredByDestination(value bool) BoolPropertyFnWithDestinationFilter {
|
|
return GetTypedPropertyFnFilteredByDestination(value)
|
|
}
|
|
|
|
type GlobalIntSetting = GlobalTypedSetting[int]
|
|
|
|
func NewGlobalIntSetting(key Key, def int, description string) GlobalIntSetting {
|
|
return NewGlobalTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewGlobalIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) GlobalIntSetting {
|
|
return NewGlobalTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFn = TypedPropertyFn[int]
|
|
|
|
func GetIntPropertyFn(value int) IntPropertyFn {
|
|
return GetTypedPropertyFn(value)
|
|
}
|
|
|
|
type NamespaceIntSetting = NamespaceTypedSetting[int]
|
|
|
|
func NewNamespaceIntSetting(key Key, def int, description string) NamespaceIntSetting {
|
|
return NewNamespaceTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewNamespaceIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) NamespaceIntSetting {
|
|
return NewNamespaceTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[int]
|
|
|
|
func GetIntPropertyFnFilteredByNamespace(value int) IntPropertyFnWithNamespaceFilter {
|
|
return GetTypedPropertyFnFilteredByNamespace(value)
|
|
}
|
|
|
|
type NamespaceIDIntSetting = NamespaceIDTypedSetting[int]
|
|
|
|
func NewNamespaceIDIntSetting(key Key, def int, description string) NamespaceIDIntSetting {
|
|
return NewNamespaceIDTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewNamespaceIDIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) NamespaceIDIntSetting {
|
|
return NewNamespaceIDTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFnWithNamespaceIDFilter = TypedPropertyFnWithNamespaceIDFilter[int]
|
|
|
|
func GetIntPropertyFnFilteredByNamespaceID(value int) IntPropertyFnWithNamespaceIDFilter {
|
|
return GetTypedPropertyFnFilteredByNamespaceID(value)
|
|
}
|
|
|
|
type TaskQueueIntSetting = TaskQueueTypedSetting[int]
|
|
|
|
func NewTaskQueueIntSetting(key Key, def int, description string) TaskQueueIntSetting {
|
|
return NewTaskQueueTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewTaskQueueIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) TaskQueueIntSetting {
|
|
return NewTaskQueueTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[int]
|
|
|
|
func GetIntPropertyFnFilteredByTaskQueue(value int) IntPropertyFnWithTaskQueueFilter {
|
|
return GetTypedPropertyFnFilteredByTaskQueue(value)
|
|
}
|
|
|
|
type ShardIDIntSetting = ShardIDTypedSetting[int]
|
|
|
|
func NewShardIDIntSetting(key Key, def int, description string) ShardIDIntSetting {
|
|
return NewShardIDTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewShardIDIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) ShardIDIntSetting {
|
|
return NewShardIDTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFnWithShardIDFilter = TypedPropertyFnWithShardIDFilter[int]
|
|
|
|
func GetIntPropertyFnFilteredByShardID(value int) IntPropertyFnWithShardIDFilter {
|
|
return GetTypedPropertyFnFilteredByShardID(value)
|
|
}
|
|
|
|
type TaskTypeIntSetting = TaskTypeTypedSetting[int]
|
|
|
|
func NewTaskTypeIntSetting(key Key, def int, description string) TaskTypeIntSetting {
|
|
return NewTaskTypeTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewTaskTypeIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) TaskTypeIntSetting {
|
|
return NewTaskTypeTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFnWithTaskTypeFilter = TypedPropertyFnWithTaskTypeFilter[int]
|
|
|
|
func GetIntPropertyFnFilteredByTaskType(value int) IntPropertyFnWithTaskTypeFilter {
|
|
return GetTypedPropertyFnFilteredByTaskType(value)
|
|
}
|
|
|
|
type DestinationIntSetting = DestinationTypedSetting[int]
|
|
|
|
func NewDestinationIntSetting(key Key, def int, description string) DestinationIntSetting {
|
|
return NewDestinationTypedSettingWithConverter[int](key, convertInt, def, description)
|
|
}
|
|
|
|
func NewDestinationIntSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[int], description string) DestinationIntSetting {
|
|
return NewDestinationTypedSettingWithConstrainedDefault[int](key, convertInt, cdef, description)
|
|
}
|
|
|
|
type IntPropertyFnWithDestinationFilter = TypedPropertyFnWithDestinationFilter[int]
|
|
|
|
func GetIntPropertyFnFilteredByDestination(value int) IntPropertyFnWithDestinationFilter {
|
|
return GetTypedPropertyFnFilteredByDestination(value)
|
|
}
|
|
|
|
type GlobalFloatSetting = GlobalTypedSetting[float64]
|
|
|
|
func NewGlobalFloatSetting(key Key, def float64, description string) GlobalFloatSetting {
|
|
return NewGlobalTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewGlobalFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) GlobalFloatSetting {
|
|
return NewGlobalTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFn = TypedPropertyFn[float64]
|
|
|
|
func GetFloatPropertyFn(value float64) FloatPropertyFn {
|
|
return GetTypedPropertyFn(value)
|
|
}
|
|
|
|
type NamespaceFloatSetting = NamespaceTypedSetting[float64]
|
|
|
|
func NewNamespaceFloatSetting(key Key, def float64, description string) NamespaceFloatSetting {
|
|
return NewNamespaceTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewNamespaceFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) NamespaceFloatSetting {
|
|
return NewNamespaceTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[float64]
|
|
|
|
func GetFloatPropertyFnFilteredByNamespace(value float64) FloatPropertyFnWithNamespaceFilter {
|
|
return GetTypedPropertyFnFilteredByNamespace(value)
|
|
}
|
|
|
|
type NamespaceIDFloatSetting = NamespaceIDTypedSetting[float64]
|
|
|
|
func NewNamespaceIDFloatSetting(key Key, def float64, description string) NamespaceIDFloatSetting {
|
|
return NewNamespaceIDTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewNamespaceIDFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) NamespaceIDFloatSetting {
|
|
return NewNamespaceIDTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFnWithNamespaceIDFilter = TypedPropertyFnWithNamespaceIDFilter[float64]
|
|
|
|
func GetFloatPropertyFnFilteredByNamespaceID(value float64) FloatPropertyFnWithNamespaceIDFilter {
|
|
return GetTypedPropertyFnFilteredByNamespaceID(value)
|
|
}
|
|
|
|
type TaskQueueFloatSetting = TaskQueueTypedSetting[float64]
|
|
|
|
func NewTaskQueueFloatSetting(key Key, def float64, description string) TaskQueueFloatSetting {
|
|
return NewTaskQueueTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewTaskQueueFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) TaskQueueFloatSetting {
|
|
return NewTaskQueueTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[float64]
|
|
|
|
func GetFloatPropertyFnFilteredByTaskQueue(value float64) FloatPropertyFnWithTaskQueueFilter {
|
|
return GetTypedPropertyFnFilteredByTaskQueue(value)
|
|
}
|
|
|
|
type ShardIDFloatSetting = ShardIDTypedSetting[float64]
|
|
|
|
func NewShardIDFloatSetting(key Key, def float64, description string) ShardIDFloatSetting {
|
|
return NewShardIDTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewShardIDFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) ShardIDFloatSetting {
|
|
return NewShardIDTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFnWithShardIDFilter = TypedPropertyFnWithShardIDFilter[float64]
|
|
|
|
func GetFloatPropertyFnFilteredByShardID(value float64) FloatPropertyFnWithShardIDFilter {
|
|
return GetTypedPropertyFnFilteredByShardID(value)
|
|
}
|
|
|
|
type TaskTypeFloatSetting = TaskTypeTypedSetting[float64]
|
|
|
|
func NewTaskTypeFloatSetting(key Key, def float64, description string) TaskTypeFloatSetting {
|
|
return NewTaskTypeTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewTaskTypeFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) TaskTypeFloatSetting {
|
|
return NewTaskTypeTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFnWithTaskTypeFilter = TypedPropertyFnWithTaskTypeFilter[float64]
|
|
|
|
func GetFloatPropertyFnFilteredByTaskType(value float64) FloatPropertyFnWithTaskTypeFilter {
|
|
return GetTypedPropertyFnFilteredByTaskType(value)
|
|
}
|
|
|
|
type DestinationFloatSetting = DestinationTypedSetting[float64]
|
|
|
|
func NewDestinationFloatSetting(key Key, def float64, description string) DestinationFloatSetting {
|
|
return NewDestinationTypedSettingWithConverter[float64](key, convertFloat, def, description)
|
|
}
|
|
|
|
func NewDestinationFloatSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[float64], description string) DestinationFloatSetting {
|
|
return NewDestinationTypedSettingWithConstrainedDefault[float64](key, convertFloat, cdef, description)
|
|
}
|
|
|
|
type FloatPropertyFnWithDestinationFilter = TypedPropertyFnWithDestinationFilter[float64]
|
|
|
|
func GetFloatPropertyFnFilteredByDestination(value float64) FloatPropertyFnWithDestinationFilter {
|
|
return GetTypedPropertyFnFilteredByDestination(value)
|
|
}
|
|
|
|
type GlobalStringSetting = GlobalTypedSetting[string]
|
|
|
|
func NewGlobalStringSetting(key Key, def string, description string) GlobalStringSetting {
|
|
return NewGlobalTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewGlobalStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) GlobalStringSetting {
|
|
return NewGlobalTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFn = TypedPropertyFn[string]
|
|
|
|
func GetStringPropertyFn(value string) StringPropertyFn {
|
|
return GetTypedPropertyFn(value)
|
|
}
|
|
|
|
type NamespaceStringSetting = NamespaceTypedSetting[string]
|
|
|
|
func NewNamespaceStringSetting(key Key, def string, description string) NamespaceStringSetting {
|
|
return NewNamespaceTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewNamespaceStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) NamespaceStringSetting {
|
|
return NewNamespaceTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[string]
|
|
|
|
func GetStringPropertyFnFilteredByNamespace(value string) StringPropertyFnWithNamespaceFilter {
|
|
return GetTypedPropertyFnFilteredByNamespace(value)
|
|
}
|
|
|
|
type NamespaceIDStringSetting = NamespaceIDTypedSetting[string]
|
|
|
|
func NewNamespaceIDStringSetting(key Key, def string, description string) NamespaceIDStringSetting {
|
|
return NewNamespaceIDTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewNamespaceIDStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) NamespaceIDStringSetting {
|
|
return NewNamespaceIDTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFnWithNamespaceIDFilter = TypedPropertyFnWithNamespaceIDFilter[string]
|
|
|
|
func GetStringPropertyFnFilteredByNamespaceID(value string) StringPropertyFnWithNamespaceIDFilter {
|
|
return GetTypedPropertyFnFilteredByNamespaceID(value)
|
|
}
|
|
|
|
type TaskQueueStringSetting = TaskQueueTypedSetting[string]
|
|
|
|
func NewTaskQueueStringSetting(key Key, def string, description string) TaskQueueStringSetting {
|
|
return NewTaskQueueTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewTaskQueueStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) TaskQueueStringSetting {
|
|
return NewTaskQueueTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[string]
|
|
|
|
func GetStringPropertyFnFilteredByTaskQueue(value string) StringPropertyFnWithTaskQueueFilter {
|
|
return GetTypedPropertyFnFilteredByTaskQueue(value)
|
|
}
|
|
|
|
type ShardIDStringSetting = ShardIDTypedSetting[string]
|
|
|
|
func NewShardIDStringSetting(key Key, def string, description string) ShardIDStringSetting {
|
|
return NewShardIDTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewShardIDStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) ShardIDStringSetting {
|
|
return NewShardIDTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFnWithShardIDFilter = TypedPropertyFnWithShardIDFilter[string]
|
|
|
|
func GetStringPropertyFnFilteredByShardID(value string) StringPropertyFnWithShardIDFilter {
|
|
return GetTypedPropertyFnFilteredByShardID(value)
|
|
}
|
|
|
|
type TaskTypeStringSetting = TaskTypeTypedSetting[string]
|
|
|
|
func NewTaskTypeStringSetting(key Key, def string, description string) TaskTypeStringSetting {
|
|
return NewTaskTypeTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewTaskTypeStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) TaskTypeStringSetting {
|
|
return NewTaskTypeTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFnWithTaskTypeFilter = TypedPropertyFnWithTaskTypeFilter[string]
|
|
|
|
func GetStringPropertyFnFilteredByTaskType(value string) StringPropertyFnWithTaskTypeFilter {
|
|
return GetTypedPropertyFnFilteredByTaskType(value)
|
|
}
|
|
|
|
type DestinationStringSetting = DestinationTypedSetting[string]
|
|
|
|
func NewDestinationStringSetting(key Key, def string, description string) DestinationStringSetting {
|
|
return NewDestinationTypedSettingWithConverter[string](key, convertString, def, description)
|
|
}
|
|
|
|
func NewDestinationStringSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[string], description string) DestinationStringSetting {
|
|
return NewDestinationTypedSettingWithConstrainedDefault[string](key, convertString, cdef, description)
|
|
}
|
|
|
|
type StringPropertyFnWithDestinationFilter = TypedPropertyFnWithDestinationFilter[string]
|
|
|
|
func GetStringPropertyFnFilteredByDestination(value string) StringPropertyFnWithDestinationFilter {
|
|
return GetTypedPropertyFnFilteredByDestination(value)
|
|
}
|
|
|
|
type GlobalDurationSetting = GlobalTypedSetting[time.Duration]
|
|
|
|
func NewGlobalDurationSetting(key Key, def time.Duration, description string) GlobalDurationSetting {
|
|
return NewGlobalTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewGlobalDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) GlobalDurationSetting {
|
|
return NewGlobalTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFn = TypedPropertyFn[time.Duration]
|
|
|
|
func GetDurationPropertyFn(value time.Duration) DurationPropertyFn {
|
|
return GetTypedPropertyFn(value)
|
|
}
|
|
|
|
type NamespaceDurationSetting = NamespaceTypedSetting[time.Duration]
|
|
|
|
func NewNamespaceDurationSetting(key Key, def time.Duration, description string) NamespaceDurationSetting {
|
|
return NewNamespaceTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewNamespaceDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) NamespaceDurationSetting {
|
|
return NewNamespaceTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[time.Duration]
|
|
|
|
func GetDurationPropertyFnFilteredByNamespace(value time.Duration) DurationPropertyFnWithNamespaceFilter {
|
|
return GetTypedPropertyFnFilteredByNamespace(value)
|
|
}
|
|
|
|
type NamespaceIDDurationSetting = NamespaceIDTypedSetting[time.Duration]
|
|
|
|
func NewNamespaceIDDurationSetting(key Key, def time.Duration, description string) NamespaceIDDurationSetting {
|
|
return NewNamespaceIDTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewNamespaceIDDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) NamespaceIDDurationSetting {
|
|
return NewNamespaceIDTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFnWithNamespaceIDFilter = TypedPropertyFnWithNamespaceIDFilter[time.Duration]
|
|
|
|
func GetDurationPropertyFnFilteredByNamespaceID(value time.Duration) DurationPropertyFnWithNamespaceIDFilter {
|
|
return GetTypedPropertyFnFilteredByNamespaceID(value)
|
|
}
|
|
|
|
type TaskQueueDurationSetting = TaskQueueTypedSetting[time.Duration]
|
|
|
|
func NewTaskQueueDurationSetting(key Key, def time.Duration, description string) TaskQueueDurationSetting {
|
|
return NewTaskQueueTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewTaskQueueDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) TaskQueueDurationSetting {
|
|
return NewTaskQueueTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[time.Duration]
|
|
|
|
func GetDurationPropertyFnFilteredByTaskQueue(value time.Duration) DurationPropertyFnWithTaskQueueFilter {
|
|
return GetTypedPropertyFnFilteredByTaskQueue(value)
|
|
}
|
|
|
|
type ShardIDDurationSetting = ShardIDTypedSetting[time.Duration]
|
|
|
|
func NewShardIDDurationSetting(key Key, def time.Duration, description string) ShardIDDurationSetting {
|
|
return NewShardIDTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewShardIDDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) ShardIDDurationSetting {
|
|
return NewShardIDTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFnWithShardIDFilter = TypedPropertyFnWithShardIDFilter[time.Duration]
|
|
|
|
func GetDurationPropertyFnFilteredByShardID(value time.Duration) DurationPropertyFnWithShardIDFilter {
|
|
return GetTypedPropertyFnFilteredByShardID(value)
|
|
}
|
|
|
|
type TaskTypeDurationSetting = TaskTypeTypedSetting[time.Duration]
|
|
|
|
func NewTaskTypeDurationSetting(key Key, def time.Duration, description string) TaskTypeDurationSetting {
|
|
return NewTaskTypeTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewTaskTypeDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) TaskTypeDurationSetting {
|
|
return NewTaskTypeTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFnWithTaskTypeFilter = TypedPropertyFnWithTaskTypeFilter[time.Duration]
|
|
|
|
func GetDurationPropertyFnFilteredByTaskType(value time.Duration) DurationPropertyFnWithTaskTypeFilter {
|
|
return GetTypedPropertyFnFilteredByTaskType(value)
|
|
}
|
|
|
|
type DestinationDurationSetting = DestinationTypedSetting[time.Duration]
|
|
|
|
func NewDestinationDurationSetting(key Key, def time.Duration, description string) DestinationDurationSetting {
|
|
return NewDestinationTypedSettingWithConverter[time.Duration](key, convertDuration, def, description)
|
|
}
|
|
|
|
func NewDestinationDurationSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[time.Duration], description string) DestinationDurationSetting {
|
|
return NewDestinationTypedSettingWithConstrainedDefault[time.Duration](key, convertDuration, cdef, description)
|
|
}
|
|
|
|
type DurationPropertyFnWithDestinationFilter = TypedPropertyFnWithDestinationFilter[time.Duration]
|
|
|
|
func GetDurationPropertyFnFilteredByDestination(value time.Duration) DurationPropertyFnWithDestinationFilter {
|
|
return GetTypedPropertyFnFilteredByDestination(value)
|
|
}
|
|
|
|
type GlobalMapSetting = GlobalTypedSetting[map[string]any]
|
|
|
|
func NewGlobalMapSetting(key Key, def map[string]any, description string) GlobalMapSetting {
|
|
return NewGlobalTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewGlobalMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) GlobalMapSetting {
|
|
return NewGlobalTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFn = TypedPropertyFn[map[string]any]
|
|
|
|
func GetMapPropertyFn(value map[string]any) MapPropertyFn {
|
|
return GetTypedPropertyFn(value)
|
|
}
|
|
|
|
type NamespaceMapSetting = NamespaceTypedSetting[map[string]any]
|
|
|
|
func NewNamespaceMapSetting(key Key, def map[string]any, description string) NamespaceMapSetting {
|
|
return NewNamespaceTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewNamespaceMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) NamespaceMapSetting {
|
|
return NewNamespaceTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFnWithNamespaceFilter = TypedPropertyFnWithNamespaceFilter[map[string]any]
|
|
|
|
func GetMapPropertyFnFilteredByNamespace(value map[string]any) MapPropertyFnWithNamespaceFilter {
|
|
return GetTypedPropertyFnFilteredByNamespace(value)
|
|
}
|
|
|
|
type NamespaceIDMapSetting = NamespaceIDTypedSetting[map[string]any]
|
|
|
|
func NewNamespaceIDMapSetting(key Key, def map[string]any, description string) NamespaceIDMapSetting {
|
|
return NewNamespaceIDTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewNamespaceIDMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) NamespaceIDMapSetting {
|
|
return NewNamespaceIDTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFnWithNamespaceIDFilter = TypedPropertyFnWithNamespaceIDFilter[map[string]any]
|
|
|
|
func GetMapPropertyFnFilteredByNamespaceID(value map[string]any) MapPropertyFnWithNamespaceIDFilter {
|
|
return GetTypedPropertyFnFilteredByNamespaceID(value)
|
|
}
|
|
|
|
type TaskQueueMapSetting = TaskQueueTypedSetting[map[string]any]
|
|
|
|
func NewTaskQueueMapSetting(key Key, def map[string]any, description string) TaskQueueMapSetting {
|
|
return NewTaskQueueTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewTaskQueueMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) TaskQueueMapSetting {
|
|
return NewTaskQueueTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFnWithTaskQueueFilter = TypedPropertyFnWithTaskQueueFilter[map[string]any]
|
|
|
|
func GetMapPropertyFnFilteredByTaskQueue(value map[string]any) MapPropertyFnWithTaskQueueFilter {
|
|
return GetTypedPropertyFnFilteredByTaskQueue(value)
|
|
}
|
|
|
|
type ShardIDMapSetting = ShardIDTypedSetting[map[string]any]
|
|
|
|
func NewShardIDMapSetting(key Key, def map[string]any, description string) ShardIDMapSetting {
|
|
return NewShardIDTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewShardIDMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) ShardIDMapSetting {
|
|
return NewShardIDTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFnWithShardIDFilter = TypedPropertyFnWithShardIDFilter[map[string]any]
|
|
|
|
func GetMapPropertyFnFilteredByShardID(value map[string]any) MapPropertyFnWithShardIDFilter {
|
|
return GetTypedPropertyFnFilteredByShardID(value)
|
|
}
|
|
|
|
type TaskTypeMapSetting = TaskTypeTypedSetting[map[string]any]
|
|
|
|
func NewTaskTypeMapSetting(key Key, def map[string]any, description string) TaskTypeMapSetting {
|
|
return NewTaskTypeTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewTaskTypeMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) TaskTypeMapSetting {
|
|
return NewTaskTypeTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFnWithTaskTypeFilter = TypedPropertyFnWithTaskTypeFilter[map[string]any]
|
|
|
|
func GetMapPropertyFnFilteredByTaskType(value map[string]any) MapPropertyFnWithTaskTypeFilter {
|
|
return GetTypedPropertyFnFilteredByTaskType(value)
|
|
}
|
|
|
|
type DestinationMapSetting = DestinationTypedSetting[map[string]any]
|
|
|
|
func NewDestinationMapSetting(key Key, def map[string]any, description string) DestinationMapSetting {
|
|
return NewDestinationTypedSettingWithConverter[map[string]any](key, convertMap, def, description)
|
|
}
|
|
|
|
func NewDestinationMapSettingWithConstrainedDefault(key Key, cdef []TypedConstrainedValue[map[string]any], description string) DestinationMapSetting {
|
|
return NewDestinationTypedSettingWithConstrainedDefault[map[string]any](key, convertMap, cdef, description)
|
|
}
|
|
|
|
type MapPropertyFnWithDestinationFilter = TypedPropertyFnWithDestinationFilter[map[string]any]
|
|
|
|
func GetMapPropertyFnFilteredByDestination(value map[string]any) MapPropertyFnWithDestinationFilter {
|
|
return GetTypedPropertyFnFilteredByDestination(value)
|
|
}
|
|
|
|
type GlobalTypedSetting[T any] setting[T, func()]
|
|
|
|
// NewGlobalTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewGlobalTypedSetting[T any](key Key, def T, description string) GlobalTypedSetting[T] {
|
|
s := GlobalTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewGlobalTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewGlobalTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) GlobalTypedSetting[T] {
|
|
s := GlobalTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewGlobalTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewGlobalTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) GlobalTypedSetting[T] {
|
|
s := GlobalTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s GlobalTypedSetting[T]) Key() Key { return s.key }
|
|
func (s GlobalTypedSetting[T]) Precedence() Precedence { return PrecedenceGlobal }
|
|
func (s GlobalTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s GlobalTypedSetting[T]) WithDefault(v T) GlobalTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFn[T any] func() T
|
|
|
|
func (s GlobalTypedSetting[T]) Get(c *Collection) TypedPropertyFn[T] {
|
|
return func() T {
|
|
prec := []Constraints{{}}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribable[T any] func(callback func(T)) (v T, cancel func())
|
|
|
|
func (s GlobalTypedSetting[T]) Subscribe(c *Collection) TypedSubscribable[T] {
|
|
return func(callback func(T)) (T, func()) {
|
|
prec := []Constraints{{}}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s GlobalTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFn[T any](value T) TypedPropertyFn[T] {
|
|
return func() T {
|
|
return value
|
|
}
|
|
}
|
|
|
|
type NamespaceTypedSetting[T any] setting[T, func(namespace string)]
|
|
|
|
// NewNamespaceTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewNamespaceTypedSetting[T any](key Key, def T, description string) NamespaceTypedSetting[T] {
|
|
s := NamespaceTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewNamespaceTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewNamespaceTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) NamespaceTypedSetting[T] {
|
|
s := NamespaceTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewNamespaceTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewNamespaceTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) NamespaceTypedSetting[T] {
|
|
s := NamespaceTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s NamespaceTypedSetting[T]) Key() Key { return s.key }
|
|
func (s NamespaceTypedSetting[T]) Precedence() Precedence { return PrecedenceNamespace }
|
|
func (s NamespaceTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s NamespaceTypedSetting[T]) WithDefault(v T) NamespaceTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFnWithNamespaceFilter[T any] func(namespace string) T
|
|
|
|
func (s NamespaceTypedSetting[T]) Get(c *Collection) TypedPropertyFnWithNamespaceFilter[T] {
|
|
return func(namespace string) T {
|
|
prec := []Constraints{{Namespace: namespace}, {}}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribableWithNamespaceFilter[T any] func(namespace string, callback func(T)) (v T, cancel func())
|
|
|
|
func (s NamespaceTypedSetting[T]) Subscribe(c *Collection) TypedSubscribableWithNamespaceFilter[T] {
|
|
return func(namespace string, callback func(T)) (T, func()) {
|
|
prec := []Constraints{{Namespace: namespace}, {}}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s NamespaceTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFnFilteredByNamespace[T any](value T) TypedPropertyFnWithNamespaceFilter[T] {
|
|
return func(namespace string) T {
|
|
return value
|
|
}
|
|
}
|
|
|
|
type NamespaceIDTypedSetting[T any] setting[T, func(namespaceID string)]
|
|
|
|
// NewNamespaceIDTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewNamespaceIDTypedSetting[T any](key Key, def T, description string) NamespaceIDTypedSetting[T] {
|
|
s := NamespaceIDTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewNamespaceIDTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewNamespaceIDTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) NamespaceIDTypedSetting[T] {
|
|
s := NamespaceIDTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewNamespaceIDTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewNamespaceIDTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) NamespaceIDTypedSetting[T] {
|
|
s := NamespaceIDTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s NamespaceIDTypedSetting[T]) Key() Key { return s.key }
|
|
func (s NamespaceIDTypedSetting[T]) Precedence() Precedence { return PrecedenceNamespaceID }
|
|
func (s NamespaceIDTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s NamespaceIDTypedSetting[T]) WithDefault(v T) NamespaceIDTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFnWithNamespaceIDFilter[T any] func(namespaceID string) T
|
|
|
|
func (s NamespaceIDTypedSetting[T]) Get(c *Collection) TypedPropertyFnWithNamespaceIDFilter[T] {
|
|
return func(namespaceID string) T {
|
|
prec := []Constraints{{NamespaceID: namespaceID}, {}}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribableWithNamespaceIDFilter[T any] func(namespaceID string, callback func(T)) (v T, cancel func())
|
|
|
|
func (s NamespaceIDTypedSetting[T]) Subscribe(c *Collection) TypedSubscribableWithNamespaceIDFilter[T] {
|
|
return func(namespaceID string, callback func(T)) (T, func()) {
|
|
prec := []Constraints{{NamespaceID: namespaceID}, {}}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s NamespaceIDTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFnFilteredByNamespaceID[T any](value T) TypedPropertyFnWithNamespaceIDFilter[T] {
|
|
return func(namespaceID string) T {
|
|
return value
|
|
}
|
|
}
|
|
|
|
type TaskQueueTypedSetting[T any] setting[T, func(namespace string, taskQueue string, taskQueueType enumspb.TaskQueueType)]
|
|
|
|
// NewTaskQueueTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewTaskQueueTypedSetting[T any](key Key, def T, description string) TaskQueueTypedSetting[T] {
|
|
s := TaskQueueTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewTaskQueueTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewTaskQueueTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) TaskQueueTypedSetting[T] {
|
|
s := TaskQueueTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewTaskQueueTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewTaskQueueTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) TaskQueueTypedSetting[T] {
|
|
s := TaskQueueTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s TaskQueueTypedSetting[T]) Key() Key { return s.key }
|
|
func (s TaskQueueTypedSetting[T]) Precedence() Precedence { return PrecedenceTaskQueue }
|
|
func (s TaskQueueTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s TaskQueueTypedSetting[T]) WithDefault(v T) TaskQueueTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFnWithTaskQueueFilter[T any] func(namespace string, taskQueue string, taskQueueType enumspb.TaskQueueType) T
|
|
|
|
func (s TaskQueueTypedSetting[T]) Get(c *Collection) TypedPropertyFnWithTaskQueueFilter[T] {
|
|
return func(namespace string, taskQueue string, taskQueueType enumspb.TaskQueueType) T {
|
|
prec := []Constraints{
|
|
{Namespace: namespace, TaskQueueName: taskQueue, TaskQueueType: taskQueueType},
|
|
{Namespace: namespace, TaskQueueName: taskQueue},
|
|
{TaskQueueName: taskQueue},
|
|
{Namespace: namespace},
|
|
{},
|
|
}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribableWithTaskQueueFilter[T any] func(namespace string, taskQueue string, taskQueueType enumspb.TaskQueueType, callback func(T)) (v T, cancel func())
|
|
|
|
func (s TaskQueueTypedSetting[T]) Subscribe(c *Collection) TypedSubscribableWithTaskQueueFilter[T] {
|
|
return func(namespace string, taskQueue string, taskQueueType enumspb.TaskQueueType, callback func(T)) (T, func()) {
|
|
prec := []Constraints{
|
|
{Namespace: namespace, TaskQueueName: taskQueue, TaskQueueType: taskQueueType},
|
|
{Namespace: namespace, TaskQueueName: taskQueue},
|
|
{TaskQueueName: taskQueue},
|
|
{Namespace: namespace},
|
|
{},
|
|
}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s TaskQueueTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFnFilteredByTaskQueue[T any](value T) TypedPropertyFnWithTaskQueueFilter[T] {
|
|
return func(namespace string, taskQueue string, taskQueueType enumspb.TaskQueueType) T {
|
|
return value
|
|
}
|
|
}
|
|
|
|
type ShardIDTypedSetting[T any] setting[T, func(shardID int32)]
|
|
|
|
// NewShardIDTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewShardIDTypedSetting[T any](key Key, def T, description string) ShardIDTypedSetting[T] {
|
|
s := ShardIDTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewShardIDTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewShardIDTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) ShardIDTypedSetting[T] {
|
|
s := ShardIDTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewShardIDTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewShardIDTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) ShardIDTypedSetting[T] {
|
|
s := ShardIDTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s ShardIDTypedSetting[T]) Key() Key { return s.key }
|
|
func (s ShardIDTypedSetting[T]) Precedence() Precedence { return PrecedenceShardID }
|
|
func (s ShardIDTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s ShardIDTypedSetting[T]) WithDefault(v T) ShardIDTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFnWithShardIDFilter[T any] func(shardID int32) T
|
|
|
|
func (s ShardIDTypedSetting[T]) Get(c *Collection) TypedPropertyFnWithShardIDFilter[T] {
|
|
return func(shardID int32) T {
|
|
prec := []Constraints{{ShardID: shardID}, {}}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribableWithShardIDFilter[T any] func(shardID int32, callback func(T)) (v T, cancel func())
|
|
|
|
func (s ShardIDTypedSetting[T]) Subscribe(c *Collection) TypedSubscribableWithShardIDFilter[T] {
|
|
return func(shardID int32, callback func(T)) (T, func()) {
|
|
prec := []Constraints{{ShardID: shardID}, {}}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s ShardIDTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFnFilteredByShardID[T any](value T) TypedPropertyFnWithShardIDFilter[T] {
|
|
return func(shardID int32) T {
|
|
return value
|
|
}
|
|
}
|
|
|
|
type TaskTypeTypedSetting[T any] setting[T, func(taskType enumsspb.TaskType)]
|
|
|
|
// NewTaskTypeTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewTaskTypeTypedSetting[T any](key Key, def T, description string) TaskTypeTypedSetting[T] {
|
|
s := TaskTypeTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewTaskTypeTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewTaskTypeTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) TaskTypeTypedSetting[T] {
|
|
s := TaskTypeTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewTaskTypeTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewTaskTypeTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) TaskTypeTypedSetting[T] {
|
|
s := TaskTypeTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s TaskTypeTypedSetting[T]) Key() Key { return s.key }
|
|
func (s TaskTypeTypedSetting[T]) Precedence() Precedence { return PrecedenceTaskType }
|
|
func (s TaskTypeTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s TaskTypeTypedSetting[T]) WithDefault(v T) TaskTypeTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFnWithTaskTypeFilter[T any] func(taskType enumsspb.TaskType) T
|
|
|
|
func (s TaskTypeTypedSetting[T]) Get(c *Collection) TypedPropertyFnWithTaskTypeFilter[T] {
|
|
return func(taskType enumsspb.TaskType) T {
|
|
prec := []Constraints{{TaskType: taskType}, {}}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribableWithTaskTypeFilter[T any] func(taskType enumsspb.TaskType, callback func(T)) (v T, cancel func())
|
|
|
|
func (s TaskTypeTypedSetting[T]) Subscribe(c *Collection) TypedSubscribableWithTaskTypeFilter[T] {
|
|
return func(taskType enumsspb.TaskType, callback func(T)) (T, func()) {
|
|
prec := []Constraints{{TaskType: taskType}, {}}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s TaskTypeTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFnFilteredByTaskType[T any](value T) TypedPropertyFnWithTaskTypeFilter[T] {
|
|
return func(taskType enumsspb.TaskType) T {
|
|
return value
|
|
}
|
|
}
|
|
|
|
type DestinationTypedSetting[T any] setting[T, func(namespace string, destination string)]
|
|
|
|
// NewDestinationTypedSetting creates a setting that uses mapstructure to handle complex structured
|
|
// values. The value from dynamic config will be copied over a shallow copy of 'def', which means
|
|
// 'def' must not contain any non-nil slices, maps, or pointers.
|
|
func NewDestinationTypedSetting[T any](key Key, def T, description string) DestinationTypedSetting[T] {
|
|
s := DestinationTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: ConvertStructure[T](def),
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewDestinationTypedSettingWithConverter creates a setting with a custom converter function.
|
|
func NewDestinationTypedSettingWithConverter[T any](key Key, convert func(any) (T, error), def T, description string) DestinationTypedSetting[T] {
|
|
s := DestinationTypedSetting[T]{
|
|
key: key,
|
|
def: def,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
// NewDestinationTypedSettingWithConstrainedDefault creates a setting with a compound default value.
|
|
func NewDestinationTypedSettingWithConstrainedDefault[T any](key Key, convert func(any) (T, error), cdef []TypedConstrainedValue[T], description string) DestinationTypedSetting[T] {
|
|
s := DestinationTypedSetting[T]{
|
|
key: key,
|
|
cdef: &cdef,
|
|
convert: convert,
|
|
description: description,
|
|
}
|
|
register(s)
|
|
return s
|
|
}
|
|
|
|
func (s DestinationTypedSetting[T]) Key() Key { return s.key }
|
|
func (s DestinationTypedSetting[T]) Precedence() Precedence { return PrecedenceDestination }
|
|
func (s DestinationTypedSetting[T]) Validate(v any) error {
|
|
_, err := s.convert(v)
|
|
return err
|
|
}
|
|
|
|
func (s DestinationTypedSetting[T]) WithDefault(v T) DestinationTypedSetting[T] {
|
|
newS := s
|
|
newS.def = v
|
|
return newS
|
|
}
|
|
|
|
type TypedPropertyFnWithDestinationFilter[T any] func(namespace string, destination string) T
|
|
|
|
func (s DestinationTypedSetting[T]) Get(c *Collection) TypedPropertyFnWithDestinationFilter[T] {
|
|
return func(namespace string, destination string) T {
|
|
prec := []Constraints{
|
|
{Namespace: namespace, Destination: destination},
|
|
{Destination: destination},
|
|
{Namespace: namespace},
|
|
{},
|
|
}
|
|
return matchAndConvert(
|
|
c,
|
|
s.key,
|
|
s.def,
|
|
s.cdef,
|
|
s.convert,
|
|
prec,
|
|
)
|
|
}
|
|
}
|
|
|
|
type TypedSubscribableWithDestinationFilter[T any] func(namespace string, destination string, callback func(T)) (v T, cancel func())
|
|
|
|
func (s DestinationTypedSetting[T]) Subscribe(c *Collection) TypedSubscribableWithDestinationFilter[T] {
|
|
return func(namespace string, destination string, callback func(T)) (T, func()) {
|
|
prec := []Constraints{
|
|
{Namespace: namespace, Destination: destination},
|
|
{Destination: destination},
|
|
{Namespace: namespace},
|
|
{},
|
|
}
|
|
return subscribe(c, s.key, s.def, s.cdef, s.convert, prec, callback)
|
|
}
|
|
}
|
|
|
|
func (s DestinationTypedSetting[T]) dispatchUpdate(c *Collection, sub any, cvs []ConstrainedValue) {
|
|
dispatchUpdate(
|
|
c,
|
|
s.key,
|
|
s.convert,
|
|
sub.(*subscription[T]),
|
|
cvs,
|
|
)
|
|
}
|
|
|
|
func GetTypedPropertyFnFilteredByDestination[T any](value T) TypedPropertyFnWithDestinationFilter[T] {
|
|
return func(namespace string, destination string) T {
|
|
return value
|
|
}
|
|
}
|