Merge pull request #4325 from xiang90/client_lease

clientv3: lease initial api
release-2.3
Xiang Li 2016-01-28 10:49:50 -08:00
commit 5bd930c9d2
1 changed files with 42 additions and 0 deletions

42
clientv3/lease.go Normal file
View File

@ -0,0 +1,42 @@
// Copyright 2016 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package clientv3
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"
)
type (
LeaseCreateResponse pb.LeaseCreateResponse
LeaseRevokeResponse pb.LeaseRevokeResponse
LeaseKeepAliveResponse pb.LeaseKeepAliveResponse
)
type Lease interface {
// Create creates a new lease.
Create(ctx context.Context, ttl int64) *LeaseCreateResponse
// Revoke revokes the given lease.
Revoke(ctx context.Context, id lease.LeaseID) *LeaseRevokeResponse
// KeepAlive keeps the given lease alive forever.
KeepAlive(ctx context.Context, id lease.LeaseID) (chan<- *LeaseKeepAliveResponse, error)
// KeepAliveOnce renews the lease once. In most of the cases, Keepalive
// should be used instead of KeepAliveOnce.
KeepAliveOnce(ctx context.Context, id lease.LeaseID) (*LeaseKeepAliveResponse, error)
}