Temporal Server options reference
You can run the Temporal Server as a Go application by including the server package go.temporal.io/server/temporal
and using it to create and start a Temporal Server.
The Temporal Server services can be run in various ways. We recommend this approach for a limited number of situations.
s := temporal.NewServer()
err := s.Start()
if err != nil{
log.Fatal(err)
}
NewServer()
accepts functions as parameters.
Each function returns a ServerOption
that is applied to the instance.
Source code for parameter reference is here: https://github.com/temporalio/temporal/blob/main/temporal/server_option.go
WithConfig
Overrides the default configuration with a custom configuration that is defined in the config package go.temporal.io/server/common/service/config
.
s := temporal.NewServer(
temporal.WithConfig(cfg),
)
WithConfigLoader
Load a custom configuration from a file.
s := temporal.NewServer(
temporal.WithConfigLoader(configDir, env, zone),
)
ForServices
Sets the list of all valid temporal services.
The default can be used from the go.temporal.io/server/temporal
package.
s := temporal.NewServer(
temporal.ForServices(temporal.Services),
)
InterruptOn
This option provides a channel that interrupts the server on the signal from that channel.
- If
temporal.InterruptOn()
is not passed,server.Start()
is never blocked and you need to callserver.Stop()
somewhere. - If
temporal.InterruptOn(nil)
is passed,server.Start()
blocks forever until the process is killed. - If
temporal.InterruptOn(temporal.InterruptCh())
is passed,server.Start()
blocks until you use Ctrl+C, which then gracefully shuts the server down. - If
temporal.Interrupt(someCustomChan)
is passed,server.Start()
blocks until a signal is sent tosomeCustomChan
.
s := temporal.NewServer(
temporal.InterruptOn(temporal.InterruptCh()),
)
WithAuthorizer
Sets a low level authorization mechanism that determines whether to allow or deny inbound API calls.
s := temporal.NewServer(
temporal.WithAuthorizer(myAuthorizer),
)
WithTLSConfigFactory
Overrides the default TLS configuration provider.
TLSConfigProvider
is defined in the go.temporal.io/server/common/rpc/encryption
package.
s := temporal.NewServer(
temporal.WithTLSConfigFactory(yourTLSConfigProvider),
)
WithClaimMapper
Configures a mechanism to map roles to Claims
for authorization.
s := temporal.NewServer(
temporal.WithClaimMapper(func(cfg *config.Config) authorization.ClaimMapper {
logger := getYourLogger() // Replace with how you retrieve or initialize your logger
return authorization.NewDefaultJWTClaimMapper(
authorization.NewDefaultTokenKeyProvider(cfg, logger),
cfg
)
}),
)
WithCustomMetricsReporter
Sets a custom tally metric reporter.
s := temporal.NewServer(
temporal.WithCustomMetricsReporter(myReporter),
)
You can see the Uber tally docs on custom reporter and see a community implementation of a reporter for Datadog's dogstatsd
format.