Documentation ¶
Overview ¶
* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* 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.
- Copyright 2020-2024 Open Networking Foundation (ONF) and the ONF Contributors *
- 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.
* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* 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.
* Copyright 2021-2024 Open Networking Foundation (ONF) and the ONF Contributors
* 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.
* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* 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.
* Copyright 2018-2024 Open Networking Foundation (ONF) and the ONF Contributors
* 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 ¶
- Constants
- func ToByte(value interface{}) ([]byte, error)
- func ToString(value interface{}) (string, error)
- type Client
- type EtcdClient
- func (c *EtcdClient) AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error
- func (c *EtcdClient) Close(ctx context.Context)
- func (c *EtcdClient) CloseWatch(ctx context.Context, key string, ch chan *Event)
- func (c *EtcdClient) Delete(ctx context.Context, key string) error
- func (c *EtcdClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error
- func (c *EtcdClient) Get(ctx context.Context, key string) (*KVPair, error)
- func (c *EtcdClient) IsConnectionUp(ctx context.Context) bool
- func (c *EtcdClient) List(ctx context.Context, key string) (map[string]*KVPair, error)
- func (c *EtcdClient) Put(ctx context.Context, key string, value interface{}) error
- func (c *EtcdClient) ReleaseAllReservations(ctx context.Context) error
- func (c *EtcdClient) ReleaseLock(lockName string) error
- func (c *EtcdClient) ReleaseReservation(ctx context.Context, key string) error
- func (c *EtcdClient) RenewReservation(ctx context.Context, key string) error
- func (c *EtcdClient) Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error)
- func (c *EtcdClient) Watch(ctx context.Context, key string, withPrefix bool) chan *Event
- type EtcdClientAllocator
- type Event
- type KVPair
- type RedisClient
- func (c *RedisClient) AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error
- func (c *RedisClient) Close(ctx context.Context)
- func (c *RedisClient) CloseWatch(ctx context.Context, key string, ch chan *Event)
- func (c *RedisClient) Delete(ctx context.Context, key string) error
- func (c *RedisClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error
- func (c *RedisClient) Get(ctx context.Context, key string) (*KVPair, error)
- func (c *RedisClient) IsConnectionUp(ctx context.Context) bool
- func (c *RedisClient) List(ctx context.Context, key string) (map[string]*KVPair, error)
- func (c *RedisClient) Put(ctx context.Context, key string, value interface{}) error
- func (c *RedisClient) ReleaseAllReservations(ctx context.Context) error
- func (c *RedisClient) ReleaseLock(lockName string) error
- func (c *RedisClient) ReleaseReservation(ctx context.Context, key string) error
- func (c *RedisClient) RenewReservation(ctx context.Context, key string) error
- func (c *RedisClient) Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error)
- func (c *RedisClient) Watch(ctx context.Context, key string, withPrefix bool) chan *Event
Constants ¶
const ( PUT = iota DELETE CONNECTIONDOWN UNKNOWN )
These constants represent the event types returned by the KV client
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface { List(ctx context.Context, key string) (map[string]*KVPair, error) Get(ctx context.Context, key string) (*KVPair, error) Put(ctx context.Context, key string, value interface{}) error Delete(ctx context.Context, key string) error DeleteWithPrefix(ctx context.Context, prefixKey string) error Watch(ctx context.Context, key string, withPrefix bool) chan *Event IsConnectionUp(ctx context.Context) bool // timeout in second CloseWatch(ctx context.Context, key string, ch chan *Event) Close(ctx context.Context) // These APIs are not used. They will be cleaned up in release Voltha 2.9. // It's not cleaned now to limit changes in all components Reserve(ctx context.Context, key string, value interface{}, ttl time.Duration) (interface{}, error) ReleaseReservation(ctx context.Context, key string) error ReleaseAllReservations(ctx context.Context) error RenewReservation(ctx context.Context, key string) error AcquireLock(ctx context.Context, lockName string, timeout time.Duration) error ReleaseLock(lockName string) error }
Client represents the set of APIs a KV Client must implement
type EtcdClient ¶
type EtcdClient struct {
// contains filtered or unexported fields
}
EtcdClient represents the Etcd KV store client
func NewEtcdClient ¶
func NewEtcdClient(ctx context.Context, addr string, timeout time.Duration, level log.LogLevel) (*EtcdClient, error)
NewEtcdClient returns a new client for the Etcd KV store
func NewEtcdCustomClient ¶
func NewEtcdCustomClient(ctx context.Context, addr string, timeout time.Duration, level log.LogLevel) (*EtcdClient, error)
NewEtcdCustomClient returns a new client for the Etcd KV store allowing the called to specify etcd client configuration
func (*EtcdClient) AcquireLock ¶
AcquireLock is deprecated
func (*EtcdClient) Close ¶
func (c *EtcdClient) Close(ctx context.Context)
Close closes all the connection in the pool store client
func (*EtcdClient) CloseWatch ¶
func (c *EtcdClient) CloseWatch(ctx context.Context, key string, ch chan *Event)
CloseWatch closes a specific watch. Both the key and the channel are required when closing a watch as there may be multiple listeners on the same key. The previously created channel serves as a key
func (*EtcdClient) Delete ¶
func (c *EtcdClient) Delete(ctx context.Context, key string) error
Delete removes a key from the KV store. Timeout defines how long the function will wait for a response
func (*EtcdClient) DeleteWithPrefix ¶
func (c *EtcdClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error
func (*EtcdClient) Get ¶
Get returns a key-value pair for a given key. Timeout defines how long the function will wait for a response
func (*EtcdClient) IsConnectionUp ¶
func (c *EtcdClient) IsConnectionUp(ctx context.Context) bool
IsConnectionUp returns whether the connection to the Etcd KV store is up. If a timeout occurs then it is assumed the connection is down or unreachable.
func (*EtcdClient) List ¶
List returns an array of key-value pairs with key as a prefix. Timeout defines how long the function will wait for a response
func (*EtcdClient) Put ¶
func (c *EtcdClient) Put(ctx context.Context, key string, value interface{}) error
Put writes a key-value pair to the KV store. Value can only be a string or []byte since the etcd API accepts only a string as a value for a put operation. Timeout defines how long the function will wait for a response
func (*EtcdClient) ReleaseAllReservations ¶
func (c *EtcdClient) ReleaseAllReservations(ctx context.Context) error
ReleaseAllReservations is deprecated
func (*EtcdClient) ReleaseLock ¶
func (c *EtcdClient) ReleaseLock(lockName string) error
ReleaseLock is deprecated
func (*EtcdClient) ReleaseReservation ¶
func (c *EtcdClient) ReleaseReservation(ctx context.Context, key string) error
ReleaseReservation is deprecated
func (*EtcdClient) RenewReservation ¶
func (c *EtcdClient) RenewReservation(ctx context.Context, key string) error
RenewReservation is deprecated
type EtcdClientAllocator ¶
type EtcdClientAllocator interface { Get(context.Context) (*clientv3.Client, error) Put(*clientv3.Client) Close(ctx context.Context) }
EtcdClientAllocator represents a generic interface to allocate an Etcd Client
func NewRoundRobinEtcdClientAllocator ¶
func NewRoundRobinEtcdClientAllocator(endpoints []string, timeout time.Duration, capacity, maxUsage int, level log.LogLevel) (EtcdClientAllocator, error)
NewRoundRobinEtcdClientAllocator creates a new ETCD Client Allocator using a Round Robin scheme
type RedisClient ¶
type RedisClient struct {
// contains filtered or unexported fields
}
func NewRedisClient ¶
func (*RedisClient) AcquireLock ¶
func (*RedisClient) Close ¶
func (c *RedisClient) Close(ctx context.Context)
func (*RedisClient) CloseWatch ¶
func (c *RedisClient) CloseWatch(ctx context.Context, key string, ch chan *Event)
func (*RedisClient) DeleteWithPrefix ¶
func (c *RedisClient) DeleteWithPrefix(ctx context.Context, prefixKey string) error
func (*RedisClient) IsConnectionUp ¶
func (c *RedisClient) IsConnectionUp(ctx context.Context) bool
func (*RedisClient) Put ¶
func (c *RedisClient) Put(ctx context.Context, key string, value interface{}) error
func (*RedisClient) ReleaseAllReservations ¶
func (c *RedisClient) ReleaseAllReservations(ctx context.Context) error
func (*RedisClient) ReleaseLock ¶
func (c *RedisClient) ReleaseLock(lockName string) error
func (*RedisClient) ReleaseReservation ¶
func (c *RedisClient) ReleaseReservation(ctx context.Context, key string) error
func (*RedisClient) RenewReservation ¶
func (c *RedisClient) RenewReservation(ctx context.Context, key string) error