github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/store/store.go (about)

     1  package store
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/projecteru2/core/lock"
     8  	"github.com/projecteru2/core/types"
     9  )
    10  
    11  // Store store eru data
    12  type Store interface {
    13  	// service
    14  	ServiceStatusStream(context.Context) (chan []string, error)
    15  	RegisterService(context.Context, string, time.Duration) (<-chan struct{}, func(), error)
    16  
    17  	// ephemeral nodes primitive
    18  	StartEphemeral(ctx context.Context, path string, heartbeat time.Duration) (<-chan struct{}, func(), error)
    19  
    20  	// pod
    21  	AddPod(ctx context.Context, name, desc string) (*types.Pod, error)
    22  	GetPod(ctx context.Context, podname string) (*types.Pod, error)
    23  	RemovePod(ctx context.Context, podname string) error
    24  	GetAllPods(ctx context.Context) ([]*types.Pod, error)
    25  
    26  	// node
    27  	AddNode(context.Context, *types.AddNodeOptions) (*types.Node, error)
    28  	RemoveNode(ctx context.Context, node *types.Node) error
    29  	GetNode(ctx context.Context, nodename string) (*types.Node, error)
    30  	GetNodes(ctx context.Context, nodenames []string) ([]*types.Node, error)
    31  	GetNodesByPod(ctx context.Context, nodeFilter *types.NodeFilter, opts ...Option) ([]*types.Node, error)
    32  	UpdateNodes(context.Context, ...*types.Node) error
    33  	SetNodeStatus(ctx context.Context, node *types.Node, ttl int64) error
    34  	GetNodeStatus(ctx context.Context, nodename string) (*types.NodeStatus, error)
    35  	NodeStatusStream(ctx context.Context) chan *types.NodeStatus
    36  	LoadNodeCert(ctx context.Context, node *types.Node) (err error)
    37  
    38  	// workload
    39  	AddWorkload(context.Context, *types.Workload, *types.Processing) error
    40  	UpdateWorkload(ctx context.Context, workload *types.Workload) error
    41  	RemoveWorkload(ctx context.Context, workload *types.Workload) error
    42  	GetWorkload(ctx context.Context, ID string) (*types.Workload, error)
    43  	GetWorkloads(ctx context.Context, IDs []string) ([]*types.Workload, error)
    44  	GetWorkloadStatus(ctx context.Context, ID string) (*types.StatusMeta, error)
    45  	SetWorkloadStatus(ctx context.Context, status *types.StatusMeta, ttl int64) error
    46  	ListWorkloads(ctx context.Context, appname, entrypoint, nodename string, limit int64, labels map[string]string) ([]*types.Workload, error)
    47  	ListNodeWorkloads(ctx context.Context, nodename string, labels map[string]string) ([]*types.Workload, error)
    48  	WorkloadStatusStream(ctx context.Context, appname, entrypoint, nodename string, labels map[string]string) chan *types.WorkloadStatus
    49  
    50  	// deploy status
    51  	GetDeployStatus(ctx context.Context, appname, entryname string) (map[string]int, error)
    52  
    53  	// processing status
    54  	CreateProcessing(ctx context.Context, process *types.Processing, count int) error
    55  	DeleteProcessing(context.Context, *types.Processing) error
    56  
    57  	// distributed lock
    58  	CreateLock(key string, ttl time.Duration) (lock.DistributedLock, error)
    59  }