Skip to content

Commit

Permalink
Created Shard Manager Service (cadence-workflow#6297)
Browse files Browse the repository at this point in the history
* The first files for the shard manager service created

* Added testing for the shard manager startup

* make pr:

* forgot to pass the new factory

* Added obligatory dynamic configs for the shard manager service

* - Added goleak
- Renamed test
  • Loading branch information
jakobht authored Oct 1, 2024
1 parent 37b3c88 commit 45d5403
Show file tree
Hide file tree
Showing 15 changed files with 1,119 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cmd/server/cadence/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/uber/cadence/service/frontend"
"github.com/uber/cadence/service/history"
"github.com/uber/cadence/service/matching"
"github.com/uber/cadence/service/shardmanager"
"github.com/uber/cadence/service/worker"
)

Expand Down Expand Up @@ -267,6 +268,8 @@ func (s *server) startService() common.Daemon {
daemon, err = matching.NewService(&params)
case service.Worker:
daemon, err = worker.NewService(&params)
case service.ShardManager:
daemon, err = shardmanager.NewService(&params, resource.NewResourceFactory())
}
if err != nil {
params.Logger.Fatal("Fail to start "+s.name+" service ", tag.Error(err))
Expand Down
38 changes: 38 additions & 0 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,29 @@ const (
// Value type: Int
// Default value: 100
ESAnalyzerMinNumWorkflowsForAvg

// key for shard manager

// ShardManagerPersistenceMaxQPS is the max qps a shard manager host can query DB
// KeyName: shardManager.persistenceMaxQPS
// Value type: Int
// Default value: 3000
// Allowed filters: N/A
ShardManagerPersistenceMaxQPS
// ShardManagerPersistenceGlobalMaxQPS is the max qps matching cluster can query DB
// KeyName: shardManager.persistenceGlobalMaxQPS
// Value type: Int
// Default value: 0
// Allowed filters: N/A
ShardManagerPersistenceGlobalMaxQPS

// ShardManagerThrottledLogRPS is the rate limit on number of log messages emitted per second for throttled logger
// KeyName: shardManager.throttledLogRPS
// Value type: Int
// Default value: 20
// Allowed filters: N/A
ShardManagerThrottledLogRPS

// Usage: VisibilityArchivalQueryMaxRangeInDays is the maximum number of days for a visibility archival query
// KeyName: N/A
// Default value: N/A
Expand Down Expand Up @@ -3936,6 +3959,21 @@ var IntKeys = map[IntKey]DynamicInt{
Description: "ESAnalyzerMinNumWorkflowsForAvg controls how many workflows to have at least to rely on workflow run time avg per type",
DefaultValue: 100,
},
ShardManagerPersistenceMaxQPS: {
KeyName: "shardManager.persistenceMaxQPS",
Description: "ShardManagerPersistenceMaxQPS is the max qps shard manager host can query DB",
DefaultValue: 3000,
},
ShardManagerPersistenceGlobalMaxQPS: {
KeyName: "shardManager.persistenceGlobalMaxQPS",
Description: "ShardManagerPersistenceGlobalMaxQPS is the max qps shard manager cluster can query DB",
DefaultValue: 0,
},
ShardManagerThrottledLogRPS: {
KeyName: "shardManager.throttledLogRPS",
Description: "ShardManagerThrottledLogRPS is the rate limit on number of log messages emitted per second for throttled logger",
DefaultValue: 20,
},
VisibilityArchivalQueryMaxRangeInDays: {
KeyName: "frontend.visibilityArchivalQueryMaxRangeInDays",
Description: "VisibilityArchivalQueryMaxRangeInDays is the maximum number of days for a visibility archival query",
Expand Down
1 change: 1 addition & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const (
History
Matching
Worker
ShardManager
NumServices
)

Expand Down
10 changes: 10 additions & 0 deletions common/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination resource_mock.go -self_package github.com/uber/cadence/common/resource

package resource

import (
Expand Down Expand Up @@ -48,8 +50,16 @@ import (
"github.com/uber/cadence/common/persistence"
persistenceClient "github.com/uber/cadence/common/persistence/client"
"github.com/uber/cadence/common/quotas/global/rpc"
"github.com/uber/cadence/common/service"
)

type ResourceFactory interface {
NewResource(params *Params,
serviceName string,
serviceConfig *service.Config,
) (resource Resource, err error)
}

type (
// Resource is the interface which expose common resources
Resource interface {
Expand Down
13 changes: 13 additions & 0 deletions common/resource/resourceImpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ import (
"github.com/uber/cadence/common/service"
)

func NewResourceFactory() ResourceFactory {
return &resourceImplFactory{}
}

type resourceImplFactory struct{}

func (*resourceImplFactory) NewResource(params *Params,
serviceName string,
serviceConfig *service.Config,
) (resource Resource, err error) {
return New(params, serviceName, serviceConfig)
}

type (

// VisibilityManagerInitializer is the function each service should implement
Expand Down
Loading

0 comments on commit 45d5403

Please sign in to comment.