util

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessCode = 200
	ServerError = 500

	GetLocationError           = 3000
	GetCpAccountError          = 3001
	GeResourceError            = 3002
	JsonError                  = 4000
	BadParamError              = 4001
	SignatureError             = 4002
	SpaceParseResourceUriError = 4003
	CheckResourcesError        = 4004
	SpaceCheckWhiteListError   = 4005
	NoAvailableResourcesError  = 4006
	FoundJobEntityError        = 4007
	NotFoundJobEntityError     = 4008
	SaveJobEntityError         = 4009
	FoundWhiteListError        = 4010

	ProofParamError   = 7001
	ProofReadLogError = 7002
	ProofError        = 7003

	UbiTaskParamError    = 8001
	UbiTaskContractError = 8002
	FoundTaskEntityError = 8003
	SaveTaskEntityError  = 8004
	SubmitProofError     = 8005
)

Variables

This section is empty.

Functions

func MonitorShutdown

func MonitorShutdown(triggerCh <-chan struct{}, handlers ...ShutdownHandler) <-chan struct{}

func ReqContext

func ReqContext() context.Context

func RunPythonScript

func RunPythonScript(scriptPath ...string) (string, error)

func SaveMcsFileByUrlToFile

func SaveMcsFileByUrlToFile(fileName, mcsUrl string) error

func StreamPythonScriptOutput

func StreamPythonScriptOutput(wg *sync.WaitGroup, scriptPath ...string)

Types

type BasicResponse

type BasicResponse struct {
	Status  string      `json:"status"`
	Code    int         `json:"code"`
	Data    interface{} `json:"data,omitempty"`
	Message string      `json:"message,omitempty"`
}

func CreateErrorResponse

func CreateErrorResponse(code int, errMsg ...string) BasicResponse

func CreateSuccessResponse

func CreateSuccessResponse(_data interface{}) BasicResponse

type ShutdownHandler

type ShutdownHandler struct {
	Component string
	StopFunc  StopFunc
}

type StopFunc

type StopFunc func(context.Context) error

func ServeHttp

func ServeHttp(h http.Handler, name string, addr string, ssl bool) (StopFunc, error)

Jump to

Keyboard shortcuts

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