service

package
v0.0.0-...-9be9f3c Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest = errors.New("bad request")
)
View Source
var (
	ErrLoadToMem = errors.New("err occur on loading data from db to memory")
)

Functions

func DecodeGRPCGetUserInfoReq

func DecodeGRPCGetUserInfoReq(_ context.Context, request interface{}) (interface{}, error)

for server

func DecodeGRPCGetUserInfoRes

func DecodeGRPCGetUserInfoRes(_ context.Context, response interface{}) (interface{}, error)

func EncodeGRPCGetUserInfoReq

func EncodeGRPCGetUserInfoReq(_ context.Context, request interface{}) (interface{}, error)

for client

func EncodeGRPCGetUserInfoRes

func EncodeGRPCGetUserInfoRes(_ context.Context, response interface{}) (interface{}, error)

func EncodeHTTPGenericResponse

func EncodeHTTPGenericResponse(_ context.Context, w http.ResponseWriter, response interface{}) error

func EndpointInstrumentingMiddleware

func EndpointInstrumentingMiddleware(duration metrics.Histogram) endpoint.Middleware

func EndpointLoggingMiddleware

func EndpointLoggingMiddleware(logger log.Logger) endpoint.Middleware

EndpointLoggingMiddleware returns an endpoint middleware that logs the duration of each invocation, and the resulting error, if any.

func MakeGRPCHandler

func MakeGRPCHandler(endpoints Endpoints, tracer stdopentracing.Tracer, logger log.Logger) pb.UserServer

func MakeGetUserInfoEndpoint

func MakeGetUserInfoEndpoint(s Service) endpoint.Endpoint

func RC4Crypt

func RC4Crypt(s []byte) []byte

Types

type Endpoints

type Endpoints struct {
	GetUserInfoEndpoint endpoint.Endpoint
}

func (Endpoints) GetUserInfo

func (e Endpoints) GetUserInfo(ctx context.Context, uid int64) (user *center.User, err error)

type Middleware

type Middleware func(Service) Service

func ServiceInstrumentingMiddleware

func ServiceInstrumentingMiddleware(requestCount metrics.Counter, requestLatency metrics.Histogram) Middleware

func ServiceLoggingMiddleware

func ServiceLoggingMiddleware(logger log.Logger) Middleware

type Service

type Service interface {
	GetUserInfo(ctx context.Context, id int64) (user *center.User, err error)
}

func NewBasicService

func NewBasicService(dbRep center.DBRepository, mqRep center.MQRepository, logger log.Logger) Service

Jump to

Keyboard shortcuts

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