Documentation ¶
Index ¶
- func ExtractHttp(r *http.Request) func() *model.SpanContext
- func Wrapper(f HandlerFunc) gin.HandlerFunc
- type BaseService
- func (s *BaseService) Call(ctx context.Context, service string, method string, args interface{}, ...) error
- func (s *BaseService) Client() *httpclient.ReqClient
- func (s *BaseService) CustomContext(key string) interface{}
- func (s *BaseService) Delete(handler *Handler) HandlerFunc
- func (s *BaseService) DeleteBatch(handler *Handler) HandlerFunc
- func (s *BaseService) Get(handler *Handler) HandlerFunc
- func (s *BaseService) GetList(handler *Handler) HandlerFunc
- func (s *BaseService) Head(handler *Handler) HandlerFunc
- func (s *BaseService) Interceptor() *Interceptor
- func (s *BaseService) Mongo() *mongo.MgoClient
- func (s *BaseService) Node() *NodeInfo
- func (s *BaseService) Options(handler *Handler) HandlerFunc
- func (s *BaseService) Patch(handler *Handler) HandlerFunc
- func (s *BaseService) Post(handler *Handler) HandlerFunc
- func (s *BaseService) Put(handler *Handler) HandlerFunc
- func (s *BaseService) Redis() *redis.RdClient
- func (s *BaseService) Reg() *Registry
- func (s *BaseService) Repo() *repo.Repository
- func (s *BaseService) SetClient(client *httpclient.ReqClient)
- func (s *BaseService) SetCustomContext(key string, value interface{})
- func (s *BaseService) SetInterceptor(op *Interceptor)
- func (s *BaseService) SetMongo(client *mongo.MgoClient)
- func (s *BaseService) SetNode(node *NodeInfo)
- func (s *BaseService) SetRedis(redisClient *redis.RdClient)
- func (s *BaseService) SetReg(reg *Registry)
- func (s *BaseService) SetRepo(repository *repo.Repository)
- func (s *BaseService) Use(handler *Handler)
- type Ctx
- func (c *Ctx) Csv(data []byte, filename string)
- func (c *Ctx) Failure(code int, err error, actual ...bool)
- func (c *Ctx) FileStream(data []byte, filename string)
- func (c *Ctx) Pdf(data []byte, filename string)
- func (c *Ctx) Response(code int, data interface{}, err error)
- func (c *Ctx) SetUser(user interface{})
- func (c *Ctx) SetUserGUID(guid uuid.GUID)
- func (c *Ctx) SetUserID(id int)
- func (c *Ctx) SetUserInfo(userInfo string)
- func (c *Ctx) Success(data interface{})
- func (c *Ctx) User() interface{}
- func (c *Ctx) UserGUID() (uuid.GUID, bool)
- func (c *Ctx) UserID() (int, bool)
- func (c *Ctx) UserInfo() (string, bool)
- type Handler
- func (h *Handler) Delete(path string)
- func (h *Handler) Get(path string)
- func (h *Handler) Head(path string)
- func (h *Handler) Options(path string)
- func (h *Handler) Patch(path string)
- func (h *Handler) Post(path string)
- func (h *Handler) Put(path string)
- func (h *Handler) Route(httpMethod string, path string)
- func (h *Handler) Use(handlerFunc ...gin.HandlerFunc)
- func (h *Handler) UseMiddleware(m ...Middleware)
- type HandlerFunc
- type IBaseService
- type Interceptor
- type Middleware
- func AuthMiddleware() Middleware
- func BreakerMiddleware(cb *breaker.CircuitBreaker) Middleware
- func DelayLimiterMiddleware(limiter *limit.Limiter) Middleware
- func ExtractHttpMiddleware() Middleware
- func MetricMiddleware(m *metric.Metric) Middleware
- func RateLimiterMiddleware(limiter *limit.Limiter) Middleware
- func ReserveLimiterMiddleware(limiter *limit.Limiter) Middleware
- func TracerMiddleware(t *tracing.Tracer, name string) Middleware
- type NodeInfo
- type Option
- func Cb(circuitBreaker *breaker.CircuitBreaker) Option
- func CustomContext(key string, value interface{}) Option
- func Limiter(limiter *limit.Limiter) Option
- func Metric(m *metric.Metric) Option
- func MongoClient(client *mongo.MgoClient) Option
- func RedisClient(redisClient *redis.RdClient) Option
- func Repository(repository *repo.Repository) Option
- func Tracer(tracer *tracing.Tracer) Option
- type Registry
- func (r *Registry) Deregister(node *NodeInfo, group *sync.WaitGroup, errChan chan error)
- func (r *Registry) GetService(name string) (*NodeInfo, error)
- func (r *Registry) Inject(service IBaseService)
- func (r *Registry) InjectSlice(services ...IBaseService)
- func (r *Registry) Register(node *NodeInfo, group *sync.WaitGroup, errChan chan error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractHttp ¶
func ExtractHttp(r *http.Request) func() *model.SpanContext
ExtractHttp 解包http头为SpanContext
func Wrapper ¶
func Wrapper(f HandlerFunc) gin.HandlerFunc
Types ¶
type BaseService ¶
type BaseService struct {
// contains filtered or unexported fields
}
func (*BaseService) Call ¶
func (s *BaseService) Call(ctx context.Context, service string, method string, args interface{}, replay interface{}) error
Call 调用其它服务方法 params:
@method: get请求: get get:id get@action post请求: post post@action put请求: put:id delete请求: delete delete:id @args: 调用方法的入参 @replay: 调用发放的返回
func (*BaseService) Client ¶
func (s *BaseService) Client() *httpclient.ReqClient
func (*BaseService) CustomContext ¶
func (s *BaseService) CustomContext(key string) interface{}
func (*BaseService) Delete ¶
func (s *BaseService) Delete(handler *Handler) HandlerFunc
func (*BaseService) DeleteBatch ¶
func (s *BaseService) DeleteBatch(handler *Handler) HandlerFunc
func (*BaseService) Get ¶
func (s *BaseService) Get(handler *Handler) HandlerFunc
func (*BaseService) GetList ¶
func (s *BaseService) GetList(handler *Handler) HandlerFunc
func (*BaseService) Head ¶
func (s *BaseService) Head(handler *Handler) HandlerFunc
func (*BaseService) Interceptor ¶
func (s *BaseService) Interceptor() *Interceptor
func (*BaseService) Mongo ¶
func (s *BaseService) Mongo() *mongo.MgoClient
func (*BaseService) Node ¶
func (s *BaseService) Node() *NodeInfo
func (*BaseService) Options ¶
func (s *BaseService) Options(handler *Handler) HandlerFunc
func (*BaseService) Patch ¶
func (s *BaseService) Patch(handler *Handler) HandlerFunc
func (*BaseService) Post ¶
func (s *BaseService) Post(handler *Handler) HandlerFunc
func (*BaseService) Put ¶
func (s *BaseService) Put(handler *Handler) HandlerFunc
func (*BaseService) Redis ¶
func (s *BaseService) Redis() *redis.RdClient
func (*BaseService) Reg ¶
func (s *BaseService) Reg() *Registry
func (*BaseService) Repo ¶
func (s *BaseService) Repo() *repo.Repository
func (*BaseService) SetClient ¶
func (s *BaseService) SetClient(client *httpclient.ReqClient)
func (*BaseService) SetCustomContext ¶
func (s *BaseService) SetCustomContext(key string, value interface{})
func (*BaseService) SetInterceptor ¶
func (s *BaseService) SetInterceptor(op *Interceptor)
func (*BaseService) SetMongo ¶
func (s *BaseService) SetMongo(client *mongo.MgoClient)
func (*BaseService) SetNode ¶
func (s *BaseService) SetNode(node *NodeInfo)
func (*BaseService) SetRedis ¶
func (s *BaseService) SetRedis(redisClient *redis.RdClient)
func (*BaseService) SetReg ¶
func (s *BaseService) SetReg(reg *Registry)
func (*BaseService) SetRepo ¶
func (s *BaseService) SetRepo(repository *repo.Repository)
func (*BaseService) Use ¶
func (s *BaseService) Use(handler *Handler)
type Handler ¶
type Handler struct { Middleware []Middleware GinMiddleware []gin.HandlerFunc RelativePath string HttpMethod string }
func (*Handler) Use ¶
func (h *Handler) Use(handlerFunc ...gin.HandlerFunc)
func (*Handler) UseMiddleware ¶
func (h *Handler) UseMiddleware(m ...Middleware)
type HandlerFunc ¶
type HandlerFunc func(*Ctx)
type IBaseService ¶
type IBaseService interface { Get(*Handler) HandlerFunc GetList(*Handler) HandlerFunc Post(*Handler) HandlerFunc Delete(*Handler) HandlerFunc DeleteBatch(*Handler) HandlerFunc Put(*Handler) HandlerFunc Head(*Handler) HandlerFunc Patch(*Handler) HandlerFunc Options(*Handler) HandlerFunc Use(*Handler) Repo() *repo.Repository SetRepo(*repo.Repository) Redis() *redis.RdClient SetRedis(*redis.RdClient) Mongo() *mongo.MgoClient SetMongo(*mongo.MgoClient) Client() *httpclient.ReqClient SetClient(*httpclient.ReqClient) Node() *NodeInfo SetNode(*NodeInfo) Reg() *Registry SetReg(*Registry) Interceptor() *Interceptor SetInterceptor(*Interceptor) CustomContext(string) interface{} SetCustomContext(string, interface{}) }
func NewService ¶
func NewService(service IBaseService, option ...Option) IBaseService
type Interceptor ¶
type Middleware ¶
type Middleware func(IBaseService) HandlerFunc
Middleware 中间件
func AuthMiddleware ¶
func AuthMiddleware() Middleware
func BreakerMiddleware ¶
func BreakerMiddleware(cb *breaker.CircuitBreaker) Middleware
BreakerMiddleware 断路器中间件
func DelayLimiterMiddleware ¶
func DelayLimiterMiddleware(limiter *limit.Limiter) Middleware
DelayLimiterMiddleware 频率延迟中间件
func ExtractHttpMiddleware ¶
func ExtractHttpMiddleware() Middleware
func RateLimiterMiddleware ¶
func RateLimiterMiddleware(limiter *limit.Limiter) Middleware
RateLimiterMiddleware 频率限制中间件
func ReserveLimiterMiddleware ¶
func ReserveLimiterMiddleware(limiter *limit.Limiter) Middleware
func TracerMiddleware ¶
func TracerMiddleware(t *tracing.Tracer, name string) Middleware
TracerMiddleware 服务跟踪中间件
type Option ¶
type Option func(service IBaseService)
func Cb ¶
func Cb(circuitBreaker *breaker.CircuitBreaker) Option
func CustomContext ¶
func MongoClient ¶
func RedisClient ¶
func Repository ¶
func Repository(repository *repo.Repository) Option
type Registry ¶
type Registry struct { sync.Mutex *consul.Client Services []*NodeInfo // contains filtered or unexported fields }
func (*Registry) Deregister ¶
func (*Registry) Inject ¶
func (r *Registry) Inject(service IBaseService)
func (*Registry) InjectSlice ¶
func (r *Registry) InjectSlice(services ...IBaseService)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.