MCPcopy Create free account
hub / github.com/temporalio/temporal / NewNamespaceConfig

Function NewNamespaceConfig

schema/sqlite/setup.go:113–167  ·  view source on GitHub ↗

NewNamespaceConfig initializes a NamespaceConfig with the field values needed to pre-register the namespace via the CreateNamespaces function. Note: this function may receive breaking changes or be removed in the future.

(
	activeClusterName string,
	namespace string,
	global bool,
	customSearchAttributes map[string]enumspb.IndexedValueType,
)

Source from the content-addressed store, hash-verified

111//
112// Note: this function may receive breaking changes or be removed in the future.
113func NewNamespaceConfig(
114 activeClusterName string,
115 namespace string,
116 global bool,
117 customSearchAttributes map[string]enumspb.IndexedValueType,
118) (*NamespaceConfig, error) {
119 dbCustomSearchAttributes := sadefs.GetDBIndexSearchAttributes(nil).CustomSearchAttributes
120 fieldToAliasMap := map[string]string{}
121 for saName, saType := range customSearchAttributes {
122 var targetFieldName string
123 var cntUsed int
124 for fieldName, fieldType := range dbCustomSearchAttributes {
125 if fieldType != saType {
126 continue
127 }
128 if _, ok := fieldToAliasMap[fieldName]; !ok {
129 targetFieldName = fieldName
130 break
131 }
132 cntUsed++
133 }
134 if targetFieldName == "" {
135 return nil, fmt.Errorf(
136 "cannot have more than %d search attributes of type %s",
137 cntUsed,
138 saType,
139 )
140 }
141 fieldToAliasMap[targetFieldName] = saName
142 }
143
144 detail := persistencespb.NamespaceDetail{
145 Info: &persistencespb.NamespaceInfo{
146 Id: primitives.NewUUID().String(),
147 State: enumspb.NAMESPACE_STATE_REGISTERED,
148 Name: namespace,
149 },
150 Config: &persistencespb.NamespaceConfig{
151 Retention: timestamp.DurationFromHours(24),
152 HistoryArchivalState: enumspb.ARCHIVAL_STATE_DISABLED,
153 VisibilityArchivalState: enumspb.ARCHIVAL_STATE_DISABLED,
154 CustomSearchAttributeAliases: fieldToAliasMap,
155 },
156 ReplicationConfig: &persistencespb.NamespaceReplicationConfig{
157 ActiveClusterName: activeClusterName,
158 Clusters: []string{activeClusterName},
159 },
160 FailoverVersion: common.EmptyVersion,
161 FailoverNotificationVersion: -1,
162 }
163 return &NamespaceConfig{
164 Detail: &detail,
165 IsGlobal: global,
166 }, nil
167}
168
169func createNamespaceIfNotExists(db sqlplugin.DB, namespace *NamespaceConfig) error {
170 var (

Callers 1

NewLiteServerFunction · 0.92

Calls 5

NewUUIDFunction · 0.92
DurationFromHoursFunction · 0.92
StringMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected