module

package
v0.0.0-...-9f73af6 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SD_CONFIG         = "config.json"
	SD_START_TIMEOUT  = 5 * 60 * 1000 // 5min
	SD_DETECT_TIMEOUT = 500           // 500ms
	SD_REQUEST_WAIT   = 30 * 1000     // 30s
)
View Source
const (
	SESSIONLENGTH = 64
	DefaultUser   = "admin"
	DefaultPasswd = "123"
)
View Source
const (
	ConfigDefaultKey = "default"
)
View Source
const (
	RETRY_INTERVALMS = time.Duration(10) * time.Millisecond
)

Variables

View Source
var (
	ProxyGlobal = NewProxy()
)
View Source
var UserManagerGlobal *userManager

Functions

func CancelEvent

func CancelEvent(v any)

CancelEvent tasks cancel signal callback

func ConfigEvent

func ConfigEvent(v any)

ConfigEvent config.json

func GetFunctionName

func GetFunctionName(key string) string

GetFunctionName hash key, avoid generating invalid characters

func GetHttpTrigger

func GetHttpTrigger(functionName string) string

func InitFuncManager

func InitFuncManager(funcStore datastore.Datastore) error

func InitUserManager

func InitUserManager(userStore datastore.Datastore) error

func ModelChangeEvent

func ModelChangeEvent(v any)

ModelChangeEvent models change callback func

func NewOssManager

func NewOssManager() error

func UpdateSdConfig

func UpdateSdConfig(configStore datastore.Datastore) error

UpdateSdConfig modify sd config.json sd_model_checkpoint and sd_vae

Types

type CallBack

type CallBack func(v any)

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 NewListenDbTask(intervalSecond int32, taskStore datastore.Datastore,
	modelStore datastore.Datastore, configStore datastore.Datastore) *ListenDbTask

func (*ListenDbTask) AddTask

func (l *ListenDbTask) AddTask(key string, listenType ListenType, callBack CallBack)

AddTask add listen task

func (*ListenDbTask) Close

func (l *ListenDbTask) Close()

Close listen

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 Proxy

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

func NewProxy

func NewProxy() *Proxy

func (*Proxy) Close

func (p *Proxy) Close()

type SDManager

type SDManager struct {
	// contains filtered or unexported fields
}
var (
	SDManageObj *SDManager
)

func NewSDManager

func NewSDManager(port string) *SDManager

func (*SDManager) Close

func (s *SDManager) Close()

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

type SdModels

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

type TaskItem

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

Jump to

Keyboard shortcuts

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