Documentation ¶
Index ¶
- Constants
- Variables
- type Agent
- type AgentRepo
- type AgentUsecase
- func (uc *AgentUsecase) Create(ctx context.Context, agent *Agent) error
- func (uc *AgentUsecase) Delete(ctx context.Context, id uuid.UUID) error
- func (uc *AgentUsecase) FindOneActiveAgent(ctx context.Context, cpu string, memory string) (*Agent, error)
- func (uc *AgentUsecase) Get(ctx context.Context, id uuid.UUID) (p *Agent, err error)
- func (uc *AgentUsecase) List(ctx context.Context) (ps []*Agent, err error)
- func (uc *AgentUsecase) Update(ctx context.Context, id uuid.UUID, agent *Agent) error
- type ComputeImage
- type ComputeImageRepo
- type ComputeInstance
- type ComputeInstanceCreate
- type ComputeInstanceRds
- type ComputeInstanceRepo
- type ComputeInstanceUsercase
- func (uc *ComputeInstanceUsercase) Create(ctx context.Context, cic *ComputeInstanceCreate) (*ComputeInstance, error)
- func (uc *ComputeInstanceUsercase) CreateInstanceOnAgent(peerId string, instance *ComputeInstance)
- func (uc *ComputeInstanceUsercase) Delete(ctx context.Context, id uuid.UUID) error
- func (uc *ComputeInstanceUsercase) Get(ctx context.Context, id uuid.UUID) (*ComputeInstance, error)
- func (uc *ComputeInstanceUsercase) ListComputeImage(ctx context.Context) ([]*ComputeImage, error)
- func (uc *ComputeInstanceUsercase) ListComputeInstance(ctx context.Context, owner string) ([]*ComputeInstance, error)
- func (uc *ComputeInstanceUsercase) ListComputeSpec(ctx context.Context) ([]*ComputeSpec, error)
- func (uc *ComputeInstanceUsercase) Start(ctx context.Context, id uuid.UUID) error
- func (uc *ComputeInstanceUsercase) Stop(ctx context.Context, id uuid.UUID) error
- func (uc *ComputeInstanceUsercase) SyncContainerStats()
- func (uc *ComputeInstanceUsercase) Terminal(w http.ResponseWriter, r *http.Request)
- type ComputeSpec
- type ComputeSpecRepo
- type Greeter
- type GreeterRepo
- type GreeterUsecase
- type Script
- type ScriptExecutionRecord
- type ScriptExecutionRecordRepo
- type ScriptRepo
- type ScriptUseCase
- func (uc *ScriptUseCase) CancelExecPythonPackage(ctx context.Context, scriptId int32) (*ScriptExecutionRecord, error)
- func (uc *ScriptUseCase) CreateScript(ctx context.Context, s *Script) (*Script, error)
- func (uc *ScriptUseCase) GetScriptExecutionRecordInfo(ctx context.Context, id int32) (*ScriptExecutionRecord, error)
- func (uc *ScriptUseCase) GetScriptExecutionRecordPage(ctx context.Context, userId string, page, size int32) ([]*ScriptExecutionRecord, int32, error)
- func (uc *ScriptUseCase) RunPythonPackage(ctx context.Context, id int32, userId string) (*ScriptExecutionRecord, error)
- func (uc *ScriptUseCase) RunPythonPackageOnAgent(peerId string, record *ScriptExecutionRecord)
- type Storage
- type StorageRepo
- type Storagecase
- func (uc *Storagecase) Create(ctx context.Context, storage *Storage) error
- func (uc *Storagecase) Delete(ctx context.Context, id uuid.UUID) error
- func (uc *Storagecase) Get(ctx context.Context, id uuid.UUID) (p *Storage, err error)
- func (uc *Storagecase) List(ctx context.Context, owner string, parentId string) (ps []*Storage, err error)
- func (uc *Storagecase) Update(ctx context.Context, id uuid.UUID, storage *Storage) error
- type User
- type UserRepo
- type UserUsercase
- func (uc *UserUsercase) Create(ctx context.Context, user *User) error
- func (uc *UserUsercase) Delete(ctx context.Context, id uuid.UUID) error
- func (uc *UserUsercase) Get(ctx context.Context, id uuid.UUID) (p *User, err error)
- func (uc *UserUsercase) GetValidateCode(ctx context.Context, user User) (string, error)
- func (uc *UserUsercase) List(ctx context.Context, entity User) (ps []*User, err error)
- func (uc *UserUsercase) Login(ctx context.Context, user *User) (string, error)
- func (uc *UserUsercase) LoginWithValidateCode(ctx context.Context, user *User) (string, error)
- func (uc *UserUsercase) SendValidateCode(ctx context.Context, entity User) error
- func (uc *UserUsercase) Update(ctx context.Context, id uuid.UUID, user *User) error
- func (uc *UserUsercase) UpdateUserPassword(ctx context.Context, id uuid.UUID, oldPassword, newPassword string) error
- func (uc *UserUsercase) UpdateUserTelephone(ctx context.Context, id uuid.UUID, user *User) error
Constants ¶
View Source
const ( InstanceStatusStarting int8 = iota InstanceStatusRunning InstanceStatusTerminal InstanceStatusExpire )
Variables ¶
View Source
var ( // ErrUserNotFound is user not found. ErrUserNotFound = errors.NotFound(v1.ErrorReason_USER_NOT_FOUND.String(), "user not found") )
View Source
var ProviderSet = wire.NewSet( NewGreeterUsecase, NewAgentUsecase, NewStorageUsecase, NewUserUsecase, NewComputeInstanceUsercase, NewScriptUseCase, )
ProviderSet is biz providers.
Functions ¶
This section is empty.
Types ¶
type AgentRepo ¶
type AgentRepo interface { //db ListAgent(ctx context.Context) ([]*Agent, error) GetAgent(ctx context.Context, id uuid.UUID) (*Agent, error) CreateAgent(ctx context.Context, agent *Agent) error UpdateAgent(ctx context.Context, id uuid.UUID, agent *Agent) error DeleteAgent(ctx context.Context, id uuid.UUID) error FindByPeerId(ctx context.Context, peerId string) (*Agent, error) FindOneActiveAgent(ctx context.Context, cpu string, memory string) (*Agent, error) }
type AgentUsecase ¶
type AgentUsecase struct {
// contains filtered or unexported fields
}
func NewAgentUsecase ¶
func NewAgentUsecase(repo AgentRepo, logger log.Logger) *AgentUsecase
func (*AgentUsecase) Create ¶
func (uc *AgentUsecase) Create(ctx context.Context, agent *Agent) error
func (*AgentUsecase) FindOneActiveAgent ¶ added in v0.0.2
type ComputeImage ¶
type ComputeImageRepo ¶
type ComputeImageRepo interface { List(ctx context.Context) ([]*ComputeImage, error) Get(ctx context.Context, id int32) (*ComputeImage, error) }
type ComputeInstance ¶
type ComputeInstance struct { // ID of the ent. ID uuid.UUID `json:"id,omitempty"` // Owner holds the value of the "owner" field. Owner string `json:"owner,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Core holds the value of the "core" field. Core string `json:"core,omitempty"` // Memory holds the value of the "memory" field. Memory string `json:"memory,omitempty"` // Image holds the value of the "image" field. Image string `json:"image,omitempty"` Port string `json:"port,omitempty"` // ExpirationTime holds the value of the "expiration_time" field. ExpirationTime time.Time `json:"expiration_time,omitempty"` // 0: 启动中,1:运行中,2:连接中断, 3:过期 Status int8 `json:"status,omitempty"` // 容器id ContainerID string `json:"container_id,omitempty"` // p2p agent Id PeerID string `json:"peer_id,omitempty"` Command string `json:"command,omitempty"` Stats []*ComputeInstanceRds `json:"stats"` }
type ComputeInstanceCreate ¶
type ComputeInstanceRds ¶ added in v0.0.3
type ComputeInstanceRds struct { ID string `json:"id"` CpuUsage uint64 `json:"cpuUsage"` MemoryUsage uint64 `json:"memoryUsage"` StatsTime time.Time `json:"statsTime"` }
func (*ComputeInstanceRds) MarshalBinary ¶ added in v0.0.3
func (m *ComputeInstanceRds) MarshalBinary() (data []byte, err error)
func (*ComputeInstanceRds) UnmarshalBinary ¶ added in v0.0.3
func (m *ComputeInstanceRds) UnmarshalBinary(data []byte) error
type ComputeInstanceRepo ¶
type ComputeInstanceRepo interface { List(ctx context.Context, owner string) ([]*ComputeInstance, error) ListAll(ctx context.Context) ([]*ComputeInstance, error) Create(ctx context.Context, instance *ComputeInstance) error Delete(ctx context.Context, id uuid.UUID) error Update(ctx context.Context, id uuid.UUID, instance *ComputeInstance) error Get(ctx context.Context, id uuid.UUID) (*ComputeInstance, error) SaveInstanceStats(ctx context.Context, id uuid.UUID, rdbInstance *ComputeInstanceRds) error GetInstanceStats(ctx context.Context, id uuid.UUID) ([]*ComputeInstanceRds, error) }
type ComputeInstanceUsercase ¶
type ComputeInstanceUsercase struct {
// contains filtered or unexported fields
}
func NewComputeInstanceUsercase ¶
func NewComputeInstanceUsercase( specRepo ComputeSpecRepo, instanceRepo ComputeInstanceRepo, imageRepo ComputeImageRepo, agentRepo AgentRepo, p2pClient *goipfsp2p.P2pClient, logger log.Logger) *ComputeInstanceUsercase
func (*ComputeInstanceUsercase) Create ¶
func (uc *ComputeInstanceUsercase) Create(ctx context.Context, cic *ComputeInstanceCreate) (*ComputeInstance, error)
func (*ComputeInstanceUsercase) CreateInstanceOnAgent ¶ added in v0.0.2
func (uc *ComputeInstanceUsercase) CreateInstanceOnAgent(peerId string, instance *ComputeInstance)
func (*ComputeInstanceUsercase) Get ¶ added in v0.0.3
func (uc *ComputeInstanceUsercase) Get(ctx context.Context, id uuid.UUID) (*ComputeInstance, error)
func (*ComputeInstanceUsercase) ListComputeImage ¶
func (uc *ComputeInstanceUsercase) ListComputeImage(ctx context.Context) ([]*ComputeImage, error)
func (*ComputeInstanceUsercase) ListComputeInstance ¶ added in v0.0.3
func (uc *ComputeInstanceUsercase) ListComputeInstance(ctx context.Context, owner string) ([]*ComputeInstance, error)
func (*ComputeInstanceUsercase) ListComputeSpec ¶
func (uc *ComputeInstanceUsercase) ListComputeSpec(ctx context.Context) ([]*ComputeSpec, error)
func (*ComputeInstanceUsercase) SyncContainerStats ¶ added in v0.0.3
func (uc *ComputeInstanceUsercase) SyncContainerStats()
func (*ComputeInstanceUsercase) Terminal ¶ added in v0.0.3
func (uc *ComputeInstanceUsercase) Terminal(w http.ResponseWriter, r *http.Request)
type ComputeSpec ¶
type ComputeSpecRepo ¶
type ComputeSpecRepo interface { List(ctx context.Context) ([]*ComputeSpec, error) Get(ctx context.Context, id int32) (*ComputeSpec, error) }
type GreeterRepo ¶
type GreeterRepo interface { Save(context.Context, *Greeter) (*Greeter, error) Update(context.Context, *Greeter) (*Greeter, error) FindByID(context.Context, int64) (*Greeter, error) ListByHello(context.Context, string) ([]*Greeter, error) ListAll(context.Context) ([]*Greeter, error) }
GreeterRepo is a Greater repo.
type GreeterUsecase ¶
type GreeterUsecase struct {
// contains filtered or unexported fields
}
GreeterUsecase is a Greeter usecase.
func NewGreeterUsecase ¶
func NewGreeterUsecase(repo GreeterRepo, logger log.Logger) *GreeterUsecase
NewGreeterUsecase new a Greeter usecase.
func (*GreeterUsecase) CreateGreeter ¶
CreateGreeter creates a Greeter, and returns the new Greeter.
type Script ¶ added in v0.0.3
type Script struct { ID int32 `json:"id,omitempty"` UserId string `json:"userId,omitempty"` TaskNumber int32 `json:"taskNumber,omitempty"` ScriptName string `json:"scriptName,omitempty"` FileAddress string `json:"fileAddress,omitempty"` ScriptContent string `json:"scriptContent,omitempty"` CreateTime time.Time `json:"createTime,omitempty"` UpdateTime time.Time `json:"updateTime,omitempty"` }
Script is a Script model.
type ScriptExecutionRecord ¶ added in v0.0.3
type ScriptExecutionRecord struct { ID int32 `json:"id,omitempty"` UserID string `json:"user_id,omitempty"` FkScriptID int32 `json:"fk_script_id,omitempty"` TaskNumber int32 `json:"taskNumber,omitempty"` ScriptContent string `json:"fk_script_content,omitempty"` ScriptName string `json:"scriptName,omitempty"` FileAddress string `json:"fileAddress,omitempty"` ExecuteState int32 `json:"execute_state,omitempty"` ExecuteResult string `json:"execute_result,omitempty"` CreateTime time.Time `json:"create_time,omitempty"` UpdateTime time.Time `json:"update_time,omitempty"` }
ScriptExecutionRecord is a ScriptExecutionRecord model.
type ScriptExecutionRecordRepo ¶ added in v0.0.3
type ScriptExecutionRecordRepo interface { Save(context.Context, *ScriptExecutionRecord) (*ScriptExecutionRecord, error) Update(context.Context, *ScriptExecutionRecord) (*ScriptExecutionRecord, error) FindByID(context.Context, int32) (*ScriptExecutionRecord, error) PageByScriptId(context.Context, string, int32, int32) ([]*ScriptExecutionRecord, int32, error) FindLatestByUserIdAndScript(context.Context, string, int32) (*ScriptExecutionRecord, error) }
ScriptExecutionRecordRepo is a ScriptExecutionRecord repo.
type ScriptRepo ¶ added in v0.0.3
type ScriptRepo interface { Save(context.Context, *Script) (*Script, error) Update(context.Context, *Script) (*Script, error) FindByID(context.Context, int32) (*Script, error) PageByUserID(context.Context, string, int32, int32) ([]*Script, int32, error) }
ScriptRepo is a Script repo.
type ScriptUseCase ¶ added in v0.0.3
type ScriptUseCase struct {
// contains filtered or unexported fields
}
ScriptUseCase is a Script UseCase.
func NewScriptUseCase ¶ added in v0.0.3
func NewScriptUseCase(repo ScriptRepo, scriptExecutionRecordRepo ScriptExecutionRecordRepo, agentRepo AgentRepo, p2pClient *goipfsp2p.P2pClient, logger log.Logger) *ScriptUseCase
NewScriptUseCase new a Script UseCase.
func (*ScriptUseCase) CancelExecPythonPackage ¶ added in v0.0.3
func (uc *ScriptUseCase) CancelExecPythonPackage(ctx context.Context, scriptId int32) (*ScriptExecutionRecord, error)
func (*ScriptUseCase) CreateScript ¶ added in v0.0.3
CreateScript creates a Script, and returns the new Script.
func (*ScriptUseCase) GetScriptExecutionRecordInfo ¶ added in v0.0.5
func (uc *ScriptUseCase) GetScriptExecutionRecordInfo(ctx context.Context, id int32) (*ScriptExecutionRecord, error)
func (*ScriptUseCase) GetScriptExecutionRecordPage ¶ added in v0.0.5
func (uc *ScriptUseCase) GetScriptExecutionRecordPage(ctx context.Context, userId string, page, size int32) ([]*ScriptExecutionRecord, int32, error)
func (*ScriptUseCase) RunPythonPackage ¶ added in v0.0.3
func (uc *ScriptUseCase) RunPythonPackage(ctx context.Context, id int32, userId string) (*ScriptExecutionRecord, error)
func (*ScriptUseCase) RunPythonPackageOnAgent ¶ added in v0.0.5
func (uc *ScriptUseCase) RunPythonPackageOnAgent(peerId string, record *ScriptExecutionRecord)
type Storage ¶
type Storage struct { ID uuid.UUID `json:"id,omitempty"` // Owner holds the value of the "owner" field. Owner string `json:"owner,omitempty"` // 0: DIR, 1:file Type int32 `json:"type,omitempty"` // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Cid holds the value of the "cid" field. Cid string `json:"cid,omitempty"` // size Size int32 `json:"size,omitempty"` // LastModify holds the value of the "last_modify" field. LastModify time.Time `json:"last_modify,omitempty"` // ParentID holds the value of the "parent_id" field. ParentID string `json:"parent_id,omitempty"` }
type StorageRepo ¶
type StorageRepo interface { ListStorage(ctx context.Context, owner string, parentId string) ([]*Storage, error) GetStorage(ctx context.Context, id uuid.UUID) (*Storage, error) CreateStorage(ctx context.Context, storage *Storage) error UpdateStorage(ctx context.Context, id uuid.UUID, storage *Storage) error DeleteStorage(ctx context.Context, id uuid.UUID) error }
type Storagecase ¶
type Storagecase struct {
// contains filtered or unexported fields
}
func NewStorageUsecase ¶
func NewStorageUsecase(repo StorageRepo, logger log.Logger) *Storagecase
func (*Storagecase) Create ¶
func (uc *Storagecase) Create(ctx context.Context, storage *Storage) error
type User ¶
type User struct { ID uuid.UUID `json:"id,omitempty"` // CountryCallCoding holds the value of the "country_call_coding" field. CountryCallCoding string `json:"country_call_coding,omitempty"` // TelephoneNumber holds the value of the "telephone_number" field. TelephoneNumber string `json:"telephone_number,omitempty"` // Password holds the value of the "password" field. Password string `json:"password,omitempty"` // CreateDate holds the value of the "create_date" field. CreateDate time.Time `json:"create_date,omitempty"` // LastLoginDate holds the value of the "last_login_date" field. LastLoginDate time.Time `json:"last_login_date,omitempty"` ValidateCode string `json:"validate_code"` // 用户名 Name string `json:"name,omitempty"` // 头像地址 Icon string `json:"icon,omitempty"` //是否配置过密码 PwdConfig bool }
func (*User) GetFullTelephone ¶
type UserRepo ¶
type UserRepo interface { ListUser(ctx context.Context, entity User) ([]*User, error) GetUser(ctx context.Context, id uuid.UUID) (*User, error) CreateUser(ctx context.Context, user *User) error UpdateUser(ctx context.Context, id uuid.UUID, user *User) error UpdateUserTelephone(ctx context.Context, id uuid.UUID, user *User) error UpdateUserPassword(ctx context.Context, id uuid.UUID, user *User) error DeleteUser(ctx context.Context, id uuid.UUID) error SendValidateCode(ctx context.Context, entity User) error GetValidateCode(ctx context.Context, user User) (string, error) DeleteValidateCode(ctx context.Context, user User) FindUserByFullTelephone(ctx context.Context, countryCallCoding string, telephone string) (*User, error) }
type UserUsercase ¶
type UserUsercase struct {
// contains filtered or unexported fields
}
func NewUserUsecase ¶
func (*UserUsercase) GetValidateCode ¶
func (*UserUsercase) LoginWithValidateCode ¶
func (*UserUsercase) SendValidateCode ¶
func (uc *UserUsercase) SendValidateCode(ctx context.Context, entity User) error
func (*UserUsercase) UpdateUserPassword ¶ added in v0.0.3
func (*UserUsercase) UpdateUserTelephone ¶ added in v0.0.3
Click to show internal directories.
Click to hide internal directories.