workflow

package
v0.0.0-...-3e0e934 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0, BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KCreateContext contextKey = "kCreateContext"

	KInitContext contextKey = "KInitContext"

	KDestroyContext contextKey = "KDestroyContext"
)

Variables

This section is empty.

Functions

func GetQosFromReq

func GetQosFromReq(req *cubebox.RunCubeSandboxRequest, key string) (*disk.RateLimiter, error)

func RecordCreateMetric

func RecordCreateMetric(ctx context.Context, err error, id string, cost time.Duration)

func RecordCreateMetricIfGreaterThan

func RecordCreateMetricIfGreaterThan(ctx context.Context, err error, id string, cost time.Duration, threshold time.Duration)

func RecordDestroyMetric

func RecordDestroyMetric(ctx context.Context, err error, id string, cost time.Duration)

func WithCreateContext

func WithCreateContext(ctx context.Context, createContext *CreateContext) context.Context

Types

type BaseWorkflowInfo

type BaseWorkflowInfo struct {
	SandboxID  string
	CPU        int64
	Memory     int64
	PCIMode    string
	NumaNode   int32
	IsRollBack bool
	AppID      int64
	Uin        string
	SubUin     string
	// contains filtered or unexported fields
}

func (*BaseWorkflowInfo) AddMetric

func (m *BaseWorkflowInfo) AddMetric(err error, id string, t time.Duration)

func (*BaseWorkflowInfo) GetAppID

func (b *BaseWorkflowInfo) GetAppID() int64

func (*BaseWorkflowInfo) GetCPU

func (b *BaseWorkflowInfo) GetCPU() int64

func (*BaseWorkflowInfo) GetInstanceType

func (b *BaseWorkflowInfo) GetInstanceType() string

func (*BaseWorkflowInfo) GetMemory

func (b *BaseWorkflowInfo) GetMemory() int64

func (*BaseWorkflowInfo) GetMetric

func (m *BaseWorkflowInfo) GetMetric() []*Metric

func (*BaseWorkflowInfo) GetNumaNode

func (b *BaseWorkflowInfo) GetNumaNode() int32

func (*BaseWorkflowInfo) GetPCIMode

func (b *BaseWorkflowInfo) GetPCIMode() string

func (*BaseWorkflowInfo) GetSandboxID

func (b *BaseWorkflowInfo) GetSandboxID() string

func (*BaseWorkflowInfo) GetSubUin

func (b *BaseWorkflowInfo) GetSubUin() string

func (*BaseWorkflowInfo) GetUin

func (b *BaseWorkflowInfo) GetUin() string

func (*BaseWorkflowInfo) IsPCIPFMode

func (b *BaseWorkflowInfo) IsPCIPFMode() bool

type CleanContext

type CleanContext struct {
	BaseWorkflowInfo
}

func (*CleanContext) AddMetric

func (m *CleanContext) AddMetric(err error, id string, t time.Duration)

func (*CleanContext) GetMetric

func (m *CleanContext) GetMetric() []*Metric

type CreateContext

type CreateContext struct {
	BaseWorkflowInfo

	ReqInfo *cubebox.RunCubeSandboxRequest

	NetworkInfo provider.NetworkProvider

	StorageInfo interface{}

	CgroupInfo interface{}

	VolumeInfo interface{}

	Failover bool

	UserData *cubeboxstore.UserData

	CubeBoxCreated bool
	NetFile        *netfile.CubeboxNetfile

	LocalRunTemplate *templatetypes.LocalRunTemplate
}

func GetCreateContext

func GetCreateContext(ctx context.Context) *CreateContext

func (*CreateContext) AddMetric

func (m *CreateContext) AddMetric(err error, id string, t time.Duration)

func (*CreateContext) GetInstanceType

func (b *CreateContext) GetInstanceType() string

func (*CreateContext) GetMetric

func (m *CreateContext) GetMetric() []*Metric

func (*CreateContext) GetQos

func (b *CreateContext) GetQos(key string) (*disk.RateLimiter, error)

func (*CreateContext) GetRegion

