Documentation ¶
Index ¶
- func NewStorage(config *ZkConfig) (storage.Storage, error)
- type Layer
- type NSClient
- func (s *NSClient) Close()
- func (s *NSClient) Create(cxt context.Context, key string, obj meta.Object, ttl int) (out meta.Object, err error)
- func (s *NSClient) Delete(ctx context.Context, key string) (obj meta.Object, err error)
- func (s *NSClient) Get(cxt context.Context, key, version string, ignoreNotFound bool) (meta.Object, error)
- func (s *NSClient) List(cxt context.Context, key string, selector storage.Selector) ([]meta.Object, error)
- func (s *NSClient) Watch(cxt context.Context, key, version string, selector storage.Selector) (watch.Interface, error)
- func (s *NSClient) WatchList(ctx context.Context, key, version string, selector storage.Selector) (watch.Interface, error)
- type Node
- type NodeWatch
- type PodClient
- func (s *PodClient) Close()
- func (s *PodClient) Create(cxt context.Context, key string, obj meta.Object, ttl int) (out meta.Object, err error)
- func (s *PodClient) Delete(ctx context.Context, key string) (obj meta.Object, err error)
- func (s *PodClient) Get(cxt context.Context, key, version string, ignoreNotFound bool) (meta.Object, error)
- func (s *PodClient) List(cxt context.Context, key string, selector storage.Selector) ([]meta.Object, error)
- func (s *PodClient) Watch(cxt context.Context, key, version string, selector storage.Selector) (watch.Interface, error)
- func (s *PodClient) WatchList(ctx context.Context, key, version string, selector storage.Selector) (watch.Interface, error)
- type PushWatchEventFn
- type ZkConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Layer ¶
type Layer struct { Index int //layer index from path IsData bool //flag to present this layer store data IsWatchChildren bool //flag for watch children if not Name string //data type for this layer PushEventFunc PushWatchEventFn //event dispatch function }
Layer info
type NSClient ¶
type NSClient struct {
// contains filtered or unexported fields
}
NSClient implementation storage interface with zookeeper client, all operations are based on namespace-like data types. All data store with namespace feature. so full paths of objects are like /prefix/{dataType}/{namespace}/{name}, all object json contents are hold by name node
func NewNSClient ¶
NewNSClient create new client for namespace-based datas that store in zookeeper. namespace-based datas store in path {namespace}/{name}, namespace nodes store nothing, only name nodes store json data
func (*NSClient) Create ¶
func (s *NSClient) Create(cxt context.Context, key string, obj meta.Object, ttl int) (out meta.Object, err error)
Create implements storage interface param cxt: context for use decline Creation, not used param key: http full api path param obj: object for creation param ttl: second for time-to-live, not used return out: exist object data
func (*NSClient) Delete ¶
Delete implements storage interface for http api operation, there are three situations for key * if key likes apis/v1/dns, clean all dns data under version v1 * if key likes apis/v1/dns/namespace/bmsf-system, delete all data under namespace * if key likes apis/v1/dns/namespace/bmsf-system/data, delete detail data in this version, no delete objects reply
func (*NSClient) Get ¶
func (s *NSClient) Get(cxt context.Context, key, version string, ignoreNotFound bool) (meta.Object, error)
Get implements storage interface get exactly data object from http event storage. so key must be resource fullpath param cxt: not used param version: reserved for future
func (*NSClient) List ¶
func (s *NSClient) List(cxt context.Context, key string, selector storage.Selector) ([]meta.Object, error)
List implements storage interface list namespace-based data or all data, detail node should use Get * if key is empty, list all data under prefix, data must be target object * if key is not empty, list all data under prefix/key, data must be target object. if one node errors, we consider all errors. List Function only list leaf data nodes
func (*NSClient) Watch ¶
func (s *NSClient) Watch(cxt context.Context, key, version string, selector storage.Selector) (watch.Interface, error)
Watch implements storage interface * if key empty, watch all data * if key is namespace, watch all data under namespace * if key is namespace/name, watch detail data watch is Stopped when any error occure, close event channel immediatly param cxt: context for background running, not used, only reserved now param version: data version, not used, reserved param selector: labels selector return:
watch: watch implementation for changing event, need to Stop manually
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node for zookeeper every node
func (*Node) DeleteNextWatch ¶
DeleteNextWatch clen next watch when child node deletion
type NodeWatch ¶
type NodeWatch interface { GetSelfPath() string //get self node path DeleteNextWatch(next NodeWatch) //delete children watch Run() //ready to start up watch Stop() //stop watch, only parent watch to stop }
NodeWatch interface for watch definition
type PodClient ¶
type PodClient struct {
// contains filtered or unexported fields
}
PodClient implements storage interface with zookeeper client, all operations are based on one object data types, but data may be stored at different levels of nodes.
func NewPodClient ¶
NewPodClient create pod client for bcs-scheduler in
func (*PodClient) Close ¶
func (s *PodClient) Close()
Close storage conenction, clean resource warnning: if you want to Close client, you have better close Watch first
func (*PodClient) Create ¶
func (s *PodClient) Create(cxt context.Context, key string, obj meta.Object, ttl int) (out meta.Object, err error)
Create implements storage interface
func (*PodClient) Delete ¶
Delete implements storage interface for http api operation, there are three situations for key * if key likes apis/v1/dns, clean all dns data under version v1 * if key likes apis/v1/dns/namespace/bmsf-system, delete all data under namespace * if key likes apis/v1/dns/namespace/bmsf-system/data, delete detail data in this version, no delete objects reply
func (*PodClient) Get ¶
func (s *PodClient) Get(cxt context.Context, key, version string, ignoreNotFound bool) (meta.Object, error)
Get implements storage interface get exactly data object from http event storage. so key must be resource fullpath param cxt: not used param version: reserved for future
func (*PodClient) List ¶
func (s *PodClient) List(cxt context.Context, key string, selector storage.Selector) ([]meta.Object, error)
List implements storage interface list all data under prefixPath/key, there may be several data type under children nodes of prefixPath, we use selector to filt all types of data. param cxt: context for cancel, not used now param key: key only can be empty, namespace or namespace/{name} param selector: data filter
func (*PodClient) Watch ¶
func (s *PodClient) Watch(cxt context.Context, key, version string, selector storage.Selector) (watch.Interface, error)
Watch implements storage interface * if key empty, watch all data * if key is namespace, watch all data under namespace * if key is namespace/name, watch detail data based-on application watch is Stopped when any error occure, close event channel immediatly param cxt: context for background running, not used, only reserved now param version: data version, not used, reserved param selector: selector for target object data return:
watch: watch implementation for changing event, need to Stop manually
type PushWatchEventFn ¶
PushWatchEventFn function to dispath event param EventType: zk event type param string: event path, especially for delete event param []byte: detail data for object, nil when it's deletion
type ZkConfig ¶
type ZkConfig struct { Hosts []string //http api host link, ip:host PrefixPath string //basic path for namespace data Name string //data type name Codec meta.Codec //Codec for encoder & decoder ObjectNewFunc meta.ObjectNewFn //object pointer for serialization }
ZkConfig only data type node config