utils

package
v0.0.0-...-d22cea1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACCESS_FROM_USER = 0
	COLON            = ":"
)
View Source
const (
	MessageTypeImage = iota
	MessageTypeEmoji
)
View Source
const (
	CH_BotNotify          string = "botNotify"
	CH_ContactInfo        string = "contactInfo"
	CH_GetContact         string = "getContact"
	CONSU_WEB_BotNotify   string = "webBotNotify"
	CONSU_WEB_ContactInfo string = "webContactInfo"
	CONSU_WEB_GetContact  string = "webGetContact"
)
View Source
const (
	MT_ALIYUN string = "aliyun"
	MT_LOCAL  string = "local"
)
View Source
const (
	//MongoDatabase  string = "mo-chathub"
	WechatMessages string = ""
)

Variables

This section is empty.

Functions

func AliyunGetPassword

func AliyunGetPassword(sk string) string

func AliyunGetUserName

func AliyunGetUserName(ak string, resourceOwnerId uint64) string

func AliyunGetUserNameBySTSToken

func AliyunGetUserNameBySTSToken(ak string, resourceOwnerId uint64, stsToken string) string

func CheckSum

func CheckSum(src []byte) []byte

func DecodeMap

func DecodeMap(src interface{}, target interface{}) error

func GenSignedURLPair

func GenSignedURLPair(ossBucket *oss.Bucket, messageType MessageType, imageId string, thumbImageId string) (string, string, error)

生成 image 和 thumbnailImage url,如果 thumbnailId 不存在,那么用 imageId + image process 方式生成 thumb

func HexString

func HexString(src []byte) string

func HmacSha1

func HmacSha1(keyStr string, message string) string

func MapKeys

func MapKeys(syncMap *sync.Map) []interface{}

func MapLen

func MapLen(syncMap *sync.Map) int

func NewAuthError

func NewAuthError(err error) error

func NewClientError

func NewClientError(code ClientErrorCode, err error) error

func NewRedisPool

func NewRedisPool(server string, db string, password string) *redis.Pool

func PasswordCheckSum

func PasswordCheckSum(pass string) string

func StringNull

func StringNull(str string, defaultValue string) sql.NullString

Types

type AuthChildUser

type AuthChildUser struct {
	AuthUrl  string `json:"AuthUrl"`
	Metadata string `json:"metadata"`
	Cookie   string `json:"cookie"`
}

type AuthError

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

type AuthUser

type AuthUser struct {
	AccountName string         `json:"accountname"`
	Password    string         `json:"password"`
	SdkCode     string         `json:"sdkcode"`
	Secret      string         `json:"secret"`
	ExpireAt    JSONTime       `json:"expireat"`
	Child       *AuthChildUser `json:"child,omitempty"`
}

type ClientError

type ClientError struct {
	Code ClientErrorCode
	// contains filtered or unexported fields
}

func (*ClientError) ErrorCode

func (err *ClientError) ErrorCode() ClientErrorCode

type ClientErrorCode

type ClientErrorCode int
const (
	OK                     ClientErrorCode = 0
	UNKNOWN                ClientErrorCode = 1
	IGNORED                ClientErrorCode = 2
	PARAM_REQUIRED         ClientErrorCode = 1001
	PARAM_INVALID          ClientErrorCode = 1002
	RESOURCE_INSUFFICIENT  ClientErrorCode = 2001
	RESOURCE_ACCESS_DENIED ClientErrorCode = 2002
	RESOURCE_NOT_FOUND     ClientErrorCode = 2003
	RESOURCE_QUOTA_LIMIT   ClientErrorCode = 2004
	STATUS_INCONSISTENT    ClientErrorCode = 3001
	METHOD_UNSUPPORTED     ClientErrorCode = 3002
)

type CommonResponse

type CommonResponse struct {
	Code    int          `json:"code"`
	Message string       `json:"message,omitempty"`
	Ts      int64        `json:"ts"`
	Error   ErrorMessage `json:"error,omitempty""`
	Body    interface{}  `json:"body,omitempty""`
	Paging  Paging       `json:"paging,omitempty"`
}

type DatabaseConfig

type DatabaseConfig struct {
	DriverName     string
	DataSourceName string
	MaxConnectNum  int
}

type ErrorHandler

type ErrorHandler struct {
	Err error
}

func (*ErrorHandler) BJTimeFromUnix

func (ctx *ErrorHandler) BJTimeFromUnix(timestamp int64) time.Time

func (*ErrorHandler) FromJson

