api

package
v0.0.0-...-977965f Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	// Auth incoming request
	//
	// req *http.Request: the incoming request
	//
	// Returns:
	// nil returned if successfully done
	// otherwise an error returned
	DoAuth(req *http.Request) error
}

Authenticator defined behaviors of doing auth checking.

type BaseRouter

type BaseRouter struct {
	// contains filtered or unexported fields
}

BaseRouter provides the basic routes for the job service based on the golang http server mux.

func (*BaseRouter) ServeHTTP

func (br *BaseRouter) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is the implementation of Router interface. 用来处理 http 请求

type DefaultHandler

type DefaultHandler struct {
	// contains filtered or unexported fields
}

DefaultHandler is the default request handler which implements the Handler interface. 继承了 core 中的接口

func NewDefaultHandler

func NewDefaultHandler(ctl core.Interface) *DefaultHandler

NewDefaultHandler is constructor of DefaultHandler.

func (*DefaultHandler) HandleCheckStatusReq

func (dh *DefaultHandler) HandleCheckStatusReq(w http.ResponseWriter, req *http.Request)

HandleCheckStatusReq is implementation of method defined in interface 'Handler' 健康检查,获取 redis 的健康状态

func (*DefaultHandler) HandleGetJobReq

func (dh *DefaultHandler) HandleGetJobReq(w http.ResponseWriter, req *http.Request)

HandleGetJobReq is implementation of method defined in interface 'Handler'

func (*DefaultHandler) HandleJobActionReq

func (dh *DefaultHandler) HandleJobActionReq(w http.ResponseWriter, req *http.Request)

HandleJobActionReq is implementation of method defined in interface 'Handler' 对 job 进行控制 stop/cancel

func (*DefaultHandler) HandleJobLogReq

func (dh *DefaultHandler) HandleJobLogReq(w http.ResponseWriter, req *http.Request)

HandleJobLogReq is implementation of method defined in interface 'Handler'

func (*DefaultHandler) HandleLaunchJobReq

func (dh *DefaultHandler) HandleLaunchJobReq(w http.ResponseWriter, req *http.Request)

HandleLaunchJobReq is implementation of method defined in interface 'Handler' 处理发送来的镜像扫描 job

type Handler

type Handler interface {
	// HandleLaunchJobReq is used to handle the job submission request.
	//用来处理 job 的提交请求
	HandleLaunchJobReq(w http.ResponseWriter, req *http.Request)

	// HandleGetJobReq is used to handle the job stats query request.
	// 用来处理 查询 job 状态请求
	HandleGetJobReq(w http.ResponseWriter, req *http.Request)

	// HandleJobActionReq is used to handle the job action requests (stop/retry).
	// 用来处理 对 job 的控制请求
	HandleJobActionReq(w http.ResponseWriter, req *http.Request)

	// HandleCheckStatusReq is used to handle the job service healthy status checking request.
	// 健康检查
	HandleCheckStatusReq(w http.ResponseWriter, req *http.Request)

	// HandleJobLogReq is used to handle the request of getting job logs
	// 获取 job 日志
	HandleJobLogReq(w http.ResponseWriter, req *http.Request)
}

Handler defines approaches to handle the http requests.

type Router

type Router interface {
	// ServeHTTP used to handle the http requests
	ServeHTTP(w http.ResponseWriter, req *http.Request)
}

Router defines the related routes for the job service and directs the request to the right handler method.

func NewBaseRouter

func NewBaseRouter(handler Handler, authenticator Authenticator) Router

NewBaseRouter is the constructor of BaseRouter. 基础路由,在 jobservice 启动的过程中使用

type SecretAuthenticator

type SecretAuthenticator struct{}

SecretAuthenticator implements interface 'Authenticator' based on simple secret.

func (*SecretAuthenticator) DoAuth

func (sa *SecretAuthenticator) DoAuth(req *http.Request) error

DoAuth implements same method in interface 'Authenticator'.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server serves the http requests.

func NewServer

func NewServer(ctx *env.Context, router Router, cfg ServerConfig) *Server

NewServer is constructor of Server.

func (*Server) Start

func (s *Server) Start()

Start the server to serve requests. 启动 API 服务器

func (*Server) Stop

func (s *Server) Stop()

Stop server gracefully.

type ServerConfig

type ServerConfig struct {
	// Protocol server listening on: https/http
	Protocol string

	// Server listening port
	Port uint

	// Cert file path if using https
	Cert string

	// Key file path if using https
	Key string
}

ServerConfig contains the configurations of Server.

Jump to

Keyboard shortcuts

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