Skip to content

Commit

Permalink
Config worker use public frontend endpoint (#3162)
Browse files Browse the repository at this point in the history
* Config worker use public frontend endpoint

* Update integration test
  • Loading branch information
yux0 committed Jul 29, 2022
1 parent 8dea880 commit a1d1650
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
7 changes: 6 additions & 1 deletion host/onebox.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,16 @@ func (c *temporalImpl) startWorker(hosts map[string][]string, startWG *sync.Wait
var workerService *worker.Service
var clientBean client.Bean
var namespaceRegistry namespace.Registry

clientConfig := &config.Config{
PublicClient: config.PublicClient{
HostPort: c.FrontendGRPCAddress(),
},
}
app := fx.New(
fx.Supply(
stoppedCh,
persistenceConfig,
clientConfig,
),
fx.Provide(func() metrics.Reporter { return metrics.NoopReporter }),
fx.Provide(func() resource.ServiceName { return resource.ServiceName(serviceName) }),
Expand Down
19 changes: 19 additions & 0 deletions service/worker/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ package worker
import (
"context"

"go.temporal.io/api/workflowservice/v1"
"go.uber.org/fx"

"go.temporal.io/server/client"
"go.temporal.io/server/common"
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/dynamicconfig"
Expand All @@ -48,12 +50,22 @@ import (
"go.temporal.io/server/service/worker/scheduler"
)

const (
localFrontendClient = "localFrontendClient"
)

var Module = fx.Options(
migration.Module,
addsearchattributes.Module,
resource.Module,
deletenamespace.Module,
scheduler.Module,
fx.Provide(
fx.Annotated{
Name: localFrontendClient,
Target: FrontendClientProvider,
},
),
fx.Provide(VisibilityManagerProvider),
fx.Provide(dynamicconfig.NewCollection),
fx.Provide(ThrottledLoggerRpsFnProvider),
Expand Down Expand Up @@ -86,6 +98,13 @@ func ConfigProvider(
)
}

func FrontendClientProvider(
cfg *config.Config,
clientFactory client.Factory,
) (workflowservice.WorkflowServiceClient, error) {
return clientFactory.NewFrontendClient(cfg.PublicClient.HostPort)
}

func VisibilityManagerProvider(
logger log.Logger,
metricsClient metrics.Client,
Expand Down
2 changes: 1 addition & 1 deletion service/worker/migration/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type (
ExecutionManager persistence.ExecutionManager
NamespaceRegistry namespace.Registry
HistoryClient historyservice.HistoryServiceClient
FrontendClient workflowservice.WorkflowServiceClient
FrontendClient workflowservice.WorkflowServiceClient `name:"localFrontendClient"`
Logger log.Logger
MetricsClient metrics.Client
}
Expand Down
2 changes: 1 addition & 1 deletion service/worker/scheduler/fx.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type (
MetricsClient metrics.Client
Logger log.Logger
HistoryClient historyservice.HistoryServiceClient
FrontendClient workflowservice.WorkflowServiceClient
FrontendClient workflowservice.WorkflowServiceClient `name:"localFrontendClient"`
}

fxResult struct {
Expand Down

0 comments on commit a1d1650

Please sign in to comment.