Skip to content

Commit

Permalink
feat(orchestration): make search attributes creation optional (#1301)
Browse files Browse the repository at this point in the history
  • Loading branch information
gfyrag authored Mar 1, 2024
1 parent 27f2d3a commit 072b1d9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
27 changes: 15 additions & 12 deletions ee/orchestration/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ var (
)

const (
stackFlag = "stack"
stackURLFlag = "stack-url"
stackClientIDFlag = "stack-client-id"
stackClientSecretFlag = "stack-client-secret"
temporalAddressFlag = "temporal-address"
temporalNamespaceFlag = "temporal-namespace"
temporalSSLClientKeyFlag = "temporal-ssl-client-key"
temporalSSLClientCertFlag = "temporal-ssl-client-cert"
temporalTaskQueueFlag = "temporal-task-queue"
topicsFlag = "topics"
listenFlag = "listen"
workerFlag = "worker"
stackFlag = "stack"
stackURLFlag = "stack-url"
stackClientIDFlag = "stack-client-id"
stackClientSecretFlag = "stack-client-secret"
temporalAddressFlag = "temporal-address"
temporalNamespaceFlag = "temporal-namespace"
temporalSSLClientKeyFlag = "temporal-ssl-client-key"
temporalSSLClientCertFlag = "temporal-ssl-client-cert"
temporalTaskQueueFlag = "temporal-task-queue"
temporalInitSearchAttributes = "temporal-init-search-attributes"
topicsFlag = "topics"
listenFlag = "listen"
workerFlag = "worker"
)

func NewRootCommand() *cobra.Command {
Expand All @@ -70,6 +71,7 @@ func NewRootCommand() *cobra.Command {
cmd.PersistentFlags().String(temporalSSLClientKeyFlag, "", "Temporal client key")
cmd.PersistentFlags().String(temporalSSLClientCertFlag, "", "Temporal client cert")
cmd.PersistentFlags().String(temporalTaskQueueFlag, "default", "Temporal task queue name")
cmd.PersistentFlags().Bool(temporalInitSearchAttributes, false, "Init temporal search attributes")
cmd.PersistentFlags().StringSlice(topicsFlag, []string{}, "Topics to listen")
cmd.PersistentFlags().String(stackFlag, "", "Stack")
cmd.AddCommand(
Expand Down Expand Up @@ -112,6 +114,7 @@ func commonOptions(cmd *cobra.Command) (fx.Option, error) {
viper.GetString(temporalNamespaceFlag),
viper.GetString(temporalSSLClientCertFlag),
viper.GetString(temporalSSLClientKeyFlag),
viper.GetBool(temporalInitSearchAttributes),
),
bunconnect.Module(*connectionOptions),
publish.CLIPublisherModule("orchestration"),
Expand Down
7 changes: 5 additions & 2 deletions ee/orchestration/internal/temporalclient/client_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"go.uber.org/fx"
)

func NewModule(address, namespace string, certStr string, key string) fx.Option {
func NewModule(address, namespace string, certStr string, key string, initSearchAttributes bool) fx.Option {
return fx.Options(
fx.Provide(func(logger logging.Logger) (client.Options, error) {

Expand Down Expand Up @@ -54,7 +54,10 @@ func NewModule(address, namespace string, certStr string, key string) fx.Option
fx.Invoke(func(lifecycle fx.Lifecycle, c client.Client) {
lifecycle.Append(fx.Hook{
OnStart: func(ctx context.Context) error {
return createSearchAttributes(ctx, c, namespace)
if initSearchAttributes {
return createSearchAttributes(ctx, c, namespace)
}
return nil
},
OnStop: func(ctx context.Context) error {
c.Close()
Expand Down
1 change: 1 addition & 0 deletions tests/integration/internal/modules/orchestration.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var Orchestration = internal.NewModule("orchestration").
"--stack-url=" + test.GatewayURL(),
"--temporal-address=" + internal.GetTemporalAddress(),
"--temporal-task-queue=" + test.ID(),
"--temporal-init-search-attributes",
"--worker",
"--publisher-nats-enabled",
"--publisher-nats-client-id=orchestration",
Expand Down

0 comments on commit 072b1d9

Please sign in to comment.