Documentation
¶
Index ¶
- func DelayingLimiterMiddleware(limit ratelimit.Waiter) endpoint.Middleware
- func MakeDeleteEndpoint(s CptService) endpoint.Endpoint
- func MakeGetAllEndpoint(s CptService) endpoint.Endpoint
- func MakeGetSpecEndpoint(s CptService) endpoint.Endpoint
- func MakePostEndpoint(s CptService) endpoint.Endpoint
- func MakePutEndpoint(s CptService) endpoint.Endpoint
- type CptService
- type Decodes
- type Encodes
- type Endpoints
- type InstrumentingMiddleware
- func (i *InstrumentingMiddleware) Delete(ctx context.Context, taskId string, state string) (status bool, errinfo string, data *model.Task)
- func (i *InstrumentingMiddleware) GetAll(ctx context.Context, kind, state string, page, offset, limit int, ...) (status bool, errinfo string, data []model.Task)
- func (i *InstrumentingMiddleware) GetSpec(ctx context.Context, taskId string) (status bool, errinfo string, data interface{})
- func (i *InstrumentingMiddleware) Post(ctx context.Context, kind string, task interface{}) (status bool, errinfo string, data interface{})
- func (i *InstrumentingMiddleware) Put(ctx context.Context, taskId string, task interface{}) (status bool, errinfo string, data interface{})
- type LoggingMiddleware
- func (l *LoggingMiddleware) Delete(ctx context.Context, taskId string, state string) (status bool, errinfo string, data *model.Task)
- func (l *LoggingMiddleware) GetAll(ctx context.Context, kind, state string, page, offset, limit int, ...) (status bool, errinfo string, data []model.Task)
- func (l *LoggingMiddleware) GetSpec(ctx context.Context, taskId string) (status bool, errinfo string, data interface{})
- func (l *LoggingMiddleware) Post(ctx context.Context, kind string, task interface{}) (status bool, errinfo string, data interface{})
- func (l *LoggingMiddleware) Put(ctx context.Context, taskId string, task interface{}) (status bool, errinfo string, data interface{})
- type Request
- type Response
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
}
type LoggingMiddleware ¶
type LoggingMiddleware struct {
Logger log.Logger
Next CptService
}
log middleware
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.
Source Files
¶
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 |
Click to show internal directories.
Click to hide internal directories.