Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporal: How to create a namespace programatically?

It is possible to create a namespace via the CLI, but how to do it using Java SDK?

like image 712
Yasin Avatar asked Sep 15 '25 01:09

Yasin


1 Answers

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()
        .setNamespace(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,
})

OP and additional discussion here.

like image 110
Yasin Avatar answered Sep 17 '25 18:09

Yasin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!