model

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FAILURE = 9999
	SUCCESS = 0
)
View Source
const (
	CLIENT = iota
	MASTER
	SLAVER
	ANALYSE
)
View Source
const (
	ErrorCodeConsoleWSClient = 1000 + iota
)
View Source
const Success = 0

Variables

View Source
var (
	Identify  = ""
	Version   = ""
	GitCommit = ""
	GitTag    = ""
	BuildDate = ""
)
View Source
var ErrorBaseNormal = func(info string) *ErrorModel {
	return NewErrModelByStr(global.ErrorCodeBase, "error : %v", info)
}
View Source
var ErrorConsoleParamsFormat = func(msg string) *ErrorModel {
	return NewErrModelByStr(ErrorCodeConsoleWSClient, "the params is not right: [%v]", msg)
}

Functions

This section is empty.

Types

type ErrorModel

type ErrorModel struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Suggest interface{} `json:"suggest,omitempty"`
	Params  interface{} `json:"params,omitempty"`
}

func NewErrModel

func NewErrModel(code int, err error) *ErrorModel

func NewErrModelByStr

func NewErrModelByStr(code int, msg string, args ...interface{}) *ErrorModel

func (*ErrorModel) ToString

func (eo *ErrorModel) ToString(args ...interface{}) string

type RespModel

type RespModel struct {
	Code    int                    `json:"code" example:"0"`
	Message string                 `json:"message,omitempty" example:""`
	Header  map[string]interface{} `json:"header,omitempty" example:""`
	Data    interface{}            `json:"data,omitempty" example:""`
}

func FailureRespWithErrModel

func FailureRespWithErrModel(obj *ErrorModel, args ...interface{}) RespModel

func FailureRespWithErrModelObj

func FailureRespWithErrModelObj(data interface{}, obj *ErrorModel) RespModel

func FailureRespWithError

func FailureRespWithError(code int, e error) RespModel

func FailureRespWithStr

func FailureRespWithStr(code int, msg string, v ...interface{}) RespModel

func NewRespModel

func NewRespModel(bytes []byte) RespModel

func SuccessResp

func SuccessResp(data interface{}) RespModel

func (RespModel) Bytes

func (resp RespModel) Bytes() []byte

func (RespModel) IsSuccess

func (resp RespModel) IsSuccess() bool

func (RespModel) String

func (resp RespModel) String() string

type ResultModel

type ResultModel[T any] struct {
	Code    int                    `json:"code" example:"0"`
	Message string                 `json:"message,omitempty" example:""`
	Header  map[string]interface{} `json:"header,omitempty" example:""`
	Data    T                      `json:"data,omitempty" example:""`
}

func FailureResultWithErrModel

func FailureResultWithErrModel[T any](obj *ErrorModel, args ...interface{}) ResultModel[T]

func FailureResultWithErrModelObj

func FailureResultWithErrModelObj[T any](data T, obj *ErrorModel) ResultModel[T]

func FailureResultWithError

func FailureResultWithError[T any](code int, e error) ResultModel[T]

func FailureResultWithStr

func FailureResultWithStr[T any](code int, msg string, v ...interface{}) ResultModel[T]

func NewResultModel

func NewResultModel[T any](bytes []byte) ResultModel[T]

func SuccessResult

func SuccessResult[T any](data T) ResultModel[T]

func (ResultModel[T]) Bytes

func (resp ResultModel[T]) Bytes() []byte

func (ResultModel[T]) IsSuccess

func (resp ResultModel[T]) IsSuccess() bool

func (ResultModel[T]) String

func (resp ResultModel[T]) String() string

type RunStatus

type RunStatus int

RunStatus 运行状态

const (
	// RunStatusStopped 停止
	RunStatusStopped RunStatus = 0
	// RunStatusPrepare 准备中
	RunStatusPrepare RunStatus = 1
	// RunStatusRunning 当前运行中
	RunStatusRunning RunStatus = 2
	// RunStatusIdle 当前空闲中
	RunStatusIdle RunStatus = 9
)

Jump to

Keyboard shortcuts

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