Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeConcatStringRequest(ctx context.Context, r interface{}) (interface{}, error)
- func DecodeDiffStringRequest(ctx context.Context, r interface{}) (interface{}, error)
- func EncodeStringResponse(_ context.Context, r interface{}) (interface{}, error)
- func MakeHealthCheckEndpoint(svc Service) endpoint.Endpoint
- func MakeStringEndpoint(svc Service) endpoint.Endpoint
- func NewStringServer(ctx context.Context, endpoints StringEndpoints) pb.StringServiceServer
- type HealthRequest
- type HealthResponse
- type Service
- type ServiceMiddleware
- type StringEndpoints
- type StringRequest
- type StringResponse
- type StringService
Constants ¶
View Source
const (
StrMaxSize = 1024
)
Service constants
Variables ¶
View Source
var ( ErrMaxSize = errors.New("maximum size of 1024 bytes exceeded") ErrStrValue = errors.New("maximum size of 1024 bytes exceeded") )
Service errors
View Source
var (
ErrInvalidRequestType = errors.New("RequestType has only two type: Concat, Diff")
)
View Source
var (
ErrorBadRequest = errors.New("invalid request parameter")
)
Functions ¶
func DecodeDiffStringRequest ¶
func EncodeStringResponse ¶
func MakeHealthCheckEndpoint ¶
MakeHealthCheckEndpoint 创建健康检查Endpoint
func MakeStringEndpoint ¶
MakeStringEndpoint make endpoint
func NewStringServer ¶
func NewStringServer(ctx context.Context, endpoints StringEndpoints) pb.StringServiceServer
Types ¶
type HealthResponse ¶
type HealthResponse struct {
Status bool `json:"status"`
}
HealthResponse 健康检查响应结构
type Service ¶
type Service interface { // Concat a and b Concat(ctx context.Context, a, b string) (string, error) // a,b pkg string value Diff(ctx context.Context, a, b string) (string, error) }
Service Define a service interface
type ServiceMiddleware ¶
ServiceMiddleware define service middleware
func LoggingMiddleware ¶
func LoggingMiddleware(logger log.Logger) ServiceMiddleware
LoggingMiddleware make logging middleware
type StringEndpoints ¶
type StringEndpoints struct { StringEndpoint endpoint.Endpoint HealthCheckEndpoint endpoint.Endpoint }
CalculateEndpoint define endpoint
type StringRequest ¶
type StringRequest struct { RequestType string `json:"request_type"` A string `json:"a"` B string `json:"b"` }
StringRequest define request struct
type StringResponse ¶
StringResponse define response struct
type StringService ¶
type StringService struct { }
ArithmeticService implement Service interface
Click to show internal directories.
Click to hide internal directories.