util

package
v0.0.0-...-5951e82 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderSet = wire.NewSet(NewEmailNotify)

ProviderSet is util providers.

Functions

func Get

func Get(url string) string

Get 发送GET请求 url: 请求地址 response: 请求返回的内容

func GetTableRows

func GetTableRows(code, scope, table, lowerBound, upperBound string, limit uint32, v interface{}) error

GetTableRows

func Post

func Post(url string, data interface{}, contentType string) string

Post 发送POST请求 url: 请求地址 data: POST请求提交的数据 contentType: 请求体格式,如:application/json content: 请求放回的内容

func Start

func Start(tracer opentracing.Tracer, spanName string, ctx context.Context) (newCtx context.Context, finish func(...SpanOption))

func Utf8ToGbk

func Utf8ToGbk(s []byte) ([]byte, error)

Types

type Crontab

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

Crontab crontab manager

func NewCrontab

func NewCrontab() *Crontab

NewCrontab new crontab

func (*Crontab) AddByFunc

func (c *Crontab) AddByFunc(id string, spec string, f func()) error

AddByFunc add function as crontab task

func (*Crontab) AddByID

func (c *Crontab) AddByID(id string, spec string, cmd cron.Job) error

AddByID add one crontab task id is unique spec is the crontab expression

func (*Crontab) DelByID

func (c *Crontab) DelByID(id string)

DelByID remove one crontab task

func (*Crontab) IDs

func (c *Crontab) IDs() []string

IDs ...

func (*Crontab) IsExists

func (c *Crontab) IsExists(jid string) bool

IsExists check the crontab task whether existed with job id

func (*Crontab) Start

func (c *Crontab) Start()

Start start the crontab engine

func (*Crontab) Stop

func (c *Crontab) Stop()

Stop stop the crontab engine

type EmailNotify

type EmailNotify struct {
	SmtpS   string
	SmtpP   int32
	Fromer  string
	Ccers   []string
	EUser   string
	Epasswd string
}

func NewEmailNotify

func NewEmailNotify(mailConf *conf.Email) *EmailNotify

func (*EmailNotify) SendNotifyWithFile

func (en *EmailNotify) SendNotifyWithFile(toers, title, content string) bool

func (*EmailNotify) SendNotifyWithFileAndAttach

func (en *EmailNotify) SendNotifyWithFileAndAttach(toers, title, content, filePath, newName string) bool

type SpanOption

type SpanOption func(span opentracing.Span)

func SpanWithError

func SpanWithError(err error) SpanOption

func SpanWithLog

func SpanWithLog(arg ...interface{}) SpanOption

example: SpanWithLog(

"event", "soft error",
"type", "cache timeout",
"waited.millis", 1500)

type SwapDefiPair

type SwapDefiPair struct {
	ID int `json:"id" gorm:"column:id"`

	Token0 struct {
		Symbol   string `json:"symbol" gorm:"column:symbol"`
		Contract string `json:"contract" gorm:"column:contract"`
	} `json:"token0" gorm:"column:token0"`
	Token1 struct {
		Symbol   string `json:"symbol" gorm:"column:symbol"`
		Contract string `json:"contract" gorm:"column:contract"`
	} `json:"token1" gorm:"column:token1"`
	BlockTimeLast        string  `json:"block_time_last" gorm:"column:block_time_last"`
	LiquidityToken       int     `json:"liquidity_token,string" gorm:"column:liquidity_token"`
	Reserve1             string  `json:"reserve1" gorm:"column:reserve1"`
	Reserve0             string  `json:"reserve0" gorm:"column:reserve0"`
	Price0Last           float64 `json:"price0_last,string" gorm:"column:price0_last"`
	Price1Last           float64 `json:"price1_last,string" gorm:"column:price1_last"`
	Price0CumulativeLast int     `json:"price0_cumulative_last" gorm:"column:price0_cumulative_last"`
	Price1CumulativeLast int     `json:"price1_cumulative_last" gorm:"column:price1_cumulative_last"`
}

func GetSwapDefiPair

func GetSwapDefiPair(pairId string) (error, *SwapDefiPair)

Jump to

Keyboard shortcuts

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