Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteFile(appID string, objectID string) error
- func DeleteFileEx(appID string, appKey string, objectID string) error
- func DeployAppFromFile(appID string, group string, prod int, fileURL string, message string, ...) (string, error)
- func DeployAppFromGit(appID string, group string, prod int, revision string, noDepsCache bool, ...) (string, error)
- func DeployImage(appID string, group string, prod int, imageTag string, mode string) (string, error)
- func GetAppRegion(appID string) (regions.Region, error)
- func GetLoginedRegion() (result []regions.Region, err error)
- func LoginUSRegion() error
- func NewErrorFromBody(body string) error
- func NewErrorFromResponse(resp *grequests.Response) error
- func PollEvents(appID string, tok string) (bool, error)
- func PutEnvironments(appID string, group string, envs map[string]string) error
- func ReceiveLogsByLimit(printer LogReceiver, appID string, masterKey string, isProd bool, group string, ...) error
- func ReceiveLogsByRange(printer LogReceiver, appID string, masterKey string, isProd bool, group string, ...) error
- func UploadFile(appID string, filePath string) (*upload.File, error)
- func UploadFileEx(appID string, appKey string, filePath string) (*upload.File, error)
- type Client
- type Error
- type ExecuteCQLResult
- type ExecuteCacheCommandResult
- type GetAppInfoResult
- type GetAppListResult
- type GetCacheListResult
- type GetEngineInfoResult
- type GetGroupsResult
- type GetUserInfoResult
- type Log
- type LogReceiver
- type ReqStat
- type Status
Constants ¶
const ( DEPLOY_SMOOTHLY = "smoothly" DEPLOY_ATOMIC = "atomic" )
Variables ¶
var (
ErrNoEnoughData = errors.New("没有足够的数据")
)
var ( // ErrNotLogined means user was not logined ErrNotLogined = errors.New("not logined") )
var ( // Get2FACode is the function to get the user's two-factor-authentication code. // You can override it with your custom function. Get2FACode = func() (int, error) { result := new(string) wizard.Ask([]wizard.Question{ { Content: "请输入二次认证验证码", Input: &wizard.Input{ Result: result, Hidden: false, }, }, }) code, err := strconv.Atoi(*result) if err != nil { return 0, errors.New("二次认证验证码应该为数字") } return code, nil } )
Functions ¶
func DeleteFile ¶
DeleteFile will delete the specific file
func DeleteFileEx ¶
DeleteFileEx will delete the specific file
func DeployAppFromFile ¶
func DeployAppFromFile(appID string, group string, prod int, fileURL string, message string, noDepsCache bool, mode string) (string, error)
DeployAppFromFile will deploy applications with specific file returns the event token for polling deploy log
func DeployAppFromGit ¶
func DeployAppFromGit(appID string, group string, prod int, revision string, noDepsCache bool, mode string) (string, error)
DeployAppFromGit will deploy applications with user's git repo returns the event token for polling deploy log
func DeployImage ¶
func DeployImage(appID string, group string, prod int, imageTag string, mode string) (string, error)
DeployImage will deploy the engine group with specify image tag
func GetAppRegion ¶
GetAppRegion will query the app router, and return the app's region. The result is cached in process memory.
func GetLoginedRegion ¶
GetLoginedRegion returns all regions which is logined
func NewErrorFromBody ¶
NewErrorFromBody build an error value from JSON string
func NewErrorFromResponse ¶
NewErrorFromResponse build an error value from *grequest.Response
func PollEvents ¶
PollEvents will poll the server's event logs and print the result to the given io.Writer
func PutEnvironments ¶
func ReceiveLogsByLimit ¶
func ReceiveLogsByLimit(printer LogReceiver, appID string, masterKey string, isProd bool, group string, limit int, follow bool) error
ReceiveLogsByLimit will poll the leanengine's log and print it to the giver io.Writer
func ReceiveLogsByRange ¶
func ReceiveLogsByRange(printer LogReceiver, appID string, masterKey string, isProd bool, group string, from time.Time, to time.Time) error
ReceiveLogsByRange will poll the leanengine's log and print it to the giver io.Writer
func UploadFile ¶
UploadFile upload specific file to LeanCloud
Types ¶
type Error ¶
type Error struct { Code int `json:"code"` Content string `json:"error"` ErrorEventID string `json:"errorEventID"` }
Error is the LeanCloud API Server API common error format
type ExecuteCQLResult ¶
type ExecuteCQLResult struct { ClassName string `json:"className"` Results []map[string]interface{} `json:"results"` Count int `json:"count"` }
ExecuteCQLResult is ExecuteCQL's result type
func ExecuteCQL ¶
func ExecuteCQL(appID string, masterKey string, region regions.Region, cql string) (*ExecuteCQLResult, error)
ExecuteCQL will execute the cql, and returns' the result
type ExecuteCacheCommandResult ¶
type ExecuteCacheCommandResult struct {
Result interface{} `json:"result"`
}
ExecuteCacheCommandResult is ExecuteCacheCommand's result type
func ExecuteCacheCommand ¶
func ExecuteCacheCommand(appID string, instance string, db int, command string) (*ExecuteCacheCommandResult, error)
ExecuteCacheCommand will send command to LeanCache and excute it
type GetAppInfoResult ¶
type GetAppInfoResult struct { AppDomain string `json:"app_domain"` AppID string `json:"app_id"` AppKey string `json:"app_key"` AppName string `json:"app_name"` HookKey string `json:"hook_key"` MasterKey string `json:"master_key"` }
GetAppInfoResult is GetAppInfo function's result type
func GetAppInfo ¶
func GetAppInfo(appID string) (*GetAppInfoResult, error)
GetAppInfo returns the application's detail info
type GetAppListResult ¶
type GetAppListResult struct { AppID string `json:"app_id"` AppKey string `json:"app_key"` AppName string `json:"app_name"` MasterKey string `json:"master_key"` AppDomain string `json:"app_domain"` }
GetAppListResult is GetAppList function's result type
func GetAppList ¶
func GetAppList(region regions.Region) ([]*GetAppListResult, error)
GetAppList returns the current user's all LeanCloud application this will also update the app router cache
type GetCacheListResult ¶
type GetCacheListResult struct { Instance string `json:"instance"` MaxMemory int `json:"max_memory"` InstanceID string `json:"instance_id"` Info struct { UsedMemoryHuman string `json:"used_memory_human"` } `json:"info"` }
GetCacheListResult is GetCacheList's return structure type
func GetCacheList ¶
func GetCacheList(appID string) ([]*GetCacheListResult, error)
GetCacheList returns current app's LeanCache instance list
type GetEngineInfoResult ¶
type GetEngineInfoResult struct { AppID string `json:"appId"` Mode string `json:"mode"` InstanceLimit int `json:"instanceLimit"` Version string `json:"version"` Environments map[string]string `json:"environments"` }
func GetEngineInfo ¶
func GetEngineInfo(appID string) (*GetEngineInfoResult, error)
type GetGroupsResult ¶
type GetGroupsResult struct { GroupName string `json:"groupName"` Repository string `json:"repository"` Domain string `json:"domain"` Instances []struct { Name string `json:"name"` Quota int `json:"quota"` } `json:"instances"` StagingImage struct { Runtime string `json:"runtime"` ImageTag string `json:"imageTag"` } `json:"stagingImage"` Environments map[string]string `json:"environments"` }
GetGroupsResult is GetGroups's result struct
func GetGroup ¶
func GetGroup(appID string, groupName string) (*GetGroupsResult, error)
GetGroup will fetch all groups from API and return the current group info
func GetGroups ¶
func GetGroups(appID string) ([]*GetGroupsResult, error)
GetGroups returns the application's engine groups
type GetUserInfoResult ¶
GetUserInfoResult is the return type of GetUserInfo
func GetUserInfo ¶
func GetUserInfo(region regions.Region) (*GetUserInfoResult, error)
GetUserInfo returns the current logined user info
type Log ¶
type Log struct { InstanceName string `json:"instanceName"` Content string `json:"content"` Type string `json:"type"` Time string `json:"time"` GroupName string `json:"groupName"` Production int `json:"production"` OID string `json:"oid"` Level string `json:"level"` Instance string `json:"instance"` }
Log is EngineLogs's type structure
type LogReceiver ¶
LogReceiver is print func interface to PrintLogs
type ReqStat ¶
type ReqStat struct { Date string `json:"date"` ExceedTimes int `json:"exceed_times"` MaxDurationTime int `json:"max_duration_ms"` MeanQPS int `json:"meanQPS"` P95DurationTime int `json:"p95_duration_ms"` P90DurationTime int `json:"p90_duration_ms"` MaxConcurrent int `json:"max_concurrent"` MeanDurationTime int `json:"mean_duration_ms"` // ExceptionPercentage string `json:"exception_percentage"` MeanConcurrent int `json:"mean_concurrent"` MaxQPS int `json:"max_qps"` P80DurationTime int `json:"p80_duration_ms"` Error string `json:"error,omitempty"` ApiReqCount int `json:"apiReqCount"` }