Creating a new namespace in Temporal

How do you do it in temporal, programmatically and from command line.

Thanks,

Kasi

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,
	})

1 Like

Thanks a ton

1 Like

Hey Max,

I am running into an issue trying to connect to remote temporal server using grpc API as above, I am seeing java.io.IOException: Connection reset by peer and when I run from docker i am seeing the following exception

Error: Operation DescribeNamespace failed.

Error Details: last connection error: connection error: desc = “transport: Error while dialing dial tcp: lookup xxxx:1234 on [::1]:53: read udp [::1]:45479->[::1]:53: read: connection refused”

nc to the temporal hostname:port succeeds from mac. Any ideas? do I need to set any other property for the gRpc to work?

Thanks

I’m not sure how to troubleshoot connectivity issues in your environment. Try invoking health service endpoint. One option is to use curl.

I am seeing the following exception running above code to local server
RegisterNamespace.main()Exception in thread “main” io.grpc.StatusRuntimeException: UNIMPLEMENTED: unknown service temporal.workflowservice.v1.WorkflowService
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:244)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:225)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:142)
at io.temporal.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.registerNamespace(WorkflowServiceGrpc.java:2546)
at io.temporal.samples.common.RegisterNamespace.main(RegisterNamespace.java:19)
FAILED
temporal sevrer : 0.28.0

tried with server 0.27 also did not work

I am seeing this error when I am running the basic HelloActivity examples