Documentation ¶
Index ¶
- Variables
- type KNotifyMessage
- type Rediaron
- func (r *Rediaron) AddNode(ctx context.Context, opts *types.AddNodeOptions) (*types.Node, error)
- func (r *Rediaron) AddPod(ctx context.Context, name, desc string) (*types.Pod, error)
- func (r *Rediaron) AddWorkload(ctx context.Context, workload *types.Workload, processing *types.Processing) error
- func (r *Rediaron) BatchCreate(ctx context.Context, data map[string]string) error
- func (r *Rediaron) BatchCreateAndDecr(ctx context.Context, data map[string]string, decrKey string) (err error)
- func (r *Rediaron) BatchDelete(ctx context.Context, keys []string) error
- func (r *Rediaron) BatchPut(ctx context.Context, data map[string]string) error
- func (r *Rediaron) BatchUpdate(ctx context.Context, data map[string]string) error
- func (r *Rediaron) BindStatus(ctx context.Context, entityKey, statusKey, statusValue string, ttl int64) error
- func (r *Rediaron) CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error)
- func (r *Rediaron) CreateProcessing(ctx context.Context, processing *types.Processing, count int) error
- func (r *Rediaron) DeleteProcessing(ctx context.Context, processing *types.Processing) error
- func (r *Rediaron) GetAllPods(ctx context.Context) ([]*types.Pod, error)
- func (r *Rediaron) GetDeployStatus(ctx context.Context, appname, entryname string) (map[string]int, error)
- func (r *Rediaron) GetMulti(ctx context.Context, keys []string) (map[string]string, error)
- func (r *Rediaron) GetNode(ctx context.Context, nodename string) (*types.Node, error)
- func (r *Rediaron) GetNodeStatus(ctx context.Context, nodename string) (*types.NodeStatus, error)
- func (r *Rediaron) GetNodes(ctx context.Context, nodenames []string) ([]*types.Node, error)
- func (r *Rediaron) GetNodesByPod(ctx context.Context, nodeFilter *types.NodeFilter, opts ...store.Option) ([]*types.Node, error)
- func (r *Rediaron) GetOne(ctx context.Context, key string) (string, error)
- func (r *Rediaron) GetPod(ctx context.Context, name string) (*types.Pod, error)
- func (r *Rediaron) GetWorkload(ctx context.Context, ID string) (*types.Workload, error)
- func (r *Rediaron) GetWorkloadStatus(ctx context.Context, ID string) (*types.StatusMeta, error)
- func (r *Rediaron) GetWorkloads(ctx context.Context, IDs []string) (workloads []*types.Workload, err error)
- func (r *Rediaron) KNotify(ctx context.Context, pattern string) chan *KNotifyMessage
- func (r *Rediaron) ListNodeWorkloads(ctx context.Context, nodename string, labels map[string]string) ([]*types.Workload, error)
- func (r *Rediaron) ListWorkloads(ctx context.Context, appname, entrypoint, nodename string, limit int64, ...) ([]*types.Workload, error)
- func (r *Rediaron) LoadNodeCert(ctx context.Context, node *types.Node) (err error)
- func (r *Rediaron) NodeStatusStream(ctx context.Context) chan *types.NodeStatus
- func (r *Rediaron) RegisterService(ctx context.Context, serviceAddress string, expire time.Duration) (<-chan struct{}, func(), error)
- func (r *Rediaron) RemoveNode(ctx context.Context, node *types.Node) error
- func (r *Rediaron) RemovePod(ctx context.Context, podname string) error
- func (r *Rediaron) RemoveWorkload(ctx context.Context, workload *types.Workload) error
- func (r *Rediaron) ServiceStatusStream(ctx context.Context) (chan []string, error)
- func (r *Rediaron) SetNodeStatus(ctx context.Context, node *types.Node, ttl int64) error
- func (r *Rediaron) SetWorkloadStatus(ctx context.Context, status *types.StatusMeta, ttl int64) error
- func (r *Rediaron) StartEphemeral(ctx context.Context, path string, heartbeat time.Duration) (<-chan struct{}, func(), error)
- func (r *Rediaron) TerminateEmbededStorage()
- func (r *Rediaron) UpdateNodes(ctx context.Context, nodes ...*types.Node) error
- func (r *Rediaron) UpdateWorkload(ctx context.Context, workload *types.Workload) error
- func (r *Rediaron) WorkloadStatusStream(ctx context.Context, appname, entrypoint, nodename string, ...) chan *types.WorkloadStatus
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMaxRetryExceeded indicates redis transaction failed after all the retries ErrMaxRetryExceeded = errors.New("[Redis transaction] Max retry exceeded") // ErrAlreadyExists indicates the key already exists when do redis SETNX ErrAlreadyExists = errors.New("[Redis setnx] Already exists") // ErrBadCmdType indicates command type is not correct // e.g. SET should be StringCmd ErrBadCmdType = errors.New("[Redis cmd] Bad cmd type") // ErrKeyNotExitsts indicates no key found // When do update, we need to ensure the key exists, just like the behavior of etcd client ErrKeyNotExitsts = errors.New("[Redis exists] Key not exists") )
Functions ¶
This section is empty.
Types ¶
type KNotifyMessage ¶
KNotifyMessage is received when using KNotify
type Rediaron ¶
type Rediaron struct {
// contains filtered or unexported fields
}
Rediaron is a store implemented by redis
func New ¶
New creates a new Rediaron instance from config Only redis address and db is used db is used to separate data, by default db 0 will be used TODO mock redis for testing
func (*Rediaron) AddNode ¶
AddNode save it to etcd storage path in etcd is `/pod/nodes/:podname/:nodename` node->pod path in etcd is `/node/pod/:nodename` func (m *Rediaron) AddNode(ctx context.Context, name, endpoint, podname, ca, cert, key string, cpu, share int, memory, storage int64, labels map[string]string, numa types.NUMA, numaMemory types.NUMAMemory, volume types.VolumeMap) (*types.Node, error) {
func (*Rediaron) AddWorkload ¶
func (r *Rediaron) AddWorkload(ctx context.Context, workload *types.Workload, processing *types.Processing) error
AddWorkload add a workload mainly record its relationship on pod and node actually if we already know its node, we will know its pod but we still store it storage path in etcd is `/workload/:workloadid`
func (*Rediaron) BatchCreate ¶
BatchCreate is wrapper to adapt etcd batch create
func (*Rediaron) BatchCreateAndDecr ¶
func (r *Rediaron) BatchCreateAndDecr(ctx context.Context, data map[string]string, decrKey string) (err error)
BatchCreateAndDecr decr processing and add workload
func (*Rediaron) BatchDelete ¶
BatchDelete is wrapper to adapt etcd batch delete
func (*Rediaron) BatchUpdate ¶
BatchUpdate is wrapper to adapt etcd batch update
func (*Rediaron) BindStatus ¶
func (r *Rediaron) BindStatus(ctx context.Context, entityKey, statusKey, statusValue string, ttl int64) error
BindStatus is wrapper to adapt etcd bind status
func (*Rediaron) CreateLock ¶
CreateLock creates a redis based lock
func (*Rediaron) CreateProcessing ¶
func (r *Rediaron) CreateProcessing(ctx context.Context, processing *types.Processing, count int) error
CreateProcessing save processing status in etcd
func (*Rediaron) DeleteProcessing ¶
DeleteProcessing delete processing status in etcd
func (*Rediaron) GetAllPods ¶
GetAllPods list all pods in core
func (*Rediaron) GetDeployStatus ¶
func (r *Rediaron) GetDeployStatus(ctx context.Context, appname, entryname string) (map[string]int, error)
GetDeployStatus .
func (*Rediaron) GetNodeStatus ¶
GetNodeStatus returns status for a node
func (*Rediaron) GetNodesByPod ¶
func (r *Rediaron) GetNodesByPod(ctx context.Context, nodeFilter *types.NodeFilter, opts ...store.Option) ([]*types.Node, error)
GetNodesByPod get all nodes bound to pod here we use podname instead of pod instance
func (*Rediaron) GetWorkload ¶
GetWorkload get a workload workload if must be in full length, or we can't find it in etcd storage path in etcd is `/workload/:workloadid`
func (*Rediaron) GetWorkloadStatus ¶
GetWorkloadStatus get workload status
func (*Rediaron) GetWorkloads ¶
func (r *Rediaron) GetWorkloads(ctx context.Context, IDs []string) (workloads []*types.Workload, err error)
GetWorkloads get many workloads
func (*Rediaron) KNotify ¶
func (r *Rediaron) KNotify(ctx context.Context, pattern string) chan *KNotifyMessage
KNotify is like `watch` in etcd knotify comes from inotify, when a key is changed, notification will be published
func (*Rediaron) ListNodeWorkloads ¶
func (r *Rediaron) ListNodeWorkloads(ctx context.Context, nodename string, labels map[string]string) ([]*types.Workload, error)
ListNodeWorkloads list workloads belong to one node
func (*Rediaron) ListWorkloads ¶
func (r *Rediaron) ListWorkloads(ctx context.Context, appname, entrypoint, nodename string, limit int64, labels map[string]string) ([]*types.Workload, error)
ListWorkloads list workloads
func (*Rediaron) LoadNodeCert ¶
func (*Rediaron) NodeStatusStream ¶
func (r *Rediaron) NodeStatusStream(ctx context.Context) chan *types.NodeStatus
NodeStatusStream returns a stream of node status it tells you if status of a node is changed, either PUT or DELETE PUT -> Alive: true DELETE -> Alive: false
func (*Rediaron) RegisterService ¶
func (r *Rediaron) RegisterService(ctx context.Context, serviceAddress string, expire time.Duration) (<-chan struct{}, func(), error)
RegisterService put /services/{address}
func (*Rediaron) RemoveNode ¶
RemoveNode delete a node
func (*Rediaron) RemoveWorkload ¶
RemoveWorkload remove a workload workload ID must be in full length
func (*Rediaron) ServiceStatusStream ¶
ServiceStatusStream watches /services/ --prefix
func (*Rediaron) SetNodeStatus ¶
SetNodeStatus sets status for a node, value will expire after ttl seconds ttl < 0 means delete node status this is heartbeat of node
func (*Rediaron) SetWorkloadStatus ¶
func (r *Rediaron) SetWorkloadStatus(ctx context.Context, status *types.StatusMeta, ttl int64) error
SetWorkloadStatus set workload status
func (*Rediaron) StartEphemeral ¶
func (r *Rediaron) StartEphemeral(ctx context.Context, path string, heartbeat time.Duration) (<-chan struct{}, func(), error)
StartEphemeral starts an empheral kv pair.
func (*Rediaron) TerminateEmbededStorage ¶
func (r *Rediaron) TerminateEmbededStorage()
TerminateEmbededStorage terminates embedded store in order to implement Store interface we can't use embedded redis, it doesn't support keyspace notification never call this except running unittests
func (*Rediaron) UpdateNodes ¶
UpdateNodes .
func (*Rediaron) UpdateWorkload ¶
UpdateWorkload update a workload
func (*Rediaron) WorkloadStatusStream ¶
func (r *Rediaron) WorkloadStatusStream(ctx context.Context, appname, entrypoint, nodename string, labels map[string]string) chan *types.WorkloadStatus
WorkloadStatusStream watch deployed status