Documentation
¶
Overview ¶
Copyright 2018 The Google Authors.
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.
Index ¶
- func Register(name string, initFunc InitFunc)
- type DataVersion
- type DistLock
- type EtcdStore
- func (store *EtcdStore) Create(ctx context.Context, key string, value []byte) error
- func (store *EtcdStore) CreateWithTTL(ctx context.Context, key string, value []byte, ttl time.Duration) error
- func (store *EtcdStore) Delete(ctx context.Context, key string) error
- func (store *EtcdStore) Get(ctx context.Context, key string) ([]byte, error)
- func (store *EtcdStore) KeepAlive(ctx context.Context, key string, value []byte, ttl time.Duration) (<-chan *clientv3.LeaseKeepAliveResponse, error)
- func (store *EtcdStore) NewIDGenerate(ctx context.Context, key string, base int64, timeout time.Duration) (int64, error)
- func (store *EtcdStore) NewLock(ctx context.Context, key string, timeout time.Duration) *DistLock
- func (store *EtcdStore) PrefixScan(ctx context.Context, prefix string) ([][]byte, [][]byte, error)
- func (store *EtcdStore) Put(ctx context.Context, key string, value []byte) error
- func (store *EtcdStore) PutWithLeaseId(ctx context.Context, key string, value []byte, ttl time.Duration, ...) error
- func (store *EtcdStore) STM(ctx context.Context, apply func(stm concurrency.STM) error) error
- func (store *EtcdStore) Update(ctx context.Context, key string, value []byte) error
- func (store *EtcdStore) WatchPrefix(ctx context.Context, key string) (clientv3.WatchChan, error)
- type InitFunc
- type Store
- type WatcherJob
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DataVersion ¶
type DataVersion int64
type DistLock ¶
type DistLock struct {
// contains filtered or unexported fields
}
* DistLock is based on vitess lock.go
func NewDistLock ¶
func (*DistLock) KeepAliveOnce ¶
func (dl *DistLock) KeepAliveOnce()
type EtcdStore ¶
type EtcdStore struct {
// contains filtered or unexported fields
}
func (*EtcdStore) Create ¶
if key already in , it will check version if same insert else ????? if key is not in , it will put
func (*EtcdStore) CreateWithTTL ¶
func (store *EtcdStore) CreateWithTTL(ctx context.Context, key string, value []byte, ttl time.Duration) error
CreateWithTTL will create the key-value if key already in , it will overwrite if key is not in , it will put
func (*EtcdStore) NewIDGenerate ¶
func (*EtcdStore) PrefixScan ¶
func (*EtcdStore) PutWithLeaseId ¶
type Store ¶
type Store interface { Put(ctx context.Context, key string, value []byte) error Create(ctx context.Context, key string, value []byte) error CreateWithTTL(ctx context.Context, key string, value []byte, ttl time.Duration) error KeepAlive(ctx context.Context, key string, value []byte, ttl time.Duration) (<-chan *clientv3.LeaseKeepAliveResponse, error) PutWithLeaseId(ctx context.Context, key string, value []byte, ttl time.Duration, leaseId clientv3.LeaseID) error Update(ctx context.Context, key string, value []byte) error Get(ctx context.Context, key string) ([]byte, error) PrefixScan(ctx context.Context, prefix string) ([][]byte, [][]byte, error) Delete(ctx context.Context, key string) error //Here we should not use the STM structure of etcd, but should define a data structure //equivalent to STM in the store, and then convert it in etcdstorage.go, on the one hand, the //decoupling of etcd and master logic, on the other hand Easy to extend other types of storage STM(ctx context.Context, apply func(stm concurrency.STM) error) error NewLock(ctx context.Context, key string, timeout time.Duration) *DistLock //it to generate increment unique id NewIDGenerate(ctx context.Context, key string, base int64, timeout time.Duration) (int64, error) WatchPrefix(ctx context.Context, key string) (clientv3.WatchChan, error) }
func NewEtcdStore ¶
NewEtcdStore is used to register etcd store init function