func (ctx *ErrorHandler) FromJson(jsonstr string) map[string]interface{}

func (*ErrorHandler) FromMap

func (ctx *ErrorHandler) FromMap(key string, m map[string]interface{}, objname string, defValue interface{}) interface{}

func (*ErrorHandler) FromMapFloat

func (ctx *ErrorHandler) FromMapFloat(key string, m map[string]interface{}, objname string, haveDefault bool, defValue float64) float64

func (*ErrorHandler) FromMapInt

func (ctx *ErrorHandler) FromMapInt(key string, m map[string]interface{}, objname string, haveDefault bool, defValue int64) int64

func (*ErrorHandler) FromMapString

func (ctx *ErrorHandler) FromMapString(key string, m map[string]interface{}, objname string, haveDefault bool, defValue string) string

func (*ErrorHandler) FromXML

func (ctx *ErrorHandler) FromXML(xmlstr string, target interface{})

func (*ErrorHandler) GetResponseBody

func (ctx *ErrorHandler) GetResponseBody(resp *httpx.RestfulResponse) map[string]interface{}

func (*ErrorHandler) ListValue

func (o *ErrorHandler) ListValue(value interface{}, hasDefault bool, defValue []interface{}) []interface{}

func (*ErrorHandler) NewMongoConn

func (o *ErrorHandler) NewMongoConn(host string, port string, database string) *mgo.Database

func (*ErrorHandler) NewRabbitMQWrapper

func (o *ErrorHandler) NewRabbitMQWrapper(config RabbitMQConfig) *RabbitMQWrapper

func (*ErrorHandler) ParseInt

func (ctx *ErrorHandler) ParseInt(s string, base int, bitsize int) int64

func (*ErrorHandler) ParseUint

func (ctx *ErrorHandler) ParseUint(s string, base int, bitsize int) uint64

func (*ErrorHandler) RabbitMQChannel

func (o *ErrorHandler) RabbitMQChannel(conn *amqp.Connection) *amqp.Channel

func (*ErrorHandler) RabbitMQConnect

func (o *ErrorHandler) RabbitMQConnect(config RabbitMQConfig) *amqp.Connection

func (*ErrorHandler) Recover

func (o *ErrorHandler) Recover(name string)

func (*ErrorHandler) RestfulCall

func (ctx *ErrorHandler) RestfulCall(req *httpx.RestfulRequest) *httpx.RestfulResponse

func (*ErrorHandler) ToJson

func (ctx *ErrorHandler) ToJson(v interface{}) string

func (*ErrorHandler) ValidateJWTToken

func (o *ErrorHandler) ValidateJWTToken(secret string, bearerToken string) *AuthUser

type ErrorMessage

type ErrorMessage struct {
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
}

type FluentConfig

type FluentConfig struct {
	Host string
	Port int
	Tags map[string]string
}

type JSONTime

type JSONTime struct {
	time.Time
}

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(buf []byte) error

type MessageType

type MessageType int

type MongoConfig

type MongoConfig struct {
	Host     string
	Port     string
	Database string
}

type OssConfig

type OssConfig struct {
	Region          string
	Accesskeyid     string
	Accesskeysecret string
	Bucket          string
}

type Paging

type Paging struct {
	Page      int64 `json:"page,omitempty"`
	PageCount int64 `json:"pagecount,omitempty"`
	PageSize  int64 `json:"pagesize,omitempty"`
}

type RabbitMQConfig

type RabbitMQConfig struct {
	User     string
	Password string
	Host     string
	Port     string
	Vhost    string

	Maintainer      string
	Accesskeyid     string
	Accesskeysecret string
	Resourceownerid uint64
}

type RabbitMQWrapper

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

func (*RabbitMQWrapper) Consume

func (w *RabbitMQWrapper) Consume(queue string, consumer string, autoack bool, exclusive bool, nolocal bool, nowait bool) (<-chan amqp.Delivery, error)

func (*RabbitMQWrapper) DeclareQueue

func (w *RabbitMQWrapper) DeclareQueue(queue string, durable bool, autodelete bool, exclusive bool, nowait bool) error

func (*RabbitMQWrapper) Reconnect

func (w *RabbitMQWrapper) Reconnect() error

func (*RabbitMQWrapper) Send

func (w *RabbitMQWrapper) Send(queue string, body string) error

type RedisConfig

type RedisConfig struct {
	Host     string
	Port     string
	Password string
	Db       string
}

Jump to

Keyboard shortcuts

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