Skip to content

Commit

Permalink
feat: (worker) ensure connector engine only instantiated in payments …
Browse files Browse the repository at this point in the history
…service
  • Loading branch information
laouji committed Dec 20, 2024
1 parent 916ba71 commit a963682
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 27 deletions.
13 changes: 0 additions & 13 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ func commonOptions(cmd *cobra.Command) (fx.Option, error) {
return nil, err
}

stack, _ := cmd.Flags().GetString(StackFlag)
stackPublicURL, _ := cmd.Flags().GetString(stackPublicURLFlag)
debug, _ := cmd.Flags().GetBool(service.DebugFlag)
temporalNamespace, _ := cmd.Flags().GetString(temporal.TemporalNamespaceFlag)
temporalMaxConcurrentWorkflowTaskPollers, _ := cmd.Flags().GetInt(temporalMaxConcurrentWorkflowTaskPollersFlag)

return fx.Options(
fx.Provide(func() *bunconnect.ConnectionOptions {
return connectionOptions
Expand All @@ -82,12 +76,5 @@ func commonOptions(cmd *cobra.Command) (fx.Option, error) {
licence.FXModuleFromFlags(cmd, ServiceName),
storage.Module(cmd, *connectionOptions, configEncryptionKey),
profiling.FXModuleFromFlags(cmd),
engine.Module(
stack,
stackPublicURL,
temporalNamespace,
temporalMaxConcurrentWorkflowTaskPollers,
debug,
),
), nil
}
9 changes: 3 additions & 6 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/formancehq/payments/internal/api"
v2 "github.com/formancehq/payments/internal/api/v2"
v3 "github.com/formancehq/payments/internal/api/v3"
"github.com/formancehq/payments/internal/connectors/engine"
"github.com/spf13/cobra"
"go.uber.org/fx"
)
Expand All @@ -23,12 +24,6 @@ func newServer() *cobra.Command {
}
commonFlags(cmd)
cmd.Flags().String(ListenFlag, ":8080", "Listen address")
cmd.Flags().String(stackPublicURLFlag, "", "Stack public url")
// MaxConcurrentWorkflowTaskPollers should not be set to a number < 2, otherwise
// temporal will panic.
// After meeting with the temporal team, we decided to set it to 20 as per
// their recommendation.
cmd.Flags().Int(temporalMaxConcurrentWorkflowTaskPollersFlag, 20, "Max concurrent workflow task pollers")
return cmd
}

Expand All @@ -55,6 +50,7 @@ func runServer() func(cmd *cobra.Command, args []string) error {

func serverOptions(cmd *cobra.Command) (fx.Option, error) {
listen, _ := cmd.Flags().GetString(ListenFlag)
stack, _ := cmd.Flags().GetString(StackFlag)
return fx.Options(
fx.Provide(func() sharedapi.ServiceInfo {
return sharedapi.ServiceInfo{
Expand All @@ -65,5 +61,6 @@ func serverOptions(cmd *cobra.Command) (fx.Option, error) {
api.NewModule(listen, service.IsDebug(cmd)),
v2.NewModule(),
v3.NewModule(),
engine.Module(stack, service.IsDebug(cmd)),
), nil
}
2 changes: 1 addition & 1 deletion cmd/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ func newWorker() *cobra.Command {
RunE: runWorker(),
}
commonFlags(cmd)
cmd.Flags().String(stackPublicURLFlag, "", "Stack public url")
// MaxConcurrentWorkflowTaskPollers should not be set to a number < 2, otherwise
// temporal will panic.
// After meeting with the temporal team, we decided to set it to 20 as per
// their recommendation.
cmd.Flags().Int(temporalMaxConcurrentWorkflowTaskPollersFlag, 20, "Max concurrent workflow task pollers")
cmd.Flags().String(stackPublicURLFlag, "", "Stack public url")
return cmd
}

Expand Down
8 changes: 1 addition & 7 deletions internal/connectors/engine/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@ import (
"go.uber.org/fx"
)

func Module(
stack string,
stackURL string,
temporalNamespace string,
temporalMaxConcurrentWorkflowTaskPollers int,
debug bool,
) fx.Option {
func Module(stack string, debug bool) fx.Option {
ret := []fx.Option{
fx.Provide(func(
logger logging.Logger,
Expand Down

0 comments on commit a963682

Please sign in to comment.