common

package
v0.0.0-...-3f61646 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success        = "success"
	Failed         = "failed"
	CommaSeparator = ","
	DefaultLimit   = 10
)
View Source
const (
	LanguageEn = "en"
	LanguageZh = "zh"
)
View Source
const (
	AppIOSDeviceType        = "ios"
	AppAndroidDeviceType    = "android"
	AppWebDeviceType        = "web"
	AppWebIosDeviceType     = "web_ios"
	AppWebAndroidDeviceType = "web_android"

	ClientPc     = "pc"
	ClientMobile = "mobile"
	ClientPad    = "pad"
	ClientMweb   = "mweb"
	ClientMinapp = "minapp"

	InternalClientJuicy     = "juicy"
	InternalClientXuangubao = "XGB"
	InternalClientSwagger   = "swagger"
	InternalClientTubiaojia = "TBJ"
	InternalClientCong      = "cong"
	InternalClientAthena    = "athena"
)
View Source
const (
	EmailRegex = `\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*`
	//MobileRegex = `^\+1([38][0-9]|14[57]|5[^4])\d{8}$`
	MobileRegex = `^\+[1-9]{1}[0-9]{3,14}$`
)
View Source
const (
	Md_USERID          = "x-userid"
	Md_CLIENTIP        = "x-clientip"
	Md_DEVICETYPE      = "x-devicetype"
	Md_OWNER           = "x-owner"
	Md_ADMIN_USER_ROLE = "x-admin-user-role"
	Md_HYSTRIX_STATUS  = "x-hystrix-status"
	Md_PLATFORM        = "x-platform"
	Md_HYSTRIX_CLOSED  = "closed"
	Md_HYSTRIX_OPEN    = "open"
	Md_APPHEADER       = "x-app-header"
	Md_Token           = "x-token"
	Md_DEVICEID        = "x-deviceid"

	RequestHeaderAppOffset_DEVICETYPE = 1
)
View Source
const (
	TokenKey = "token_1234567890"
)

Variables

View Source
var (
	ContentOrderMap = map[string]string{
		"display_time_desc": "article_display_time desc",
		"display_time_asc":  "article_display_time asc",
		"updated_at_asc":    "updated_at asc",
		"updated_at_desc":   "updated_at desc",
	}
)
View Source
var TimeEnd2032 = time.Unix(1956499200, 0)

Functions

func InitConfig

func InitConfig()

func NsqChannelName

func NsqChannelName(id string, nameParam string) string

func NsqDefaultChannelName

func NsqDefaultChannelName(id string) string

func NsqEphChannelName

func NsqEphChannelName(id string, nameParam string) string

func NsqTopicName

func NsqTopicName(id string) string

func PbMetaGet

func PbMetaGet(k string, ctx context.Context) string

Types

type Config

type Config struct {
	Environment    ConfigEnv         `json:"environment" yaml:"environment"`
	Micro          std.ConfigService `json:"micro" yaml:"micro"`
	Log            std.ConfigLog     `json:"logger" yaml:"logger"`
	Redis          std.ConfigRedis   `json:"redis" yaml:"redis"`
	EventCollector ec.Config         `json:"event_collector" yaml:"event_collector"`
}
var (
	GlobalConf  *Config
	RedisClient *redis.Client
)

type ConfigEnv

type ConfigEnv struct {
	Env     string `json:"env" yaml:"env"`
	Bind    string `json:"bind" yaml:"bind"`
	CertPem string `json:"cert_pem" yaml:"cert_pem"`
	KeyPem  string `json:"key_pem" yaml:"key_pem"`
}

type Token

type Token struct {
	AppType    string
	UID        int64
	Expiration int64
	DeviceType string
	ClientType string
}

func NewToken

func NewToken(appType string, uid int64, outTime int64, deviceType string) *Token

func NewTokenFromString

func NewTokenFromString(content string) (*Token, error)

func NewTokenWithClient

func NewTokenWithClient(appType string, uid int64, outTime int64, deviceType string, clientType string) *Token

func (*Token) GenTokenString

func (o *Token) GenTokenString() string

Jump to

Keyboard shortcuts

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