Documentation ¶
Index ¶
- Constants
- Variables
- func CancelEvent(v any)
- func ConfigEvent(v any)
- func GetFunctionName(key string) string
- func GetHttpTrigger(functionName string) string
- func InitFuncManager(funcStore datastore.Datastore) error
- func InitUserManager(userStore datastore.Datastore) error
- func ModelChangeEvent(v any)
- func NewOssManager() error
- func PredictProbe() bool
- func UpdateSdConfig(configStore datastore.Datastore) error
- type CallBack
- type FuncManager
- func (f *FuncManager) DeleteFunction(functions []string) ([]string, []string)
- func (f *FuncManager) GetEndpoint(sdModel string) (string, error)
- func (f *FuncManager) GetFcFunc(functionName string) interface{}
- func (f *FuncManager) GetFcFuncEnv(functionName string) *map[string]*string
- func (f *FuncManager) GetFileMgr() *fcUtils.Function
- func (f *FuncManager) GetFuncResource(functionName string) *FuncResource
- func (f *FuncManager) GetLastInvokeEndpoint(sdModel *string) string
- func (f *FuncManager) GetSd() *fcUtils.Function
- func (f *FuncManager) ListFunction() *project.T
- func (f *FuncManager) UpdateAllFunctionEnv() error
- func (f *FuncManager) UpdateFunctionEnv(key string) error
- func (f *FuncManager) UpdateFunctionResource(resources map[string]*FuncResource) ([]string, []string, []string)
- type FuncResource
- type ListenDbTask
- type ListenType
- type OssManagerLocal
- func (o *OssManagerLocal) DeleteFile(ossKey string) error
- func (o *OssManagerLocal) DownloadFile(ossKey, localFile string) error
- func (o *OssManagerLocal) DownloadFileToBase64(ossKey string) (*string, error)
- func (o *OssManagerLocal) GetUrl(ossKey []string) ([]string, error)
- func (o *OssManagerLocal) UploadFile(ossKey, localFile string) error
- func (o *OssManagerLocal) UploadFileByByte(ossKey string, body []byte) error
- type OssManagerRemote
- func (o *OssManagerRemote) DeleteFile(ossKey string) error
- func (o *OssManagerRemote) DownloadFile(ossKey, localFile string) error
- func (o *OssManagerRemote) DownloadFileToBase64(ossKey string) (*string, error)
- func (o *OssManagerRemote) GetUrl(ossKeys []string) ([]string, error)
- func (o *OssManagerRemote) UploadFile(ossKey, localFile string) error
- func (o *OssManagerRemote) UploadFileByByte(ossKey string, body []byte) error
- type OssOp
- type Proxy
- type SDManager
- type SdModels
- type TaskItem
Constants ¶
const ( SD_CONFIG = "config.json" SD_START_TIMEOUT = 5 * 60 * 1000 // 5min SD_DETECT_TIMEOUT = 500 // 500ms SD_REQUEST_WAIT = 30 * 1000 // 30s )
const ( SESSIONLENGTH = 64 DefaultUser = "admin" DefaultPasswd = "123" )
const (
ConfigDefaultKey = "default"
)
const (
RETRY_INTERVALMS = time.Duration(10) * time.Millisecond
)
Variables ¶
var (
ProxyGlobal = NewProxy()
)
var UserManagerGlobal *userManager
Functions ¶
func GetFunctionName ¶
GetFunctionName hash key, avoid generating invalid characters
func GetHttpTrigger ¶
func InitFuncManager ¶
func InitUserManager ¶
func NewOssManager ¶
func NewOssManager() error
func UpdateSdConfig ¶
UpdateSdConfig modify sd config.json sd_model_checkpoint and sd_vae
Types ¶
type FuncManager ¶
type FuncManager struct {
// contains filtered or unexported fields
}
FuncManager manager fc function create function and http trigger update instance env
var FuncManagerGlobal *FuncManager
func (*FuncManager) DeleteFunction ¶
func (f *FuncManager) DeleteFunction(functions []string) ([]string, []string)
DeleteFunction delete function
func (*FuncManager) GetEndpoint ¶
func (f *FuncManager) GetEndpoint(sdModel string) (string, error)
GetEndpoint get endpoint, key=sdModel retry and read from db if create function fail first get from cache second get from db third create function and return endpoint
func (*FuncManager) GetFcFunc ¶
func (f *FuncManager) GetFcFunc(functionName string) interface{}
GetFcFunc get fc function info
func (*FuncManager) GetFcFuncEnv ¶
func (f *FuncManager) GetFcFuncEnv(functionName string) *map[string]*string
GetFcFuncEnv get fc function env info
func (*FuncManager) GetFileMgr ¶
func (f *FuncManager) GetFileMgr() *fcUtils.Function
func (*FuncManager) GetFuncResource ¶
func (f *FuncManager) GetFuncResource(functionName string) *FuncResource
func (*FuncManager) GetLastInvokeEndpoint ¶
func (f *FuncManager) GetLastInvokeEndpoint(sdModel *string) string
GetLastInvokeEndpoint get last invoke endpoint
func (*FuncManager) GetSd ¶
func (f *FuncManager) GetSd() *fcUtils.Function
func (*FuncManager) ListFunction ¶
func (f *FuncManager) ListFunction() *project.T
func (*FuncManager) UpdateAllFunctionEnv ¶
func (f *FuncManager) UpdateAllFunctionEnv() error
UpdateAllFunctionEnv update instance env, restart agent function
func (*FuncManager) UpdateFunctionEnv ¶
func (f *FuncManager) UpdateFunctionEnv(key string) error
UpdateFunctionEnv update instance env input modelName and env
func (*FuncManager) UpdateFunctionResource ¶
func (f *FuncManager) UpdateFunctionResource(resources map[string]*FuncResource) ([]string, []string, []string)
UpdateFunctionResource update function resource
type FuncResource ¶
type FuncResource struct { Image string `json:"image"` CPU float32 `json:"cpu"` GpuMemorySize int32 `json:"gpuMemorySize"` InstanceType string `json:"InstanceType"` MemorySize int32 `json:"memorySize"` Timeout int32 `json:"timeout"` Env map[string]*string `json:"env"` VpcConfig *map[string]interface{} `json:"vpcConfig"` NasConfig *map[string]interface{} `json:"nasConfig"` OssMountConfig *map[string]interface{} `json:"ossMountConfig"` }
FuncResource Fc resource
type ListenDbTask ¶
type ListenDbTask struct {
// contains filtered or unexported fields
}
ListenDbTask listen db value change and call callback func for example: tasks cancel signal and models register/update
func NewListenDbTask ¶
func (*ListenDbTask) AddTask ¶
func (l *ListenDbTask) AddTask(key string, listenType ListenType, callBack CallBack)
AddTask add listen task
type ListenType ¶
type ListenType int32
const ( CancelListen ListenType = iota ModelListen ConfigListen )
type OssManagerLocal ¶
type OssManagerLocal struct { }
func (*OssManagerLocal) DeleteFile ¶
func (o *OssManagerLocal) DeleteFile(ossKey string) error
func (*OssManagerLocal) DownloadFile ¶
func (o *OssManagerLocal) DownloadFile(ossKey, localFile string) error
func (*OssManagerLocal) DownloadFileToBase64 ¶
func (o *OssManagerLocal) DownloadFileToBase64(ossKey string) (*string, error)
DownloadFileToBase64 : support png/jpg/jpeg
func (*OssManagerLocal) GetUrl ¶
func (o *OssManagerLocal) GetUrl(ossKey []string) ([]string, error)
func (*OssManagerLocal) UploadFile ¶
func (o *OssManagerLocal) UploadFile(ossKey, localFile string) error
func (*OssManagerLocal) UploadFileByByte ¶
func (o *OssManagerLocal) UploadFileByByte(ossKey string, body []byte) error
type OssManagerRemote ¶
type OssManagerRemote struct {
// contains filtered or unexported fields
}
func (*OssManagerRemote) DeleteFile ¶
func (o *OssManagerRemote) DeleteFile(ossKey string) error
DeleteFile delete file from oss
func (*OssManagerRemote) DownloadFile ¶
func (o *OssManagerRemote) DownloadFile(ossKey, localFile string) error
DownloadFile download file from oss
func (*OssManagerRemote) DownloadFileToBase64 ¶
func (o *OssManagerRemote) DownloadFileToBase64(ossKey string) (*string, error)
func (*OssManagerRemote) GetUrl ¶
func (o *OssManagerRemote) GetUrl(ossKeys []string) ([]string, error)
func (*OssManagerRemote) UploadFile ¶
func (o *OssManagerRemote) UploadFile(ossKey, localFile string) error
UploadFile upload file to oss
func (*OssManagerRemote) UploadFileByByte ¶
func (o *OssManagerRemote) UploadFileByByte(ossKey string, body []byte) error
UploadFileByByte UploadFile upload file to oss
type OssOp ¶
type OssOp interface { UploadFile(ossKey, localFile string) error UploadFileByByte(ossKey string, body []byte) error DownloadFile(ossKey, localFile string) error DeleteFile(ossKey string) error DownloadFileToBase64(ossPath string) (*string, error) GetUrl(ossPath []string) ([]string, error) }
var OssGlobal OssOp
OssGlobal oss manager
type SDManager ¶
type SDManager struct {
// contains filtered or unexported fields
}
var (
SDManageObj *SDManager
)
func NewSDManager ¶
func (*SDManager) KillAgentWithoutSd ¶
func (s *SDManager) KillAgentWithoutSd()
func (*SDManager) WaitPortWork ¶
func (s *SDManager) WaitPortWork()
func (*SDManager) WaitSDRestartFinish ¶
func (s *SDManager) WaitSDRestartFinish()
WaitSDRestartFinish blocking until sd restart finish