Browse Source

libnetwork/networkdb: format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
32e716e848

+ 1 - 2
libnetwork/networkdb/delegate.go

@@ -215,7 +215,7 @@ func (nDB *NetworkDB) handleTableEvent(tEvent *TableEvent, isBulkSync bool) bool
 		// most likely the cluster is already aware of it
 		// This also reduce the possibility that deletion of entries close to their garbage collection ends up circuling around
 		// forever
-		//log.G(ctx).Infof("exiting on delete not knowing the obj with rebroadcast:%t", network.inSync)
+		// log.G(ctx).Infof("exiting on delete not knowing the obj with rebroadcast:%t", network.inSync)
 		return network.inSync && e.reapTime > nDB.config.reapEntryInterval/6
 	}
 
@@ -491,5 +491,4 @@ func (d *delegate) MergeRemoteState(buf []byte, isJoin bool) {
 
 		d.nDB.handleNetworkEvent(nEvent)
 	}
-
 }

+ 2 - 2
libnetwork/networkdb/networkdb.go

@@ -294,7 +294,7 @@ func (nDB *NetworkDB) Close() {
 		log.G(context.TODO()).Errorf("%v(%v) Could not close DB: %v", nDB.config.Hostname, nDB.config.NodeID, err)
 	}
 
-	//Avoid (*Broadcaster).run goroutine leak
+	// Avoid (*Broadcaster).run goroutine leak
 	nDB.broadcaster.Close()
 }
 
@@ -622,7 +622,7 @@ func (nDB *NetworkDB) JoinNetwork(nid string) error {
 	nodeNetworks[nid].entriesNumber.Store(entries)
 	nodeNetworks[nid].tableBroadcasts = &memberlist.TransmitLimitedQueue{
 		NumNodes: func() int {
-			//TODO fcrisciani this can be optimized maybe avoiding the lock?
+			// TODO fcrisciani this can be optimized maybe avoiding the lock?
 			// this call is done each GetBroadcasts call to evaluate the number of
 			// replicas for the message
 			nDB.RLock()

+ 5 - 3
libnetwork/networkdb/networkdb_test.go

@@ -23,7 +23,7 @@ import (
 var dbPort int32 = 10000
 
 func TestMain(m *testing.M) {
-	os.WriteFile("/proc/sys/net/ipv6/conf/lo/disable_ipv6", []byte{'0', '\n'}, 0644)
+	os.WriteFile("/proc/sys/net/ipv6/conf/lo/disable_ipv6", []byte{'0', '\n'}, 0o644)
 	logrus.SetLevel(logrus.ErrorLevel)
 	os.Exit(m.Run())
 }
@@ -851,9 +851,11 @@ func TestNetworkDBIslands(t *testing.T) {
 	node := dbs[0].nodes[dbs[0].config.NodeID]
 	baseIPStr := node.Addr.String()
 	// Node 0,1,2 are going to be the 3 bootstrap nodes
-	members := []string{fmt.Sprintf("%s:%d", baseIPStr, dbs[0].config.BindPort),
+	members := []string{
+		fmt.Sprintf("%s:%d", baseIPStr, dbs[0].config.BindPort),
 		fmt.Sprintf("%s:%d", baseIPStr, dbs[1].config.BindPort),
-		fmt.Sprintf("%s:%d", baseIPStr, dbs[2].config.BindPort)}
+		fmt.Sprintf("%s:%d", baseIPStr, dbs[2].config.BindPort),
+	}
 	// Rejoining will update the list of the bootstrap members
 	for i := 3; i < 5; i++ {
 		t.Logf("Re-joining: %d", i)

+ 1 - 1
libnetwork/networkdb/networkdbdiagnostic.go

@@ -391,7 +391,7 @@ func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
 	if ok {
 		table := nDB.GetTableByNetwork(tname, nid)
 		rsp := &diagnostic.TableObj{Length: len(table)}
-		var i = 0
+		i := 0
 		for k, v := range table {
 			var encodedValue string
 			if unsafe {