api

package
v0.0.0-...-6ac6f58 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PathV1 describe the prefix of version 1 http action.
	PathV1 = prefix + versionV1
)

Variables

This section is empty.

Functions

func FuncWrapper

func FuncWrapper(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)

FuncWrapper log before and after a request. If options is mater-required, then redirect the request to master node and return the data from master node.

func GetAPIV1Action

func GetAPIV1Action() []*httpserver.Action

GetAPIV1Action get V1 actions

func InitActionsFunc

func InitActionsFunc() error

InitActionsFunc will call all the functions in initFunc

func RegisterInitFunc

func RegisterInitFunc(f func() error)

RegisterInitFunc called by actions for registering some daemon functions and these functions will be called after flag-init and server-start

func RegisterV1Action

func RegisterV1Action(action Action)

RegisterV1Action register a handler into v1 actions means all the URL of these handlers are start with PathV1

func ReturnRest

func ReturnRest(resp *RestResponse)

ReturnRest do the return work according to a RestResponse

Types

type Action

type Action httpserver.Action

Action describe the http handler action.

type ErrorCode

type ErrorCode interface {
	// get error string
	String() string

	// get error code int
	Int() int
}

ErrorCode describe the error from http handler

type RestResponse

type RestResponse struct {
	Resp     *restful.Response
	HTTPCode int

	Data    interface{}
	ErrCode ErrorCode
	Message string
	Extra   map[string]interface{}

	WrapFunc func([]byte) []byte
}

RestResponse contains all response information need by a http handler

func (*RestResponse) Check

func (resp *RestResponse) Check()

Check make sure the fields set alright

func (*RestResponse) Wrap

func (resp *RestResponse) Wrap(r []byte) []byte

Wrap do the wrap function if set

type ServerAPIResource

type ServerAPIResource struct {
	ActionsV1 []*httpserver.Action
	ActionsV2 []*httpserver.Action
	Manager   types.Mgr
	Conf      *config.ServerConfig
}

ServerAPIResource describe all the server api resources

func GetAPIResource

func GetAPIResource() *ServerAPIResource

GetAPIResource get the standalone api resource instance

func (*ServerAPIResource) RegisterWebServer

func (a *ServerAPIResource) RegisterWebServer(svr *httpserver.HTTPServer) error

RegisterWebServer register all actions in api-resource into the given http server.

type ServerErrCode

type ServerErrCode int

ServerErrorCode implements the ErrorCode

const (
	ServerErrOK ServerErrCode = iota
	ServerErrInvalidParam
	ServerErrRedirectFailed
	ServerErrEncodeJSONFailed
	ServerErrRegisterWorkFailed
	ServerErrUnregisterWorkFailed
	ServerErrOccupyWorkerSlotsFailed
	ServerErrFreeWorkerSlotsFailed
	ServerErrOccupyLocalSlotsFailed
	ServerErrFreeLocalSlotsFailed
	ServerErrStartWorkFailed
	ServerErrEndWorkFailed
	ServerErrSetWorkSettings
	ServerErrGetWorkSettings
	ServerErrUpdateJobStats
	ServerErrRecordWorkStats
	ServerErrGetWorkStatus
	ServerErrOccupySlotsOrUsageNoEnough
	ServerErrQueryFileSendStatusFailed
	ServerErrUpdateFileSendStatusFailed
	ServerErrUpdateWorkHeartbeatFailed
	ServerErrGetWorkDetailFailed
	ServerErrExecuteRemoteTaskFailed
	ServerErrSendRemoteFileFailed
	ServerErrExecuteLocalTaskFailed
	ServerErrWorkNotFound
)

func (ServerErrCode) Int

func (sec ServerErrCode) Int() int

Int get code int from error code

func (ServerErrCode) String

func (sec ServerErrCode) String() string

String get error string from error code

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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