Moved updater into server

While we're only reacting to containers going away, it's more
convenient to bundle the docker events watcher into the server.

I've added a flag to switch it on; and switched it on by default in
the container.

I also implemented `Zone.DeleteRecordsFor(ident)`, which removes all
records for a particular container.

One minor change to the structure of the code is that the Zone is now
constructed *outside* the server, and given to it and the updater.
This commit is contained in:
Michael Bridgen committed 2014-10-16 15:38:32 +01:00
1 parent 0fb4bce24d
commit 0749460652
9 files changed
+102 -72

No files matched your search

+16
View File
@@ -10,6 +10,7 @@ import (
type Zone interface {
AddRecord(string, string, net.IP, net.IP, *net.IPNet) error
DeleteRecord(ident string, weave_ip net.IP) error
DeleteRecordsFor(ident string) error
MatchLocal(string) (net.IP, error)
}
@@ -99,3 +100,18 @@ func (zone *ZoneDb) DeleteRecord(ident string, weave_ip net.IP) error {
return nil
}
func (zone *ZoneDb) DeleteRecordsFor(ident string) error {
zone.mx.Lock()
defer zone.mx.Unlock()
w := 0 // write index
for _, r := range zone.recs {
if r.Ident != ident {
zone.recs[w] = r
w++
}
}
zone.recs = zone.recs[:w]
return nil
}