common

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodInfoKey       = "/pod/info/%s" // /pod/info/{podname}
	ServiceStatusKey = "/services/%s" // /service/{ipv4:port}

	NodeInfoKey      = "/node/%s"              // /node/{nodename}
	NodePodKey       = "/node/%s:pod/%s"       // /node/{podname}:pod/{nodename}
	NodeStatusPrefix = "/status:node/"         // /status:node/{nodename} -> node status key
	NodeWorkloadsKey = "/node/%s:workloads/%s" // /node/{nodename}:workloads/{workloadID}

	WorkloadInfoKey          = "/workloads/%s" // /workloads/{workloadID}
	WorkloadDeployPrefix     = "/deploy"       // /deploy/{appname}/{entrypoint}/{nodename}/{workloadID}
	WorkloadStatusPrefix     = "/status"       // /status/{appname}/{entrypoint}/{nodename}/{workloadID} value -> something by agent
	WorkloadProcessingPrefix = "/processing"   // /processing/{appname}/{entrypoint}/{nodename}/{opsIdent} value -> count
)

Variables

This section is empty.

Functions

func ParseNodename

func ParseNodename(key string) string

func ParseStatusKey

func ParseStatusKey(key string) (string, string, string, string)

func ProcessingKey

func ProcessingKey(processing *types.Processing) string

Types

type Endpoints

type Endpoints map[string]struct{}

func (Endpoints) Add

func (e Endpoints) Add(endpoint string) (changed bool)

func (Endpoints) Remove

func (e Endpoints) Remove(endpoint string) (changed bool)

func (Endpoints) ToSlice

func (e Endpoints) ToSlice() []string

type Event

type Event struct {
	Key  string
	Type EventType
}

Event is one key change reported by a backend watch.

type EventType

type EventType int
const (
	EventPut EventType = iota
	EventDelete
	EventExpire
)

type KV

type KV interface {
	GetOne(ctx context.Context, key string) (string, error)
	GetMulti(ctx context.Context, keys []string) (map[string]string, error)
	GetPrefix(ctx context.Context, prefix string, limit int64) (map[string]string, error)
	ListPrefix(ctx context.Context, prefix string) ([]string, error)
	NotFound(err error) bool

	Create(ctx context.Context, data map[string]string) error
	Update(ctx context.Context, data map[string]string) error
	Put(ctx context.Context, data map[string]string) error
	Delete(ctx context.Context, keys []string) error
	CreateAndDecr(ctx context.Context, data map[string]string, decrKey string) error
	BindStatus(ctx context.Context, entityKey, statusKey, statusValue string, ttl int64) error

	// Watch registers the watch before it returns, so no event is lost between a read and the first iteration.
	Watch(ctx context.Context, prefix string) iter.Seq[Event]

	StartEphemeral(ctx context.Context, path string, heartbeat time.Duration) (<-chan struct{}, func(), error)
	CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error)
}

KV is the key-value surface both store backends provide.

type Store

type Store struct {
	KV

	Config types.Config
	Pool   *ants.PoolWithFunc
}

Store is the backend-independent half of the eru metadata store.

func New

func New(kv KV, config types.Config, pool *ants.PoolWithFunc) *Store

func (*Store) AddNode

func (s *Store) AddNode(ctx context.Context, opts *types.AddNodeOptions) (*types.Node, error)

func (*Store) AddPod

func (s *Store) AddPod(ctx context.Context, name, desc string) (*types.Pod, error)

func (*Store) AddWorkload

func (s *Store) AddWorkload(ctx context.Context, workload *types.Workload, processing *types.Processing) error

func (*Store) CreateProcessing

func (s *Store) CreateProcessing(ctx context.Context, processing *types.Processing, count int) error

func (*Store) DeleteProcessing

func (s *Store) DeleteProcessing(ctx context.Context, processing *types.Processing) error

func (*Store) GetAllPods

func (s *Store) GetAllPods(ctx context.Context) ([]*types.Pod, error)

func (*Store) GetDeployStatus

func (s *Store) GetDeployStatus(ctx context.Context, appname, entryname string) (map[string]int, error)

func (*Store) GetNode

func (s *Store) GetNode(ctx context.Context, nodename string) (*types.Node, error)

func (*Store) GetNodeStatus

func (s *Store) GetNodeStatus(ctx context.Context, nodename string) (*types.NodeStatus, error)

func (*Store) GetNodes

func (s *Store) GetNodes(ctx context.Context, nodenames []string) ([]*types.Node, error)

func (*Store) GetNodesByPod

func (s *Store) GetNodesByPod(ctx context.Context, nodeFilter *types.NodeFilter, withoutEngine bool) ([]*types.Node, error)

func (*Store) GetPod

func (s *Store) GetPod(ctx context.Context, name string) (*types.Pod, error)

func (*Store) GetServiceStatus added in v0.1.1

func (s *Store) GetServiceStatus(ctx context.Context) ([]string, error)

func (*Store) GetWorkload

func (s *Store) GetWorkload(ctx context.Context, ID string) (*types.Workload, error)

func (*Store) GetWorkloadStatus

func (s *Store) GetWorkloadStatus(ctx context.Context, ID string) (*types.StatusMeta, error)

func (*Store) GetWorkloads

func (s *Store) GetWorkloads(ctx context.Context, IDs []string) ([]*types.Workload, error)

func (*Store) ListNodeWorkloads

func (s *Store) ListNodeWorkloads(ctx context.Context, nodename string, labels map[string]string) ([]*types.Workload, error)

func (*Store) ListWorkloads

func (s *Store) ListWorkloads(ctx context.Context, appname, entrypoint, nodename string, limit int64, labels map[string]string) ([]*types.Workload, error)

func (*Store) MakeClient

func (s *Store) MakeClient(ctx context.Context, node *types.Node) (engine.API, error)

func (*Store) NodeStatusStream

func (s *Store) NodeStatusStream(ctx context.Context) chan *types.NodeStatus

func (*Store) RegisterService

func (s *Store) RegisterService(ctx context.Context, serviceAddress string, expire time.Duration) (<-chan struct{}, func(), error)

func (*Store) RemoveNode

func (s *Store) RemoveNode(ctx context.Context, node *types.Node) error

func (*Store) RemovePod

func (s *Store) RemovePod(ctx context.Context, podname string) error

func (*Store) RemoveWorkload

func (s *Store) RemoveWorkload(ctx context.Context, workload *types.Workload) error

func (*Store) ServiceStatusStream

func (s *Store) ServiceStatusStream(ctx context.Context) (chan []string, error)

func (*Store) SetNodeStatus

func (s *Store) SetNodeStatus(ctx context.Context, node *types.Node, ttl int64) error

func (*Store) SetWorkloadStatus

func (s *Store) SetWorkloadStatus(ctx context.Context, status *types.StatusMeta, ttl int64) error

func (*Store) UpdateNodes

func (s *Store) UpdateNodes(ctx context.Context, nodes ...*types.Node) error

func (*Store) UpdateWorkload

func (s *Store) UpdateWorkload(ctx context.Context, workload *types.Workload) error

func (*Store) WorkloadStatusStream

func (s *Store) WorkloadStatusStream(ctx context.Context, appname, entrypoint, nodename string, labels map[string]string) chan *types.WorkloadStatus

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL