utils

package
v0.0.0-...-90ad8ca Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RailsCachePool *redis.Pool
	DatePool       *redis.Pool
	TickerPool     *redis.Pool
	KLinePool      *redis.Pool
	LimitPool      *redis.Pool
)
View Source
var (
	SuccessResponse = Response{Head: map[string]string{"code": "1000", "msg": "Success."}}
	ArrayResponse   = ArrayDataResponse{Head: map[string]string{"code": "1000", "msg": "Success."}}
)
View Source
var (
	MainDb, BackupDb *gorm.DB
)
View Source
var QiniuConfig map[string]string
View Source
var S3Config map[string]string

Functions

func AddFileToS3

func AddFileToS3(s *session.Session, bucket, key, filePath string) error

AddFileToS3 will upload a single file to S3, it will require a pre-built aws session and will set file info like content type and encryption on the uploaded file.

func CloseBackupDB

func CloseBackupDB()

func CloseMainDB

func CloseMainDB()

func CloseRedisPools

func CloseRedisPools()

func GetRealIp

func GetRealIp(context echo.Context) (ip string)

func GetRedisConn

func GetRedisConn(redisName string) redis.Conn

func InitAwsS3Config

func InitAwsS3Config()

func InitBackupDB

func InitBackupDB()

func InitMainDB

func InitMainDB()

func InitQiniuConfig

func InitQiniuConfig()

func InitRedisPools

func InitRedisPools()

func RandStringRunes

func RandStringRunes(n int) string

func UploadFileToQiniu

func UploadFileToQiniu(bucket, key, filePath string) error

func UploadFileToS3

func UploadFileToS3(bucket, key, filePath string) error

Types

type ArrayBodyStruct

type ArrayBodyStruct struct {
	CurrentPage  int         `json:"current_page"`
	TotalPages   int         `json:"total_pages"`
	PerPage      int         `json:"per_page"`
	NextPage     int         `json:"next_page"`
	PreviousPage int         `json:"previous_page"`
	Data         interface{} `json:"data"`
}

type ArrayDataResponse

type ArrayDataResponse struct {
	Head map[string]string `json:"head"`
	Body interface{}       `json:"body"`
}

func (*ArrayDataResponse) Init

func (arrayResponse *ArrayDataResponse) Init(data interface{}, page, count, per_page int)

type ConfigEnv

type ConfigEnv struct {
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(configFile string) *ConfigEnv

func (*ConfigEnv) Get

func (env *ConfigEnv) Get(spec, defaultValue string) string

func (*ConfigEnv) GetDuration

func (env *ConfigEnv) GetDuration(spec string, defaultValue string) time.Duration

func (*ConfigEnv) GetInt

func (env *ConfigEnv) GetInt(spec string, defaultValue int) int

type GormDB

type GormDB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func BackupDbBegin

func BackupDbBegin() *GormDB

func MainDbBegin

func MainDbBegin() *GormDB

func (*GormDB) DbCommit

func (c *GormDB) DbCommit()

func (*GormDB) DbRollback

func (c *GormDB) DbRollback()

type MyPutRet

type MyPutRet struct {
	Key    string
	Hash   string
	Fsize  int
	Bucket string
	Name   string
}

type Response

type Response struct {
	Head map[string]string `json:"head"`
	Body interface{}       `json:"body"`
}

func BuildError

func BuildError(code string) Response

func (Response) Error

func (errorResponse Response) Error() string

Jump to

Keyboard shortcuts

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