func (b *CreateContext) GetRegion() string

func (*CreateContext) GetSnapshotTemplateID

func (b *CreateContext) GetSnapshotTemplateID() (string, bool)

func (*CreateContext) IsCreateSnapshot

func (b *CreateContext) IsCreateSnapshot() bool

func (*CreateContext) IsCubeboxV2

func (b *CreateContext) IsCubeboxV2() bool

func (*CreateContext) IsRetoreSnapshot

func (b *CreateContext) IsRetoreSnapshot() bool

type DestroyContext

type DestroyContext struct {
	BaseWorkflowInfo

	DestroyInfo *cubebox.DestroyCubeSandboxRequest
}

func (*DestroyContext) AddMetric

func (m *DestroyContext) AddMetric(err error, id string, t time.Duration)

func (*DestroyContext) GetInstanceType

func (b *DestroyContext) GetInstanceType() string

func (*DestroyContext) GetMetric

func (m *DestroyContext) GetMetric() []*Metric

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func (*Engine) AddCleaupFlow

func (e *Engine) AddCleaupFlow(f Flow)

func (*Engine) AddFlow

func (e *Engine) AddFlow(k string, f *Workflow)

func (*Engine) CleanUp

func (e *Engine) CleanUp(ctx context.Context, opts *CleanContext) error

func (*Engine) Create

func (e *Engine) Create(ctx context.Context, opts *CreateContext) error

func (*Engine) Destroy

func (e *Engine) Destroy(ctx context.Context, opts *DestroyContext) error

func (*Engine) GetFlowOnFlyingRequests

func (e *Engine) GetFlowOnFlyingRequests(name string) int64

func (*Engine) GetFlowPeakRequests

func (e *Engine) GetFlowPeakRequests(name string) int64

func (*Engine) ID

func (s *Engine) ID() string

func (*Engine) Init

func (e *Engine) Init(ctx context.Context, opts *InitInfo) error

func (*Engine) RegisterMetrics

func (e *Engine) RegisterMetrics(register *metrictype.CollectRegister) error

func (*Engine) SetFlowLimit

func (e *Engine) SetFlowLimit(name string, limit int64)

type Flow

type Flow interface {
	ID() string
	Init(context.Context, *InitInfo) error
	Create(context.Context, *CreateContext) error
	Destroy(context.Context, *DestroyContext) error

	CleanUp(context.Context, *CleanContext) error
}

type InitInfo

type InitInfo struct {
	BaseWorkflowInfo

	NetCIDR    string
	MVMInnerIP net.IP
	TapInitNum int
}

func (*InitInfo) AddMetric

func (m *InitInfo) AddMetric(err error, id string, t time.Duration)

func (*InitInfo) GetMetric

func (m *InitInfo) GetMetric() []*Metric

type Metric

type Metric struct {
	// contains filtered or unexported fields
}

func (Metric) Duration

func (m Metric) Duration() time.Duration

func (Metric) Error

func (m Metric) Error() error

func (Metric) ID

func (m Metric) ID() string

type ReqContext

type ReqContext interface {
	GetInstanceType() string
	GetMetric() []*Metric
	AddMetric(err error, id string, t time.Duration)
	GetSandboxID() string
	GetCPU() int64
	GetMemory() int64
	GetNumaNode() int32
}

type Step

type Step struct {
	Name    string
	Actions []Flow
}

func (*Step) AppendFlow

func (s *Step) AppendFlow(f Flow)

func (Step) ID

func (s Step) ID() string

type Workflow

type Workflow struct {
	Name          string
	MaxConcurrent int64
	Limiter       *semaphore.Limiter
	Steps         []*Step
}

func (*Workflow) AppendStep

func (w *Workflow) AppendStep(s *Step)

func (*Workflow) GetOnFlyingRequest

func (w *Workflow) GetOnFlyingRequest() int64

func (*Workflow) GetPeakRequest

func (w *Workflow) GetPeakRequest() int64

func (*Workflow) ID

func (w *Workflow) ID() string

func (*Workflow) SetLimit

func (w *Workflow) SetLimit(limit int64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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