Some more (inelegant) multiple listener code plus some reconfigure support

This commit is contained in:
Neil Alexander 2019-03-04 18:41:32 +00:00
parent be8db0c120
commit 82bb95b77f
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
5 changed files with 103 additions and 31 deletions

View file

@ -76,3 +76,20 @@ func FuncTimeout(f func(), timeout time.Duration) bool {
return false
}
}
// This calculates the difference between two arrays and returns items
// that appear in A but not in B - useful somewhat when reconfiguring
// and working out what configuration items changed
func Difference(a, b []string) []string {
ab := []string{}
mb := map[string]bool{}
for _, x := range b {
mb[x] = true
}
for _, x := range a {
if _, ok := mb[x]; !ok {
ab = append(ab, x)
}
}
return ab
}