Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

Commit

Permalink
Rename match modes
Browse files Browse the repository at this point in the history
  • Loading branch information
xichen2020 committed Jun 18, 2017
1 parent 3de81fe commit 6425c66
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
10 changes: 5 additions & 5 deletions rules/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ type MatchMode int

// List of supported match modes.
const (
// When performing matches in Forward mode, the matcher matches the given id against
// When performing matches in ForwardMatch mode, the matcher matches the given id against
// both the mapping rules and rollup rules to find out the applicable mapping policies
// and rollup policies.
Forward MatchMode = iota
ForwardMatch MatchMode = iota

// When performing matches in Reverse mode, the matcher find the applicable mapping
// When performing matches in ReverseMatch mode, the matcher find the applicable mapping
// policies for the given id.
Reverse
ReverseMatch
)

// Matcher matches metrics against rules to determine applicable policies.
Expand Down Expand Up @@ -113,7 +113,7 @@ func (as *activeRuleSet) MatchAll(
fromNanos, toNanos int64,
matchMode MatchMode,
) MatchResult {
if matchMode == Forward {
if matchMode == ForwardMatch {
return as.matchAllForward(id, fromNanos, toNanos)
}
return as.matchAllReverse(id, fromNanos, toNanos)
Expand Down
66 changes: 33 additions & 33 deletions rules/ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestActiveRuleSetMappingPoliciesForNonRollupID(t *testing.T) {
id: "mtagName1=mtagValue1",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -69,7 +69,7 @@ func TestActiveRuleSetMappingPoliciesForNonRollupID(t *testing.T) {
id: "mtagName1=mtagValue1",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -87,7 +87,7 @@ func TestActiveRuleSetMappingPoliciesForNonRollupID(t *testing.T) {
id: "mtagName1=mtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -103,15 +103,15 @@ func TestActiveRuleSetMappingPoliciesForNonRollupID(t *testing.T) {
id: "mtagName1=mtagValue3",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: policy.DefaultPoliciesList,
},
{
id: "mtagName1=mtagValue1",
matchFrom: 10000,
matchTo: 40000,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestActiveRuleSetMappingPoliciesForNonRollupID(t *testing.T) {
id: "mtagName1=mtagValue2",
matchFrom: 10000,
matchTo: 40000,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.PoliciesList{
policy.DefaultStagedPolicies,
Expand Down Expand Up @@ -211,7 +211,7 @@ func TestActiveRuleSetMappingPoliciesForRollupID(t *testing.T) {
id: "rName4|rtagName1=rtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Reverse,
matchMode: ReverseMatch,
expireAtNanos: 30000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -227,23 +227,23 @@ func TestActiveRuleSetMappingPoliciesForRollupID(t *testing.T) {
id: "rName4|rtagName2=rtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Reverse,
matchMode: ReverseMatch,
expireAtNanos: 30000,
result: nil,
},
{
id: "rName4|rtagName1=rtagValue2",
matchFrom: 10000,
matchTo: 10001,
matchMode: Reverse,
matchMode: ReverseMatch,
expireAtNanos: 15000,
result: nil,
},
{
id: "rName3|rtagName1=rtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Reverse,
matchMode: ReverseMatch,
expireAtNanos: 30000,
result: nil,
},
Expand Down Expand Up @@ -273,7 +273,7 @@ func TestActiveRuleSetRollupResults(t *testing.T) {
id: "rtagName1=rtagValue1,rtagName2=rtagValue2,rtagName3=rtagValue3",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: []RollupResult{
{
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestActiveRuleSetRollupResults(t *testing.T) {
id: "rtagName1=rtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: []RollupResult{
{
Expand All @@ -330,15 +330,15 @@ func TestActiveRuleSetRollupResults(t *testing.T) {
id: "rtagName5=rtagValue5",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: []RollupResult{},
},
{
id: "rtagName1=rtagValue1,rtagName2=rtagValue2,rtagName3=rtagValue3",
matchFrom: 10000,
matchTo: 40000,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: []RollupResult{
{
Expand Down Expand Up @@ -498,7 +498,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue1",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -518,7 +518,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue1",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -536,7 +536,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -552,7 +552,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue3",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: policy.DefaultPoliciesList,
},
Expand All @@ -562,7 +562,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName1=rtagValue1,rtagName2=rtagValue2,rtagName3=rtagValue3",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: []RollupResult{
{
Expand Down Expand Up @@ -598,7 +598,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName1=rtagValue2",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: []RollupResult{
{
Expand All @@ -619,7 +619,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName5=rtagValue5",
matchFrom: 25000,
matchTo: 25001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 30000,
result: []RollupResult{},
},
Expand All @@ -632,7 +632,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue1",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -650,7 +650,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue2",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -666,7 +666,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue3",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: policy.DefaultPoliciesList,
},
Expand All @@ -676,7 +676,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName1=rtagValue1,rtagName2=rtagValue2,rtagName3=rtagValue3",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: []RollupResult{
{
Expand All @@ -699,7 +699,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName1=rtagValue2",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: []RollupResult{
{
Expand All @@ -720,7 +720,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName5=rtagValue5",
matchFrom: 35000,
matchTo: 35001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: 100000,
result: []RollupResult{},
},
Expand All @@ -733,7 +733,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue1",
matchFrom: 250000,
matchTo: 250001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: timeNanosMax,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -751,7 +751,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue2",
matchFrom: 250000,
matchTo: 250001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: timeNanosMax,
result: policy.PoliciesList{
policy.NewStagedPolicies(
Expand All @@ -767,7 +767,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "mtagName1=mtagValue3",
matchFrom: 250000,
matchTo: 250001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: timeNanosMax,
result: policy.DefaultPoliciesList,
},
Expand All @@ -777,7 +777,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName1=rtagValue1,rtagName2=rtagValue2,rtagName3=rtagValue3",
matchFrom: 250000,
matchTo: 250001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: timeNanosMax,
result: []RollupResult{
{
Expand Down Expand Up @@ -812,7 +812,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName1=rtagValue2",
matchFrom: 250000,
matchTo: 250001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: timeNanosMax,
result: []RollupResult{
{
Expand All @@ -833,7 +833,7 @@ func TestRuleSetActiveSet(t *testing.T) {
id: "rtagName5=rtagValue5",
matchFrom: 250000,
matchTo: 250001,
matchMode: Forward,
matchMode: ForwardMatch,
expireAtNanos: timeNanosMax,
result: []RollupResult{},
},
Expand Down

0 comments on commit 6425c66

Please sign in to comment.