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

Function createNamespaceIfNotExists

schema/sqlite/setup.go:169–200  ·  view source on GitHub ↗
(db sqlplugin.DB, namespace *NamespaceConfig)

Source from the content-addressed store, hash-verified

167}
168
169func createNamespaceIfNotExists(db sqlplugin.DB, namespace *NamespaceConfig) error {
170 var (
171 name = namespace.Detail.GetInfo().GetName()
172 id = primitives.MustParseUUID(namespace.Detail.GetInfo().GetId())
173 )
174
175 // Return early if namespace already exists
176 rows, err := db.SelectFromNamespace(context.Background(), sqlplugin.NamespaceFilter{
177 Name: &name,
178 })
179 if err == nil && len(rows) > 0 {
180 return nil
181 }
182
183 blob, err := serialization.NewSerializer().NamespaceDetailToBlob(namespace.Detail)
184 if err != nil {
185 return err
186 }
187
188 if _, err := db.InsertIntoNamespace(context.Background(), &sqlplugin.NamespaceRow{
189 ID: id,
190 Name: name,
191 Data: blob.GetData(),
192 DataEncoding: blob.GetEncodingType().String(),
193 IsGlobal: namespace.IsGlobal,
194 NotificationVersion: 0,
195 }); err != nil {
196 return err
197 }
198
199 return nil
200}

Callers 1

CreateNamespacesFunction · 0.85

Calls 10

MustParseUUIDFunction · 0.92
NewSerializerFunction · 0.92
GetNameMethod · 0.65
SelectFromNamespaceMethod · 0.65
NamespaceDetailToBlobMethod · 0.65
InsertIntoNamespaceMethod · 0.65
GetDataMethod · 0.65
StringMethod · 0.65
GetInfoMethod · 0.45
GetIdMethod · 0.45

Tested by

no test coverage detected