cpt

package
v0.0.0-...-4aec9fb Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelayingLimiterMiddleware

func DelayingLimiterMiddleware(limit ratelimit.Waiter) endpoint.Middleware

此函数并没有使用,函数已在go-kit包中实现

func MakeDeleteEndpoint

func MakeDeleteEndpoint(s CptService) endpoint.Endpoint

MakeDeleteEndpoint returns an endpoint that invokes Delete on the service.

func MakeGetAllEndpoint

func MakeGetAllEndpoint(s CptService) endpoint.Endpoint

MakeGetAllEndpoint returns an endpoint that invokes GetAll on the service.

func MakeGetSpecEndpoint

func MakeGetSpecEndpoint(s CptService) endpoint.Endpoint

MakeGetSpecEndpoint returns an endpoint that invokes GetSpec on the service.

func MakePostEndpoint

func MakePostEndpoint(s CptService) endpoint.Endpoint

MakePostEndpoint returns an endpoint that invokes Post on the service.

func MakePutEndpoint

func MakePutEndpoint(s CptService) endpoint.Endpoint

MakePutEndpoint returns an endpoint that invokes Put on the service.

Types

type CptService

type CptService interface {
	// 查询所有任务,kind和state为可选参数,返回值为缩略信息
	GetAll(ctx context.Context, kind string, state string, page, offset, limit int, orderby string) (status bool, errinfo string, data []model.Task)
	// 查询某个任务,返回值为相应类型的详细信息
	GetSpec(ctx context.Context, taskId string) (status bool, errinfo string, data interface{})
	// 创建任务,上传任务为详细信息
	Post(ctx context.Context, kind string, task interface{}) (status bool, errinfo string, data interface{})
	// 发布任务、领取任务、完成任务
	Put(ctx context.Context, taskId string, task interface{}) (status bool, errinfo string, data interface{})
	// // 取消领取任务、删除已完成任务、取消发布任务
	Delete(ctx context.Context, taskId string, state string) (status bool, errinfo string, data *model.Task)
}

func NewBasicCptService

func NewBasicCptService(conf string) CptService

NewBasicCptService returns a naive, stateless implementation of CptService.

type Decodes

type Decodes struct {
	GetSpecDecode func(ctx context.Context, r *http.Request) (interface{}, error)
	GetAllDecode  func(ctx context.Context, r *http.Request) (interface{}, error)
	PostDecode    func(ctx context.Context, r *http.Request) (interface{}, error)
	PutDecode     func(ctx context.Context, r *http.Request) (interface{}, error)
	DeleteDecode  func(ctx context.Context, r *http.Request) (interface{}, error)
}

func MakeServerDecodes

func MakeServerDecodes() Decodes

type Encodes

type Encodes struct {
	GetSpecEncode func(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)
	GetAllEncode  func(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)
	PostEncode    func(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)
	PutEncode     func(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)
	DeleteEncode  func(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)
}

func MakeServerEncodes

func MakeServerEncodes() Encodes

type Endpoints

type Endpoints struct {
	GetSpecEndpoint endpoint.Endpoint
	GetAllEndpoint  endpoint.Endpoint
	PostEndpoint    endpoint.Endpoint
	PutEndpoint     endpoint.Endpoint
	DeleteEndpoint  endpoint.Endpoint
}

func MakeServerEndpoints

func MakeServerEndpoints(s CptService) Endpoints

type InstrumentingMiddleware

type InstrumentingMiddleware struct {
	RequestCount   metrics.Counter
	RequestLatency metrics.Histogram
	Next           CptService
}

func (*InstrumentingMiddleware) Delete

func (i *InstrumentingMiddleware) Delete(ctx context.Context, taskId string, state string) (status bool, errinfo string, data *model.Task)

func (*InstrumentingMiddleware) GetAll

func (i *InstrumentingMiddleware) GetAll(ctx context.Context, kind, state string, page, offset, limit int, orderby string) (status bool, errinfo string, data []model.Task)

func (*InstrumentingMiddleware) GetSpec

func (i *InstrumentingMiddleware) GetSpec(ctx context.Context, taskId string) (status bool, errinfo string, data interface{})

func (*InstrumentingMiddleware) Post

func (i *InstrumentingMiddleware) Post(ctx context.Context, kind string, task interface{}) (status bool, errinfo string, data interface{})

func (*InstrumentingMiddleware) Put

func (i *InstrumentingMiddleware) Put(ctx context.Context, taskId string, task interface{}) (status bool, errinfo string, data interface{})

type LoggingMiddleware

type LoggingMiddleware struct {
	Logger log.Logger
	Next   CptService
}

log middleware

func (*LoggingMiddleware) Delete

func (l *LoggingMiddleware) Delete(ctx context.Context, taskId string, state string) (status bool, errinfo string, data *model.Task)

func (*LoggingMiddleware) GetAll

func (l *LoggingMiddleware) GetAll(ctx context.Context, kind, state string, page, offset, limit int, orderby string) (status bool, errinfo string, data []model.Task)

func (*LoggingMiddleware) GetSpec

func (l *LoggingMiddleware) GetSpec(ctx context.Context, taskId string) (status bool, errinfo string, data interface{})

func (*LoggingMiddleware) Post

func (l *LoggingMiddleware) Post(ctx context.Context, kind string, task interface{}) (status bool, errinfo string, data interface{})

func (*LoggingMiddleware) Put

func (l *LoggingMiddleware) Put(ctx context.Context, taskId string, task interface{}) (status bool, errinfo string, data interface{})

type Request

type Request struct {
	TaskId  string      `json:"taskId"`
	Kind    string      `json:"kind"`
	State   string      `json:"state"`
	Task    interface{} `json:"task"`
	Page    int         `json:"page"`
	Offset  int         `json:"offset"`
	Limit   int         `json:"limit"`
	Orderby string      `json:"orderby"`
}

Request collects the request parameters for the All method.

type Response

type Response struct {
	Status  bool        `json:"status"`
	Errinfo string      `json:"errinfo"`
	Data    interface{} `json:"data"`
}

Response collects the response parameters for the All method.

Directories

Path Synopsis
money-hub MoneyDodo/cpt This documentation describes example APIs found under https://github.com/money-hub/MoneyDodo.service Schemes: http Version: 1.0.0 License: MIT http://opensource.org/licenses/MIT Consumes: - application/json Produces: - application/json Security: - bearer SecurityDefinitions: bearer: type: apiKey name: Authorization in: header swagger:meta
money-hub MoneyDodo/cpt This documentation describes example APIs found under https://github.com/money-hub/MoneyDodo.service Schemes: http Version: 1.0.0 License: MIT http://opensource.org/licenses/MIT Consumes: - application/json Produces: - application/json Security: - bearer SecurityDefinitions: bearer: type: apiKey name: Authorization in: header swagger:meta

Jump to

Keyboard shortcuts

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