app

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCloudReleased   = errors.New("cloud was released")
	ErrCloudNotAllowed = errors.New("not allowed")
	ErrPodNotFound     = errors.New("not found")
)

Functions

func NewCloudService

func NewCloudService(
	cloudRepo repository.Cloud,
	podRepo repository.Pod,
	producer message.CloudMessageProducer,
	whitelistRepo userrepo.WhiteList,
) *cloudService

Types

type CloudConfDTO

type CloudConfDTO struct {
	Id        string   `json:"id"`
	Specs     []Spec   `json:"specs"`
	Name      string   `json:"name"`
	Images    []string `json:"images"`
	Feature   string   `json:"feature"`
	Processor string   `json:"processor"`
	Credit    int64    `json:"credit"`
}

type CloudDTO

type CloudDTO struct {
	CloudConfDTO

	IsIdle     bool `json:"is_idle"`
	HasHolding bool `json:"has_holding"`
}

type CloudInternalService

type CloudInternalService interface {
	UpdateInfo(*UpdatePodInternalCmd) error
	Release(*ReleaseInternalCmd) error
}

func NewCloudInternalService

func NewCloudInternalService(
	repo repository.Pod,
	terminationWait int64,
) CloudInternalService

type CloudMessageService

type CloudMessageService interface {
	CreatePodInstance(*domain.PodInfo) error
	ReleasePodInstance(Id, cloudType string) error
}

func NewCloudMessageService

func NewCloudMessageService(
	repo repository.Pod,
	manager cloud.CloudPod,
	survivalTimeForPodCPU int64,
	survivalTimeForPodAscend int64,
	cloudRecordEventPublisher message.CloudRecordEventPublisher,
) CloudMessageService

type CloudService

type CloudService interface {
	// cloud
	ListCloud(*GetCloudConfCmd) ([]CloudDTO, error)
	SubscribeCloud(*SubscribeCloudCmd) (code string, err error)

	// pod
	Get(*PodInfoCmd) (PodInfoDTO, error)
	ReleaseCloud(*ReleaseCloudCmd) error
	GetReleasedPod(*GetReleasedPodCmd) (PodInfoDTO, error)
}

type GetCloudConfCmd

type GetCloudConfCmd struct {
	IsVisitor bool
	User      types.Account
}

func (*GetCloudConfCmd) ToCmd

func (cmd *GetCloudConfCmd) ToCmd(user types.Account, visitor bool)

type GetReleasedPodCmd

type GetReleasedPodCmd struct {
	PodId string
}

type PodInfoCmd

type PodInfoCmd SubscribeCloudCmd

func (*PodInfoCmd) Validate

func (cmd *PodInfoCmd) Validate() error

type PodInfoDTO

type PodInfoDTO struct {
	Id        string `json:"id"`
	CloudId   string `json:"cloud_id"`
	Owner     string `json:"owner"`
	Status    string `json:"status"`
	Expiry    int64  `json:"expiry"`
	Error     string `json:"error"`
	AccessURL string `json:"access_url"`
	CreatedAt int64  `json:"created_at"`
	Image     string `json:"image"`
	Spec      string `json:"spec"`
}

type ReleaseCloudCmd

type ReleaseCloudCmd struct {
	PodId string
	User  types.Account
}

func (*ReleaseCloudCmd) Validate

func (c *ReleaseCloudCmd) Validate() error

type ReleaseInternalCmd

type ReleaseInternalCmd struct {
	PodId string
}

type Spec added in v1.3.0

type Spec struct {
	Desc     string `json:"desc"`
	CardsNum int    `json:"cards_num"`
}

type SubscribeCloudCmd

type SubscribeCloudCmd struct {
	User       types.Account
	ImageAlias domain.CloudImageAlias
	CardsNum   domain.CloudSpecCardsNum
	CloudId    string
}

func (*SubscribeCloudCmd) Validate

func (cmd *SubscribeCloudCmd) Validate() error

type UpdatePodInternalCmd

type UpdatePodInternalCmd struct {
	PodId     string
	PodError  domain.PodError
	AccessURL domain.AccessURL
}

Jump to

Keyboard shortcuts

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