1// Copyright 2015 CoreOS, Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package rafthttp 16 17import ( 18 "github.com/coreos/etcd/pkg/types" 19 "github.com/coreos/etcd/raft/raftpb" 20) 21 22type remote struct { 23 id types.ID 24 status *peerStatus 25 pipeline *pipeline 26} 27 28func startRemote(tr *Transport, urls types.URLs, local, to, cid types.ID, r Raft, errorc chan error) *remote { 29 picker := newURLPicker(urls) 30 status := newPeerStatus(to) 31 return &remote{ 32 id: to, 33 status: status, 34 pipeline: newPipeline(tr, picker, local, to, cid, status, nil, r, errorc), 35 } 36} 37 38func (g *remote) send(m raftpb.Message) { 39 select { 40 case g.pipeline.msgc <- m: 41 default: 42 if g.status.isActive() { 43 plog.MergeWarningf("dropped internal raft message to %s since sending buffer is full (bad/overloaded network)", g.id) 44 } 45 plog.Debugf("dropped %s to %s since sending buffer is full", m.Type, g.id) 46 } 47} 48 49func (g *remote) stop() { 50 g.pipeline.stop() 51} 52