Versions in this module Expand all Collapse all v0 v0.0.3 Aug 2, 2021 Changes in this version + func WithTrace() grpc.DialOption + type GrpcConn struct + type GrpcConnManager struct + func NewGrpcConnManager() *GrpcConnManager + func (gm *GrpcConnManager) AddConn(name, addr string, connecter GrpcConnecter, opts ...grpc.DialOption) + func (gm *GrpcConnManager) CloseConns() + func (gm *GrpcConnManager) Reconnect(name string) + type GrpcConnecter interface + OnConnected func(*grpc.ClientConn) v0.0.2 May 14, 2021 v0.0.1 Apr 29, 2021 Changes in this version + const CodeErr + const CodeOK + const TimeLayout1 + const TimeLayout2 + const TimeLayout3 + const TimeLayout4 + const TimeLayout5 + const TimeLayout6 + const TimeLayout7 + const TimeLayout8 + var DurationsSummary *prometheus.SummaryVec + var LatencyHistogram *prometheus.HistogramVec + var RequestCounter *prometheus.CounterVec + func BasicAuth(username, password string) gin.HandlerFunc + func CORS(acceptedOrigin, AcceptedMethods, AcceptedHeaders, MaxAge string) gin.HandlerFunc + func CreateFolder(path string) error + func Errf(fomart string, v ...interface{}) + func GetCaller(d int) (string, int) + func GetRealIP(req *http.Request) string + func GrpcRecovery(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (resp interface{}, err error) + func GzipJSON(c *gin.Context, data interface{}) + func HeadSeparator(path string) string + func InitPrometheus(space, name string) + func JSON(c *gin.Context, data interface{}) + func JsonErr(c *gin.Context, err error) + func JsonMsg(c *gin.Context, msg string) + func JsonOK(c *gin.Context, data interface{}) + func LoadJSON(name string, data interface{}) error + func LoadOrSaveJSON(name string, res interface{}, def func() interface{}) (err error) + func LoadOrSaveToml(name string, data interface{}, def func() interface{}) (err error) + func LoadToml(name string, data interface{}) error + func LogControl(trace bool, skip []string) gin.HandlerFunc + func LogErr(err error, msg string) + func Logf(fomart string, v ...interface{}) + func MD5(src string) []byte + func NewGrpcConn(addr string) (*grpc.ClientConn, error) + func NewRedisClient(addr, pass string, db int) *redis.Client + func NewRedisClients(addr, pass string) (clients map[int]*redis.Client, err error) + func NoCache() gin.HandlerFunc + func PromeMetrics() gin.HandlerFunc + func PromeTrace(label string) func() + func PromeUnaryInterceptor() grpc.ServerOption + func PromethousHandler() gin.HandlerFunc + func RandomString(n int) string + func Run(app AppInterface) + func SaveJSON(name string, data interface{}) error + func SaveToml(name string, data interface{}) error + func StrTime(timestamp int64, timeLayout string) string + func TailSeparator(path string) string + func ToJsonStr(data interface{}) string + func Trace(msg string) func() + func TraceUnaryInt(ctx context.Context, method string, req, reply interface{}, ...) error + func UUID() string + func UnixTime(timeStr, layout string) int64 + func Warnf(fomart string, v ...interface{}) + type App struct + Na string + Start func() bool + Stop func() + Svrs []ServerInterface + func NewApp(name string, start func() bool, stop func(), svrs ...ServerInterface) *App + func (a *App) Name() string + func (a *App) OnStart() bool + func (a *App) OnStop() + func (a *App) Servers() []ServerInterface + type AppInterface interface + Name func() string + OnStart func() bool + OnStop func() + Servers func() []ServerInterface + type DSN struct + DBName string + LogLevel logger.LogLevel + Password string + Port string + PreStmt bool + SkipTran bool + URL string + Username string + func (d DSN) MySQL() string + func (d DSN) Postgres() string + type GinServer struct + Engine *gin.Engine + Name string + Server *http.Server + func NewGinServer(name, addr, mod string) *GinServer + func (s *GinServer) Group(path string, handlers ...gin.HandlerFunc) *gin.RouterGroup + func (s *GinServer) Health() + func (s *GinServer) Info() string + func (s *GinServer) OnStart() bool + func (s *GinServer) OnStop() + func (s *GinServer) Promethous(name, pass string) + type GormDB struct + func MustOpen(dial gorm.Dialector, d DSN) *GormDB + func MustOpenMySQL(d DSN) *GormDB + func MustOpenPostgres(d DSN) *GormDB + func (db *GormDB) BatchInsert(tb string, value interface{}, batchSize int) error + func (db *GormDB) ExecSQL(sql string, values ...interface{}) (int64, error) + func (db *GormDB) Insert(tb string, value interface{}) error + func (db *GormDB) Query(dest interface{}, stmt string, values ...interface{}) error + func (db *GormDB) QueryRow(stmt string, values ...interface{}) *sql.Row + func (db *GormDB) QueryRows(hand func(*sql.Rows) error, sql string, values ...interface{}) (err error) + func (gdb *GormDB) CloseDB() + type GrpcServer struct + Addr string + Name string + Register func(*GrpcServer) + func NewGrpcServer(name, addr string, reg func(*GrpcServer), opt ...grpc.ServerOption) *GrpcServer + func (gs *GrpcServer) Info() string + func (gs *GrpcServer) OnStart() bool + func (gs *GrpcServer) OnStop() + type HttpClient struct + func NewHttpClient() *HttpClient + func (c *HttpClient) GetJSON(url string, data interface{}) (err error) + func (c *HttpClient) GetJSONAuth(url, un, pa string, data interface{}) (err error) + func (c *HttpClient) PostFormJSON(url string, vals url.Values, data interface{}) (err error) + func (c *HttpClient) PostFormJSONAuth(url, un, pa string, vals url.Values, data interface{}) (err error) + func (c *HttpClient) PostJSON(url string, src, data interface{}) (err error) + func (c *HttpClient) PostJSONAuth(url, un, pa string, src, data interface{}) (err error) + type MqttSubPub struct + func NewMqttSubPub(id, addr, user, pass string, topics ...string) *MqttSubPub + func (m *MqttSubPub) Info() string + func (m *MqttSubPub) OnStart() bool + func (m *MqttSubPub) OnStop() + func (m *MqttSubPub) Pub(topic string, payload []byte) + func (m *MqttSubPub) SetSubDeal(deal func(mqtt.Message)) + type Queue struct + func NewQueue(size, num int, deal dealFunc) *Queue + func (q *Queue) Start() + func (q *Queue) Stop() + func (q *Queue) SubmitAsync(item interface{}) + func (q *Queue) SubmitSync(item interface{}) + type QueueManager struct + func NewQueueManager() *QueueManager + func (qm *QueueManager) AddQueue(q *Queue) + func (qm *QueueManager) GetQueue(i int) *Queue + func (qm *QueueManager) PushQueue(i int, args interface{}, async bool) + func (qm *QueueManager) StartQueue() + func (qm *QueueManager) StopQueue() + type Resp struct + Code int + Data interface{} + func NewResp(code int, data interface{}) *Resp + func RespErr(err error) *Resp + func RespMsg(code int, msg string) *Resp + func RespOK(data interface{}) *Resp + type Serial struct + func NewSerial(reset int) *Serial + func (s *Serial) Get() int + func (s *Serial) Reset(c int) + func (s *Serial) Start() + type ServerInterface interface + Info func() string + OnStart func() bool + OnStop func() + type StmtDB struct + func NewStmtDB(db *sqlx.DB) *StmtDB + func (s *StmtDB) CloseDB() + func (s *StmtDB) DeferLock() func() + func (s *StmtDB) Lock() + func (s *StmtDB) NStmt(sqlStr string) (stmt *sqlx.NamedStmt, err error) + func (s *StmtDB) Stmt(sqlStr string) (stmt *sqlx.Stmt, err error) + func (s *StmtDB) Unlock() + type TStamp int64 + func NewStampTime(te time.Time) TStamp + func NewStrStamp(ts string) TStamp + func NewTimeStamp(ts int64) TStamp + func (t *TStamp) UnmarshalJSON(b []byte) error + func (t TStamp) Format(layout string) string + func (t TStamp) GoString() string + func (t TStamp) Int64() int64 + func (t TStamp) MarshalJSON() (buf []byte, err error) + func (t TStamp) String() string + func (t TStamp) Time() time.Time + type XmlMap map[string]string + func (m *XmlMap) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error + func (m XmlMap) MarshalXML(e *xml.Encoder, start xml.StartElement) error