Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobht committed Nov 27, 2024
1 parent d05953c commit e6c31f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 5 additions & 1 deletion service/sharddistributor/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"context"
"sync"

"github.com/uber/cadence/client/history"
"github.com/uber/cadence/client/matching"
"github.com/uber/cadence/common/log"
"github.com/uber/cadence/common/metrics"
Expand All @@ -36,14 +37,16 @@ func NewHandler(
logger log.Logger,
metricsClient metrics.Client,
matchingPeerResolver matching.PeerResolver,
historyPeerResolver history.PeerResolver,
) Handler {
handler := &handlerImpl{
logger: logger,
metricsClient: metricsClient,
matchingPeerResolver: matchingPeerResolver,
historyPeerResolver: historyPeerResolver,
}

// prevent us from trying to serve requests before matching engine is started and ready
// prevent us from trying to serve requests before shard distributor is started and ready
handler.startWG.Add(1)
return handler
}
Expand All @@ -52,6 +55,7 @@ type handlerImpl struct {
logger log.Logger
metricsClient metrics.Client
matchingPeerResolver matching.PeerResolver
historyPeerResolver history.PeerResolver
startWG sync.WaitGroup
}

Expand Down
22 changes: 13 additions & 9 deletions service/sharddistributor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package sharddistributor
import (
"sync/atomic"

"github.com/uber/cadence/client/history"
"github.com/uber/cadence/client/matching"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/dynamicconfig"
Expand All @@ -38,10 +39,11 @@ import (
type Service struct {
resource.Resource

status int32
handler handler.Handler
stopC chan struct{}
config *config.Config
status int32
handler handler.Handler
stopC chan struct{}
config *config.Config
numHistoryShards int
}

// NewService builds a new task manager service
Expand Down Expand Up @@ -75,10 +77,11 @@ func NewService(
}

return &Service{
Resource: serviceResource,
status: common.DaemonStatusInitialized,
config: serviceConfig,
stopC: make(chan struct{}),
Resource: serviceResource,
status: common.DaemonStatusInitialized,
config: serviceConfig,
stopC: make(chan struct{}),
numHistoryShards: params.PersistenceConfig.NumHistoryShards,
}, nil
}

Expand All @@ -92,8 +95,9 @@ func (s *Service) Start() {
logger.Info("shard distributor starting")

matchingPeerResolver := matching.NewPeerResolver(s.GetMembershipResolver(), membership.PortGRPC)
historyPeerResolver := history.NewPeerResolver(s.numHistoryShards, s.GetMembershipResolver(), membership.PortGRPC)

s.handler = handler.NewHandler(s.GetLogger(), s.GetMetricsClient(), matchingPeerResolver)
s.handler = handler.NewHandler(s.GetLogger(), s.GetMetricsClient(), matchingPeerResolver, historyPeerResolver)

grpcHandler := grpc.NewGRPCHandler(s.handler)
grpcHandler.Register(s.GetDispatcher())
Expand Down

0 comments on commit e6c31f4

Please sign in to comment.