Creating a new namespace in Temporal

Here is the relevant CLI documentation.

Programmatically it is done through gRPC API exposed by the service.

In Java the generated gRPC client is accessible through WorkflowServiceStubs:

    WorkflowServiceStubs service =
        WorkflowServiceStubs.newInstance(
            WorkflowServiceStubsOptions.newBuilder().setTarget(serviceAddress).build());
    RegisterNamespaceRequest request =
        RegisterNamespaceRequest.newBuilder()
            .setName(NAMESPACE)
            .setWorkflowExecutionRetentionPeriod(Durations.fromDays(7))
            .build();
    service.blockingStub().registerNamespace(request);

In Go SDK you can use higher-level NamespaceClient:

	client, err := client.NewNamespaceClient(client.Options{HostPort: ts.config.ServiceAddr})
        ...
	err = client.Register(ctx, &workflowservice.RegisterNamespaceRequest{
		Name:                             name,
		WorkflowExecutionRetentionPeriod: &retention,
	})

2 Likes