ソースを参照

embed: Make immutable defaults constant

This changes the two immutable defaults into constants which allows
packages embedding etcd to import them as const! If they are variables,
then you'll fail with "const initializer foo is not a constant".
James Shubin 9 年 前
コミット
745cd730a7
1 ファイル変更3 行追加2 行削除
  1. 3 2
      embed/config.go

+ 3 - 2
embed/config.go

@@ -39,6 +39,9 @@ const (
 	DefaultMaxSnapshots = 5
 	DefaultMaxSnapshots = 5
 	DefaultMaxWALs      = 5
 	DefaultMaxWALs      = 5
 
 
+	DefaultListenPeerURLs   = "http://localhost:2380"
+	DefaultListenClientURLs = "http://localhost:2379"
+
 	// maxElectionMs specifies the maximum value of election timeout.
 	// maxElectionMs specifies the maximum value of election timeout.
 	// More details are listed in ../Documentation/tuning.md#time-parameters.
 	// More details are listed in ../Documentation/tuning.md#time-parameters.
 	maxElectionMs = 50000
 	maxElectionMs = 50000
@@ -49,8 +52,6 @@ var (
 		"Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"")
 		"Choose one of \"initial-cluster\", \"discovery\" or \"discovery-srv\"")
 	ErrUnsetAdvertiseClientURLsFlag = fmt.Errorf("--advertise-client-urls is required when --listen-client-urls is set explicitly")
 	ErrUnsetAdvertiseClientURLsFlag = fmt.Errorf("--advertise-client-urls is required when --listen-client-urls is set explicitly")
 
 
-	DefaultListenPeerURLs           = "http://localhost:2380"
-	DefaultListenClientURLs         = "http://localhost:2379"
 	DefaultInitialAdvertisePeerURLs = "http://localhost:2380"
 	DefaultInitialAdvertisePeerURLs = "http://localhost:2380"
 	DefaultAdvertiseClientURLs      = "http://localhost:2379"
 	DefaultAdvertiseClientURLs      = "http://localhost:2379"