Sfoglia il codice sorgente

Merge pull request #144 from Shopify/robust-client-creation

Don't fail to create the client on LeaderNotAvailable
Evan Huus 11 anni fa
parent
commit
f5d5815754
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      client.go

+ 7 - 1
client.go

@@ -64,7 +64,13 @@ func NewClient(id string, addrs []string, config *ClientConfig) (*Client, error)
 
 	// do an initial fetch of all cluster metadata by specifing an empty list of topics
 	err := client.RefreshAllMetadata()
-	if err != nil {
+	switch err {
+	case nil:
+		break
+	case LeaderNotAvailable:
+		// indicates that maybe part of the cluster is down, but is not fatal to creating the client
+		Logger.Println(err)
+	default:
 		client.Close()
 		return nil, err
 	}