MCPcopy Create free account
hub / github.com/cortexproject/cortex / NewOp

Function NewOp

pkg/ring/ring.go:1012–1027  ·  view source on GitHub ↗

NewOp constructs new Operation with given "healthy" states for operation, and optional function to extend replica set. Result of calling shouldExtendReplicaSet is cached.

(healthyStates []InstanceState, shouldExtendReplicaSet func(s InstanceState) bool)

Source from the content-addressed store, hash-verified

1010// NewOp constructs new Operation with given "healthy" states for operation, and optional function to extend replica set.
1011// Result of calling shouldExtendReplicaSet is cached.
1012func NewOp(healthyStates []InstanceState, shouldExtendReplicaSet func(s InstanceState) bool) Operation {
1013 op := Operation(0)
1014 for _, s := range healthyStates {
1015 op |= (1 << s)
1016 }
1017
1018 if shouldExtendReplicaSet != nil {
1019 for _, s := range []InstanceState{ACTIVE, LEAVING, PENDING, JOINING, LEFT, READONLY} {
1020 if shouldExtendReplicaSet(s) {
1021 op |= (0x10000 << s)
1022 }
1023 }
1024 }
1025
1026 return op
1027}
1028
1029// IsInstanceInStateHealthy is used during "filtering" phase to remove undesired instances based on their state.
1030func (op Operation) IsInstanceInStateHealthy(s InstanceState) bool {

Callers 9

gateway_ring.goFile · 0.92
compactor.goFile · 0.92
converter.goFile · 0.92
ruler_ring.goFile · 0.92
ring.goFile · 0.85

Calls 1

OperationTypeAlias · 0.70