commit
1b4bcedf99
|
@ -4,6 +4,8 @@ etcd can now run as a transparent proxy. Running etcd as a proxy allows for easi
|
||||||
|
|
||||||
etcd currently supports two proxy modes: `readwrite` and `readonly`. The default mode is `readwrite`, which forwards both read and write requests to the etcd cluster. A `readonly` etcd proxy only forwards read requests to the etcd cluster, and returns `HTTP 501` to all write requests.
|
etcd currently supports two proxy modes: `readwrite` and `readonly`. The default mode is `readwrite`, which forwards both read and write requests to the etcd cluster. A `readonly` etcd proxy only forwards read requests to the etcd cluster, and returns `HTTP 501` to all write requests.
|
||||||
|
|
||||||
|
The proxy will shuffle the list of cluster members periodically to avoid sending all connections to a single member.
|
||||||
|
|
||||||
### Using an etcd proxy
|
### Using an etcd proxy
|
||||||
To start etcd in proxy mode, you need to provide three flags: `proxy`, `listen-client-urls`, and `initial-cluster` (or `discovery`).
|
To start etcd in proxy mode, you need to provide three flags: `proxy`, `listen-client-urls`, and `initial-cluster` (or `discovery`).
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"math/rand"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -65,6 +66,13 @@ func (d *director) refresh() {
|
||||||
}
|
}
|
||||||
endpoints = append(endpoints, newEndpoint(*uu))
|
endpoints = append(endpoints, newEndpoint(*uu))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shuffle array to avoid connections being "stuck" to a single endpoint
|
||||||
|
for i := range endpoints {
|
||||||
|
j := rand.Intn(i + 1)
|
||||||
|
endpoints[i], endpoints[j] = endpoints[j], endpoints[i]
|
||||||
|
}
|
||||||
|
|
||||||
d.ep = endpoints
|
d.ep = endpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue