util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuccessCode = 200
	JsonError   = 400

	ProofParamError   = 8001
	ProofReadLogError = 8002
	ProofError        = 8003
)

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 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"`
	PageInfo *PageInfo   `json:"page_info,omitempty"`
}

func CreateErrorResponse

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

func CreateSuccessResponse

func CreateSuccessResponse(_data interface{}) BasicResponse

type MixedResponse

type MixedResponse struct {
	BasicResponse
	MixData struct {
		Success interface{} `json:"success"`
		Fail    interface{} `json:"fail"`
	} `json:"mix_data"`
}

type PageInfo

type PageInfo struct {
	PageNumber       string `json:"page_number"`
	PageSize         string `json:"page_size"`
	TotalRecordCount string `json:"total_record_count"`
}

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) (StopFunc, error)

Jump to

Keyboard shortcuts

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