Explorar el Código

libnetwork/networkdb: NetworkDB.Watch(): remove unused "key" argument

This function was implemented in https://github.com/moby/libnetwork/commit/dd4950f36d0a568791ead9398ddd175451ae36fa
which added a "key" field, but that field was never used anywhere, and
still appears unused.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn hace 2 años
padre
commit
332ffe8d74

+ 3 - 3
libnetwork/agent.go

@@ -312,9 +312,9 @@ func (c *Controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr, d
 	c.DiagnosticServer.RegisterHandler(nDB, networkdb.NetDbPaths2Func)
 
 	var cancelList []func()
-	ch, cancel := nDB.Watch(libnetworkEPTable, "", "")
+	ch, cancel := nDB.Watch(libnetworkEPTable, "")
 	cancelList = append(cancelList, cancel)
-	nodeCh, cancel := nDB.Watch(networkdb.NodeTable, "", "")
+	nodeCh, cancel := nDB.Watch(networkdb.NodeTable, "")
 	cancelList = append(cancelList, cancel)
 
 	c.mu.Lock()
@@ -783,7 +783,7 @@ func (n *network) addDriverWatches() {
 		return
 	}
 	for _, table := range n.driverTables {
-		ch, cancel := agent.networkDB.Watch(table.name, n.ID(), "")
+		ch, cancel := agent.networkDB.Watch(table.name, n.ID())
 		agent.Lock()
 		agent.driverCancelFuncs[n.ID()] = append(agent.driverCancelFuncs[n.ID()], cancel)
 		agent.Unlock()

+ 1 - 1
libnetwork/cmd/networkdb-test/dummyclient/dummyClient.go

@@ -45,7 +45,7 @@ func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
 
 	nDB, ok := ctx.(*networkdb.NetworkDB)
 	if ok {
-		ch, cancel := nDB.Watch(tableName, "", "")
+		ch, cancel := nDB.Watch(tableName, "")
 		clientWatchTable[tableName] = tableHandler{cancelWatch: cancel, entries: make(map[string]string)}
 		go handleTableEvents(tableName, ch)
 

+ 1 - 1
libnetwork/networkdb/networkdb_test.go

@@ -368,7 +368,7 @@ func TestNetworkDBWatch(t *testing.T) {
 	err = dbs[1].JoinNetwork("network1")
 	assert.NilError(t, err)
 
-	ch, cancel := dbs[1].Watch("", "", "")
+	ch, cancel := dbs[1].Watch("", "")
 
 	err = dbs[0].CreateEntry("test_table", "network1", "test_key", []byte("test_value"))
 	assert.NilError(t, err)

+ 3 - 7
libnetwork/networkdb/watch.go

@@ -39,14 +39,14 @@ type UpdateEvent event
 type DeleteEvent event
 
 // Watch creates a watcher with filters for a particular table or
-// network or key or any combination of the tuple. If any of the
+// network or any combination of the tuple. If any of the
 // filter is an empty string it acts as a wildcard for that
 // field. Watch returns a channel of events, where the events will be
 // sent.
-func (nDB *NetworkDB) Watch(tname, nid, key string) (*events.Channel, func()) {
+func (nDB *NetworkDB) Watch(tname, nid string) (*events.Channel, func()) {
 	var matcher events.Matcher
 
-	if tname != "" || nid != "" || key != "" {
+	if tname != "" || nid != "" {
 		matcher = events.MatcherFunc(func(ev events.Event) bool {
 			var evt event
 			switch ev := ev.(type) {
@@ -66,10 +66,6 @@ func (nDB *NetworkDB) Watch(tname, nid, key string) (*events.Channel, func()) {
 				return false
 			}
 
-			if key != "" && evt.Key != key {
-				return false
-			}
-
 			return true
 		})
 	}