mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
rafthttp: move new funcs to right place
This commit is contained in:
parent
478fab6aca
commit
e87cd0c17b
@ -48,27 +48,10 @@ var (
|
||||
errClusterIDMismatch = errors.New("cluster ID mismatch")
|
||||
)
|
||||
|
||||
func newSnapshotHandler(r Raft, snapSaver SnapshotSaver, cid types.ID) http.Handler {
|
||||
return &snapshotHandler{
|
||||
r: r,
|
||||
snapSaver: snapSaver,
|
||||
cid: cid,
|
||||
}
|
||||
}
|
||||
|
||||
type peerGetter interface {
|
||||
Get(id types.ID) Peer
|
||||
}
|
||||
|
||||
func newStreamHandler(peerGetter peerGetter, r Raft, id, cid types.ID) http.Handler {
|
||||
return &streamHandler{
|
||||
peerGetter: peerGetter,
|
||||
r: r,
|
||||
id: id,
|
||||
cid: cid,
|
||||
}
|
||||
}
|
||||
|
||||
type writerToResponse interface {
|
||||
WriteTo(w http.ResponseWriter)
|
||||
}
|
||||
@ -140,6 +123,14 @@ type snapshotHandler struct {
|
||||
cid types.ID
|
||||
}
|
||||
|
||||
func newSnapshotHandler(r Raft, snapSaver SnapshotSaver, cid types.ID) http.Handler {
|
||||
return &snapshotHandler{
|
||||
r: r,
|
||||
snapSaver: snapSaver,
|
||||
cid: cid,
|
||||
}
|
||||
}
|
||||
|
||||
// ServeHTTP serves HTTP request to receive and process snapshot message.
|
||||
//
|
||||
// If request sender dies without closing underlying TCP connection,
|
||||
@ -211,6 +202,15 @@ type streamHandler struct {
|
||||
cid types.ID
|
||||
}
|
||||
|
||||
func newStreamHandler(peerGetter peerGetter, r Raft, id, cid types.ID) http.Handler {
|
||||
return &streamHandler{
|
||||
peerGetter: peerGetter,
|
||||
r: r,
|
||||
id: id,
|
||||
cid: cid,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *streamHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != "GET" {
|
||||
w.Header().Set("Allow", "GET")
|
||||
|
Loading…
x
Reference in New Issue
Block a user