diff --git a/etcdserver/etcdhttp/peer.go b/etcdserver/etcdhttp/peer.go index 73441fe35..f142f7089 100644 --- a/etcdserver/etcdhttp/peer.go +++ b/etcdserver/etcdhttp/peer.go @@ -19,7 +19,7 @@ import ( "net/http" "github.com/coreos/etcd/etcdserver" - "github.com/coreos/etcd/lease" + "github.com/coreos/etcd/lease/leasehttp" "github.com/coreos/etcd/rafthttp" ) @@ -32,7 +32,7 @@ const ( func NewPeerHandler(s *etcdserver.EtcdServer) http.Handler { var lh http.Handler if l := s.Lessor(); l != nil { - lh = lease.NewHandler(l) + lh = leasehttp.NewHandler(l) } return newPeerHandler(s.Cluster(), s.RaftHandler(), lh) } diff --git a/etcdserver/v3demo_server.go b/etcdserver/v3demo_server.go index 9502b1fe1..9f0bb40b5 100644 --- a/etcdserver/v3demo_server.go +++ b/etcdserver/v3demo_server.go @@ -24,6 +24,7 @@ import ( "github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" "github.com/coreos/etcd/lease" + "github.com/coreos/etcd/lease/leasehttp" dstorage "github.com/coreos/etcd/storage" "github.com/coreos/etcd/storage/storagepb" ) @@ -139,7 +140,7 @@ func (s *EtcdServer) LeaseRenew(id lease.LeaseID) (int64, error) { for _, url := range leader.PeerURLs { lurl := url + "/leases" - ttl, err = lease.RenewHTTP(id, lurl, s.cfg.PeerTLSInfo, s.cfg.peerDialTimeout()) + ttl, err = leasehttp.RenewHTTP(id, lurl, s.cfg.PeerTLSInfo, s.cfg.peerDialTimeout()) if err == nil { break } diff --git a/lease/http.go b/lease/leasehttp/http.go similarity index 90% rename from lease/http.go rename to lease/leasehttp/http.go index bd4ffa24d..53cde2d8d 100644 --- a/lease/http.go +++ b/lease/leasehttp/http.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package lease +package leasehttp import ( "bytes" @@ -22,15 +22,16 @@ import ( "time" pb "github.com/coreos/etcd/etcdserver/etcdserverpb" + "github.com/coreos/etcd/lease" "github.com/coreos/etcd/pkg/transport" ) // NewHandler returns an http Handler for lease renewals -func NewHandler(l Lessor) http.Handler { +func NewHandler(l lease.Lessor) http.Handler { return &leaseHandler{l} } -type leaseHandler struct{ l Lessor } +type leaseHandler struct{ l lease.Lessor } func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.Method != "POST" { @@ -50,7 +51,7 @@ func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - ttl, err := h.l.Renew(LeaseID(lreq.ID)) + ttl, err := h.l.Renew(lease.LeaseID(lreq.ID)) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -69,7 +70,7 @@ func (h *leaseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // RenewHTTP renews a lease at a given primary server. -func RenewHTTP(id LeaseID, url string, tlsInfo transport.TLSInfo, timeout time.Duration) (int64, error) { +func RenewHTTP(id lease.LeaseID, url string, tlsInfo transport.TLSInfo, timeout time.Duration) (int64, error) { // will post lreq protobuf to leader lreq, err := (&pb.LeaseKeepAliveRequest{ID: int64(id)}).Marshal() if err != nil {