Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorToRanderJson(err error) puzzle.DefaultRender
- func GetFormatRequestTime(time time.Time) string
- func GetRequestCost(start, end time.Time) float64
- func GetRequestData(requestBody interface{}) (encodeData string, err error)
- func GetUrlData(data map[string]string) (string, error)
- type Api
- func (entity *Api) HttpGet(uri string, params map[string]string, header map[string]string) (data []byte, err error)
- func (entity *Api) HttpPost(uri string, params map[string]string, header map[string]string) (data []byte, err error)
- func (entity *Api) HttpPostJSON(uri string, params map[string]interface{}, header map[string]string) (data []byte, err error)
- func (entity *Api) MakeRequest(method, url string, data io.Reader, headers map[string]string, ...) (*http.Request, error)
- func (entity *Api) PostData(uri string, params map[string]interface{}) (data []byte, err error)
- func (entity *Api) PostDataJson(uri string, params map[string]interface{}, header map[string]string) (data []byte, err error)
- func (entity *Api) PostForm(uri string, params map[string]interface{}, header *map[string]string) ([]byte, error)
- func (entity *Api) PreUse(args ...interface{})
- func (entity *Api) RalPost(uri string, params map[string]interface{}, header map[string]string) (*puzzle.DefaultRender, error)
- func (entity *Api) Request(method string, uri string, reqBody []byte, header map[string]string, ...) (data []byte, err error)
- type ApiConf
- type ApiRequest
- type BackOffPolicy
- type BaseError
- type ConsumeHandler
- type Controller
- func (entity *Controller) Action()
- func (entity *Controller) BindParam(req interface{}) bool
- func (entity *Controller) BindParamError(req interface{}) error
- func (entity *Controller) RenderHttpError(errNo int, errDetail ...interface{})
- func (entity *Controller) RenderJsonAbort(err error)
- func (entity *Controller) RenderJsonFail(err error)
- func (entity *Controller) RenderJsonSucc(data interface{})
- type Dao
- func (entity *Dao) Create(value interface{}) error
- func (entity *Dao) GetDB(args ...string) *gorm.DB
- func (entity *Dao) GetTable() string
- func (entity *Dao) PreUse(args ...interface{})
- func (entity *Dao) Printf(msg string, args ...interface{})
- func (entity *Dao) SetDB(db *gorm.DB)
- func (entity *Dao) SetTable(tableName string)
- func (entity *Dao) Update(model interface{}, attrs interface{}, query interface{}, args ...interface{}) error
- type Domain
- type Flow
- func (entity *Flow) CountArgs() int
- func (entity *Flow) GetAllArgs() []interface{}
- func (entity *Flow) GetArgs(idx int) interface{}
- func (entity *Flow) GetContext() *gin.Context
- func (entity *Flow) GetLog() *zap.SugaredLogger
- func (entity *Flow) GetLogCtx() *puzzle.LogCtx
- func (entity *Flow) LogDebug(args ...interface{})
- func (entity *Flow) LogDebugf(format string, args ...interface{})
- func (entity *Flow) LogError(args ...interface{})
- func (entity *Flow) LogErrorf(format string, args ...interface{})
- func (entity *Flow) LogInfo(args ...interface{})
- func (entity *Flow) LogInfof(format string, args ...interface{})
- func (entity *Flow) LogWarn(args ...interface{})
- func (entity *Flow) LogWarnf(format string, args ...interface{})
- func (entity *Flow) PreUse(args ...interface{})
- func (entity *Flow) SetArgs(idx int, arg interface{}) *Flow
- func (entity *Flow) SetContext(ctx *gin.Context) *Flow
- func (entity *Flow) SetLog(log *zap.SugaredLogger) *Flow
- func (entity *Flow) SetLogCtx(logCtx *puzzle.LogCtx) *Flow
- func (entity *Flow) Use(newFlow IFlow, args ...interface{}) interface{}
- type IApi
- type IConsumer
- type IController
- type IDao
- type IDomain
- type IFlow
- type INMQConsumer
- type IService
- type ITask
- type KFKConsumer
- func (entity *KFKConsumer) Cleanup(sarama.ConsumerGroupSession) error
- func (entity *KFKConsumer) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
- func (entity *KFKConsumer) LogAndExit(format string, args ...interface{})
- func (entity *KFKConsumer) LoopKafka(handler ConsumeHandler)
- func (entity *KFKConsumer) Setup(sarama.ConsumerGroupSession) error
- type NmqConsumer
- type RetryPolicy
- type Service
- type Task
Constants ¶
View Source
const ( HttpHeaderService = "SERVICE" // trace 日志前缀标识(放在[]zap.Field的第一个位置提高效率) TopicType = "_tp" // 业务日志名字 LogNameServer = "server" // access 日志文件名字 LogNameAccess = "access" // module 日志文件名字 LogNameModule = "module" TraceHeaderKey = "Uber-Trace-Id" LogIDHeaderKey = "X_BD_LOGID" LogIDHeaderKeyLower = "x_bd_logid" )
Variables ¶
View Source
var ( //StackLogger func(ctx *gin.Context, err error) ErrMsgMap map[int]string NmqResponseStatusCodeError = 500 NmqRetryError = 34002 )
Functions ¶
func ErrorToRanderJson ¶
func ErrorToRanderJson(err error) puzzle.DefaultRender
func GetFormatRequestTime ¶
func GetRequestCost ¶
func GetRequestData ¶
Types ¶
type Api ¶
func (*Api) HttpPostJSON ¶
func (*Api) MakeRequest ¶
func (*Api) PostDataJson ¶
type ApiConf ¶
type ApiConf struct { Service string `yaml:"service"` AppKey string `yaml:"appkey"` Domain string `yaml:"domain"` Timeout time.Duration `yaml:"timeout"` ConnectTimeout time.Duration `yaml:"connectTimeout"` Retry int `yaml:"retry"` HttpStat bool `yaml:"httpStat"` Proxy string `yaml:"proxy"` BasicAuth struct { Username string `yaml:"username"` Password string `yaml:"password"` } }
func (*ApiConf) GetTransPort ¶
type ApiRequest ¶
type ApiRequest struct { Req *http.Request HTTPClient *http.Client // 重试策略,可不指定,默认使用`defaultRetryPolicy`(只有在`api.yaml`中指定retry>0 时生效) RetryPolicy RetryPolicy // 重试间隔机制,可不指定,默认使用`defaultBackOffPolicy`(只有在`api.yaml`中指定retry>0 时生效) BackOffPolicy BackOffPolicy // contains filtered or unexported fields }
func (*ApiRequest) GetBackOffPolicy ¶
func (entity *ApiRequest) GetBackOffPolicy() BackOffPolicy
func (*ApiRequest) GetRetryPolicy ¶
func (entity *ApiRequest) GetRetryPolicy() RetryPolicy
type ConsumeHandler ¶
type ConsumeHandler func(sarama.ConsumerGroupSession, *sarama.ConsumerMessage) error
type Controller ¶
type Controller struct {
Flow
}
func (*Controller) Action ¶
func (entity *Controller) Action()
func (*Controller) BindParam ¶
func (entity *Controller) BindParam(req interface{}) bool
func (*Controller) BindParamError ¶
func (entity *Controller) BindParamError(req interface{}) error
func (*Controller) RenderHttpError ¶
func (entity *Controller) RenderHttpError(errNo int, errDetail ...interface{})
func (*Controller) RenderJsonAbort ¶
func (entity *Controller) RenderJsonAbort(err error)
func (*Controller) RenderJsonFail ¶
func (entity *Controller) RenderJsonFail(err error)
func (*Controller) RenderJsonSucc ¶
func (entity *Controller) RenderJsonSucc(data interface{})
type Flow ¶
type Flow struct { zap.SugaredLogger // contains filtered or unexported fields }
func (*Flow) GetAllArgs ¶
func (entity *Flow) GetAllArgs() []interface{}
func (*Flow) GetContext ¶
func (*Flow) GetLog ¶
func (entity *Flow) GetLog() *zap.SugaredLogger
type IConsumer ¶
type IConsumer interface { IFlow Run(args []string) error Setup(sarama.ConsumerGroupSession) error Cleanup(sarama.ConsumerGroupSession) error ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error }
type IController ¶
type IFlow ¶
type IFlow interface { GetContext() *gin.Context SetContext(*gin.Context) *Flow GetArgs(idx int) interface{} SetArgs(idx int, arg interface{}) *Flow GetAllArgs() []interface{} Use(newFlow IFlow, args ...interface{}) interface{} PreUse(args ...interface{}) GetLogCtx() *puzzle.LogCtx SetLogCtx(logCtx *puzzle.LogCtx) *Flow GetLog() *zap.SugaredLogger SetLog(log *zap.SugaredLogger) *Flow }
type INMQConsumer ¶
type KFKConsumer ¶
type KFKConsumer struct { Flow Ready chan bool Topics []string // contains filtered or unexported fields }
func (*KFKConsumer) Cleanup ¶
func (entity *KFKConsumer) Cleanup(sarama.ConsumerGroupSession) error
func (*KFKConsumer) ConsumeClaim ¶
func (entity *KFKConsumer) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error
func (*KFKConsumer) LogAndExit ¶
func (entity *KFKConsumer) LogAndExit(format string, args ...interface{})
func (*KFKConsumer) LoopKafka ¶
func (entity *KFKConsumer) LoopKafka(handler ConsumeHandler)
func (*KFKConsumer) Setup ¶
func (entity *KFKConsumer) Setup(sarama.ConsumerGroupSession) error
type NmqConsumer ¶
type NmqConsumer struct {
Flow
}
Click to show internal directories.
Click to hide internal directories.