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

Function CreateNamespaces

schema/sqlite/setup.go:93–107  ·  view source on GitHub ↗

CreateNamespaces creates namespaces in the target database without the need to have a running Temporal server. This exists primarily as a workaround for https://github.com/temporalio/temporal/issues/1336. Namespaces should typically be created through the Temporal API either via `tctl` or an SDK cl

(cfg *config.SQL, namespaces ...*NamespaceConfig)

Source from the content-addressed store, hash-verified

91//
92// Note: this function may receive breaking changes or be removed in the future.
93func CreateNamespaces(cfg *config.SQL, namespaces ...*NamespaceConfig) error {
94 db, err := sql.NewSQLDB(sqlplugin.DbKindUnknown, cfg, resolver.NewNoopResolver(), log.NewNoopLogger(), metrics.NoopMetricsHandler)
95 if err != nil {
96 return fmt.Errorf("unable to create SQLite admin DB: %w", err)
97 }
98 defer func() { _ = db.Close() }()
99
100 for _, ns := range namespaces {
101 if err := createNamespaceIfNotExists(db, ns); err != nil {
102 return fmt.Errorf("error creating namespace %q: %w", ns.Detail.Info.Name, err)
103 }
104 }
105
106 return nil
107}
108
109// NewNamespaceConfig initializes a NamespaceConfig with the field values needed to pre-register
110// the namespace via the CreateNamespaces function.

Callers 1

NewLiteServerFunction · 0.92

Calls 6

NewSQLDBFunction · 0.92
NewNoopResolverFunction · 0.92
NewNoopLoggerFunction · 0.92
CloseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected