Skip to content

Commit

Permalink
bump to go 1.11.5 (#79)
Browse files Browse the repository at this point in the history
* bump to go 1.11.5

* housekeeping
  • Loading branch information
jencarlucci authored and jswarren4 committed Mar 7, 2019
1 parent 275ce1c commit 53d560e
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 76 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: go
go:
- 1.9.2
- 1.10.3
- 1.11.5
- tip

matrix:
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ test:
.PHONY: vet
vet:
go vet ${GOPACKAGES}

.PHONY: dofmt
dofmt:
gofmt -l -s -w ${GOFILES}
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ of keys based on the gin attribute syntax and the comparison to literals or othe
keys. These rules can be nested inside of AND, OR and NOT rules to enable the expression
of complex relationships of values in etcd and the actions to be triggered when a set
of conditions has been met. The engine watches etcd for updates and crawls the data tree
at configurable intervals so that changes that occurred beyond the watch time scope are picked
up and actions triggered by watches that initially failed can be retried without being lost.
This library makes use of the IBM-Cloud/go-etcd-lock library to enable concurrent monitoring
by multiple application instances without collisions--the first client to obtain the lock
processes the change while the others quickly fail to acquire the lock and move on. A trigger
callback function should update the model if the action is successful so it is not retriggered.
Recurring actions, such as continuous polling, can be implemented with rules that reference
nodes with TTLs such that the expiration of a node triggers a rule and the callback adds back
a node with the same key and TTL.
at configurable intervals. This library makes use of the IBM-Cloud/go-etcd-lock library
to enable concurrent monitoring by multiple application instances without collisions--the
first client to obtain the lock processes the change while the others quickly fail to acquire
the lock and move on. A trigger callback function should update the model if the action
is successful so it is not retriggered. Recurring actions, such as continuous polling,
can be implemented with rules that reference nodes with TTLs such that the expiration of
a node triggers a rule and the callback adds back a node with the same key and TTL.

Import
------
Expand Down
2 changes: 1 addition & 1 deletion rules/dynamic_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func processBooleanMap(keys []string, parent map[string]bool, value bool, proc f
}

func (krp *dynamicRule) getLeafRepresentationPatternMap() map[string][]string {
out := map[string][]string{krp.rep: []string{}}
out := map[string][]string{krp.rep: {}}
for _, pattern := range krp.patterns {
out[krp.rep] = append(out[krp.rep], pattern)
}
Expand Down
30 changes: 15 additions & 15 deletions rules/dynamic_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func newExpandedEqualsLiteralRule(key string, value *string) DynamicRule {
if err != nil {
return nil
}
rules, _ := rule.Expand(map[string][]string{"region": []string{"us"}})
rules, _ := rule.Expand(map[string][]string{"region": {"us"}})
return rules[0]
}

Expand All @@ -255,7 +255,7 @@ func newExpandedEqualsRule(keys []string) DynamicRule {
if err != nil {
return nil
}
rules, _ := rule.Expand(map[string][]string{"region": []string{"us"}})
rules, _ := rule.Expand(map[string][]string{"region": {"us"}})
return rules[0]
}

Expand Down Expand Up @@ -358,7 +358,7 @@ func TestRuleSatisfied(t *testing.T) {
true,
map[string]string{
"/emea/branch/parent/fef460923d2248bf99da87f8d4b1c363/child/child-home-fef460923d2248bf99da87f8d4b1c363-c1/attributes/location/value": "home",
"/updater/emea/child/location/enabled": "true",
"/updater/emea/child/location/enabled": "true",
},
},
{
Expand All @@ -370,7 +370,7 @@ func TestRuleSatisfied(t *testing.T) {
false,
map[string]string{
"/emea/branch/parent/fef460923d2248bf99da87f8d4b1c363/child/child-home-fef460923d2248bf99da87f8d4b1c363-c1/attributes/location/value": "home",
"/updater/emea/child/location/enabled": "true",
"/updater/emea/child/location/enabled": "true",
},
},
}
Expand Down Expand Up @@ -465,53 +465,53 @@ func TestGetLeafRepresentationPatternMap(t *testing.T) {
nil,
func() (DynamicRule, error) { return NewEqualsLiteralRule("/:region/test", nil) },
map[string][]string{
"/:region/test = <nil>": []string{"/:region/test"},
"/:region/test = <nil>": {"/:region/test"},
},
},
{
nil,
func() (DynamicRule, error) { return NewEqualsLiteralRule("/:region/test2", sTP("value")) },
map[string][]string{
"/:region/test2 = \"value\"": []string{"/:region/test2"},
"/:region/test2 = \"value\"": {"/:region/test2"},
},
},
{
func() DynamicRule { return NewAndRule(rules[0], rules[1]) },
nil,
map[string][]string{
"/:region/test = <nil>": []string{"/:region/test"},
"/:region/test2 = \"value\"": []string{"/:region/test2"},
"/:region/test = <nil>": {"/:region/test"},
"/:region/test2 = \"value\"": {"/:region/test2"},
},
},
{
func() DynamicRule { return NewOrRule(rules[0], rules[1]) },
nil,
map[string][]string{
"/:region/test = <nil>": []string{"/:region/test"},
"/:region/test2 = \"value\"": []string{"/:region/test2"},
"/:region/test = <nil>": {"/:region/test"},
"/:region/test2 = \"value\"": {"/:region/test2"},
},
},
{
func() DynamicRule { return NewOrRule(rules[2], rules[3]) },
nil,
map[string][]string{
"/:region/test = <nil>": []string{"/:region/test"},
"/:region/test2 = \"value\"": []string{"/:region/test2"},
"/:region/test = <nil>": {"/:region/test"},
"/:region/test2 = \"value\"": {"/:region/test2"},
},
},
{
func() DynamicRule { return NewNotRule(rules[4]) },
nil,
map[string][]string{
"/:region/test = <nil>": []string{"/:region/test"},
"/:region/test2 = \"value\"": []string{"/:region/test2"},
"/:region/test = <nil>": {"/:region/test"},
"/:region/test2 = \"value\"": {"/:region/test2"},
},
},
{
nil,
func() (DynamicRule, error) { return NewEqualsRule([]string{"/:region/test", "/:region/test2"}) },
map[string][]string{
"/:region/test = /:region/test2": []string{"/:region/test", "/:region/test2"},
"/:region/test = /:region/test2": {"/:region/test", "/:region/test2"},
},
},
}
Expand Down
20 changes: 10 additions & 10 deletions rules/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"golang.org/x/net/context"
)

type stopable interface {
type stoppable interface {
stop()
isStopped() bool
}
Expand All @@ -35,9 +35,9 @@ type baseEngine struct {
ruleLockTTLs map[int]int
ruleMgr ruleManager
stopped uint32
crawlers []stopable
watchers []stopable
workers []stopable
crawlers []stoppable
watchers []stoppable
workers []stoppable
}

type channelCloser func()
Expand Down Expand Up @@ -141,9 +141,9 @@ func (e *baseEngine) Shutdown(ctx context.Context) error {

func (e *baseEngine) stop() {
e.logger.Debug("Stopping crawlers")
stopStopables(e.crawlers)
stopstoppables(e.crawlers)
e.logger.Debug("Stopping watchers")
stopStopables(e.watchers)
stopstoppables(e.watchers)
e.logger.Debug("Stopping workers")
for _, worker := range e.workers {
worker.stop()
Expand All @@ -153,19 +153,19 @@ func (e *baseEngine) stop() {
// Ensure workers are stopped; the "stop" method is called again, but
// that is idempotent. The workers' "stop" method must be called before
// the channel is closed in order to avoid nil pointer dereference panics.
stopStopables(e.workers)
stopstoppables(e.workers)
atomicSet(&e.stopped, true)
e.logger.Info("Engine stopped")
}

func stopStopables(stopables []stopable) {
for _, s := range stopables {
func stopstoppables(stoppables []stoppable) {
for _, s := range stoppables {
s.stop()
}
allStopped := false
for !allStopped {
allStopped = true
for _, s := range stopables {
for _, s := range stoppables {
allStopped = allStopped && s.isStopped()
}
}
Expand Down
2 changes: 1 addition & 1 deletion rules/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestBasic(t *testing.T) {
t.Fail()
}
prefixes := km.getPrefixesWithConstraints(map[string]constraint{
"name": constraint{
"name": {
prefix: "xy",
chars: [][]rune{{'a', 'b'}, {'a', 'b'}},
},
Expand Down
6 changes: 3 additions & 3 deletions rules/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ func TestEngineOptions(t *testing.T) {
assert.Equal(t, 1, opts.syncDelay)
opts = makeEngineOptions(EngineConcurrency(10))
assert.Equal(t, 10, opts.concurrency)
keyExp1 := KeyExpansion(map[string][]string{"key1": []string{"val1"}, "key2": []string{"val2"}})
keyExp2 := KeyExpansion(map[string][]string{"key2": []string{"val3"}, "key3": []string{"val4"}})
keyExp1 := KeyExpansion(map[string][]string{"key1": {"val1"}, "key2": {"val2"}})
keyExp2 := KeyExpansion(map[string][]string{"key2": {"val3"}, "key3": {"val4"}})
opts = makeEngineOptions(keyExp1, keyExp2)
assert.Equal(t, map[string][]string{"key1": []string{"val1"}, "key2": []string{"val3"}, "key3": []string{"val4"}}, opts.keyExpansion)
assert.Equal(t, map[string][]string{"key1": {"val1"}, "key2": {"val3"}, "key3": {"val4"}}, opts.keyExpansion)
opts = makeEngineOptions(EngineSyncDelay(10))
assert.Equal(t, 10, opts.syncDelay)
opts = makeEngineOptions(EngineWatchTimeout(3))
Expand Down
2 changes: 1 addition & 1 deletion rules/rule_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestCombineRuleData(t *testing.T) {
expectedData []string
}{
{
[][]string{[]string{"/a/b/c", "/x/y/z"}, []string{"/a/b/c"}},
[][]string{{"/a/b/c", "/x/y/z"}, {"/a/b/c"}},
[]string{"/a/b/c", "/x/y/z"},
},
}
Expand Down
Loading

0 comments on commit 53d560e

Please sign in to comment.