server

package
v1.3.22 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: Zlib Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const (
	AT_DEF     = AuthType(0)
	AT_NAME    = AuthType(1)  //用户名
	AT_PHONE   = AuthType(2)  //手机
	AT_EMAIL   = AuthType(3)  //邮箱
	AT_WEIXIN  = AuthType(4)  //微信(第三方)
	AT_WEIBIO  = AuthType(5)  //微博(第三方)
	AT_QQ      = AuthType(6)  //QQ (第三方)
	AT_WXMINI  = AuthType(7)  //微信小程序(第三方)
	AT_WXSER   = AuthType(8)  //微信服务号(第三方)
	AT_TODAY   = AuthType(9)  //今日头条(第三方)
	AT_BAIDU   = AuthType(10) //百度(第三方)
	AT_TOKEN   = AuthType(99) //业务TOKEN验证
	AT_VISITOR = AuthType(100)
	AT_INNER   = AuthType(101)
	AT_END     = AuthType(102)
)
View Source
const (
	AS_DEF        = AuthStatus(0) //0=未激活 1=正在.. 2=已激活 3=删除
	AS_ACTIVATING = AuthStatus(1)
	AS_ACTIVATED  = AuthStatus(2)
	AS_DELETED    = AuthStatus(3)
)
View Source
const (
	AM_DEF  = AuthMethod(0)
	AM_PASS = AuthMethod(1) //密码
	AM_SMS  = AuthMethod(2) //短信
	AM_END  = AuthMethod(3)
)
View Source
const (
	VT_DEF        = ValidatingType(0)
	VT_REG_SMS    = ValidatingType(1) //注册短信
	VT_LOG_SMS    = ValidatingType(2) //登录短信
	VT_REG_INVITE = ValidatingType(3) //注册邀请
	VT_ACT_EMAIL  = ValidatingType(4)
	VT_END        = ValidatingType(255)
)
View Source
const (
	//PC MAC IPHONE IPAD APHONE APAD TV
	PT_PC     = "pc"
	PT_MAC    = "mac"
	PT_IPHONE = "iphone"
	PT_IPAD   = "ipad"
	PT_APHONE = "aphone"
	PT_APAD   = "apad"
	PT_TV     = "tv"
)
View Source
const (
	GHealthTtl    = 10
	KGRpcProtocol = "grpc"
	KHttpProtocol = "http"
	KTCPProtocol  = "tcp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address added in v0.1.2

type Address struct {
	Scheme  string `json:"scheme" yaml:"scheme" xml:"scheme"`
	Host    string `json:"host" yaml:"host" xml:"host"`
	Port    int    `json:"port" yaml:"port" xml:"port"`
	Path    string `json:"path,omitempty" yaml:"path,omitempty" xml:"path,omitempty"`
	Name    string `json:"name,omitempty" yaml:"name,omitempty" xml:"name,omitempty"`
	Weight  int    `json:"weight,omitempty" yaml:"weight,omitempty" xml:"weight,omitempty"`
	Timeout int    `json:"timeout,omitempty" yaml:"timeout,omitempty" xml:"timeout,omitempty"`
}

func Parse

func Parse(addr string) (Address, error)

func ParseV2 added in v1.2.0

func ParseV2(addr net.Addr, pubIp string) Address

func ParseWithSeparate added in v0.1.2

func ParseWithSeparate(info string) Address

ParseWithSeparate info = name|scheme://host:post|timeout|weight

func (Address) Adjust added in v0.5.44

func (s Address) Adjust() Address

Adjust 如果IP是自己,调整为 127.0.0.1

func (Address) Clone added in v1.2.0

func (s Address) Clone() Address

func (Address) HasDomain added in v0.1.2

func (s Address) HasDomain() bool

HasDomain 简单的域名 .com,.cn

func (Address) HasIP added in v0.1.2

func (s Address) HasIP() bool

func (Address) HasPort added in v0.1.2

func (s Address) HasPort() bool

func (Address) HasScheme added in v1.2.0

func (s Address) HasScheme() bool

func (Address) IsEqual added in v1.2.0

func (s Address) IsEqual(addr Address) bool

func (Address) IsHttp added in v0.1.2

func (s Address) IsHttp() bool

func (Address) IsScheme added in v0.1.2

func (s Address) IsScheme(scheme string) bool

func (Address) IsSelf added in v1.2.0

func (s Address) IsSelf(addr string) bool

IsSelf 服务就是自己

func (Address) IsWs added in v0.5.44

func (s Address) IsWs() bool

func (Address) SetHost added in v0.1.2

func (s Address) SetHost(host string)

func (Address) To added in v0.1.2

func (s Address) To() string

To scheme://host:port

type Addresses added in v1.1.9

type Addresses []Address

func (*Addresses) Add added in v1.1.9

func (ay *Addresses) Add(addr string)

Add @param s = host:port

func (Addresses) Array added in v1.1.9

func (ay Addresses) Array() []string

func (Addresses) Len added in v1.1.9

func (ay Addresses) Len() int

func (Addresses) Less added in v1.1.9

func (ay Addresses) Less(i, j int) bool

Less 权重越大,在前面

func (Addresses) Swap added in v1.1.9

func (ay Addresses) Swap(i, j int)

func (Addresses) ToWeight added in v1.1.9

func (ay Addresses) ToWeight()

type AuthMethod

type AuthMethod int8

认证方法

func (AuthMethod) Int

func (a AuthMethod) Int() int8

type AuthStatus

type AuthStatus int8

认证状态

func (AuthStatus) Int

func (a AuthStatus) Int() int8

type AuthType

type AuthType int8

认证 1=用户名, 2=手机 3=邮箱 4=微信 5=微博 6=QQ 7=小程序

func (AuthType) Int

func (a AuthType) Int() int8

type Cluster

type Cluster struct {
	Nodes        []Address     `json:"nodes" yaml:"nodes" xml:"nodes"`
	Password     string        `json:"password" yaml:"password" xml:"password"`
	PoolSize     int           `json:"pool_size" yaml:"pool_size" xml:"pool_size"`
	ReadOnly     bool          `json:"read_only" yaml:"read_only" xml:"read_only"`
	DialTimeout  time.Duration `json:"dial_timeout" yaml:"dial_timeout" xml:"dial_timeout"`
	ReadTimeout  time.Duration `json:"read_timeout" yaml:"read_timeout" xml:"read_timeout"`
	WriteTimeout time.Duration `json:"write_timeout" yaml:"write_timeout" xml:"write_timeout"`
}

Cluster 集群配置

type Database

type Database struct {
	Host       string `json:"host" yaml:"host" xml:"host"`
	Port       int    `json:"port" yaml:"port" xml:"port"`
	User       string `json:"user" yaml:"user" xml:"user"`
	Pwd        string `json:"pwd" yaml:"pwd" xml:"pwd"`
	DriverType string `json:"type" yaml:"type" xml:"type"` //mysql, sqlite
	Name       string `json:"name" yaml:"name" xml:"name"` //数据库名
}

func (Database) GetDataSourceName

func (d Database) GetDataSourceName() string

type Domain added in v0.1.2

type Domain struct {
	Domain string `json:"-"`
	Raw    string `json:"domain" yaml:"domain" xml:"domain"`
}

func (Domain) DomainTo added in v0.1.2

func (c Domain) DomainTo() string

type Elastic

type Elastic struct {
	Name              string        `json:"name" yaml:"name" xml:"name"`    //数据名(不是数据库名)
	Host              []string      `json:"hosts" yaml:"hosts" xml:"hosts"` //机群
	User              string        `json:"user" yaml:"user" xml:"user"`
	Pwd               string        `json:"pwd" yaml:"pwd" xml:"pwd"`
	Sniff             bool          `json:"sniff" yaml:"sniff" xml:"sniff"`
	Interval          time.Duration `json:"interval" yaml:"interval" xml:"interval"`
	XPackSecurityUser string        `json:"XPackSecurityUser" yaml:"XPackSecurityUser" xml:"XPackSecurityUser"`
	Logger            EsLogger      `json:"logger" yaml:"logger" xml:"logger"`
}

type EsLogger added in v1.2.7

type EsLogger struct {
	LogLevel int `json:"level" yaml:"level" xml:"level"`
}

type Health added in v1.0.4

type Health struct {
	URL           Address       `json:"url"`
	Method        string        `json:"method"`
	Protocol      string        `json:"protocol"`
	Ttl           bool          `json:"ttl"`
	Interval      time.Duration `json:"interval"` //(second)
	SuccessStatus int           `json:"successStatus"`
}

func ReadHealth added in v1.0.4

func ReadHealth(filename string) (Health, error)

type MqClient

type MqClient struct {
	GroupID      string `json:"groupId" yaml:"groupId" xml:"groupId"`
	Server       string `json:"server" yaml:"server" xml:"server"`
	Domain       string `json:"domain" yaml:"domain" xml:"domain"`
	GroupName    string `json:"groupName" yaml:"groupName" xml:"groupName"`
	InstanceName string `json:"instance" yaml:"instance" xml:"instance"`
}

type MqConfig

type MqConfig struct {
	Client       MqClient         `json:"client" yaml:"client" xml:"client"`
	Credentials  MqCredentials    `json:"credentials" yaml:"credentials" xml:"credentials"`
	LogLevel     int              `json:"logLevel" yaml:"logLevel" xml:"logLevel"`
	ProducerConf MqProducerConfig `json:"producer" yaml:"producer" xml:"producer"`
	ConsumerConf MqConsumerConfig `json:"consumer" yaml:"consumer" xml:"consumer"`
}

type MqConsumerConfig

type MqConsumerConfig struct {
	ThreadCount int `json:"threadCount" yaml:"threadCount" xml:"threadCount"`
	Model       int `json:"model" yaml:"model" xml:"model"`
	Size        int `json:"size" yaml:"size" xml:"size"`
}

type MqCredentials

type MqCredentials struct {
	AccessKey   string `json:"accessKey" yaml:"accessKey" xml:"accessKey"`
	SecretKey   string `json:"secretKey" yaml:"secretKey" xml:"secretKey"`
	SecretToken string `json:"secretToken" yaml:"secretToken" xml:"secretToken"`
}

type MqProducerConfig

type MqProducerConfig struct {
	Timeout  int `json:"timeout" yaml:"timeout" xml:"timeout"`
	Compress int `json:"compress" yaml:"compress" xml:"compress"`
	Size     int `json:"size" yaml:"size" xml:"size"`
	Retry    int `json:"retry" yaml:"retry" xml:"retry"`
}

type Redis

type Redis struct {
	Name     string      `json:"name" yaml:"name" xml:"name"` //redis名
	Master   RedisConfig `json:"master" yaml:"master" xml:"master"`
	Cluster  RedisConfig `json:"cluster" yaml:"cluster" xml:"cluster"`
	Sentinel RedisConfig `json:"sentinel" yaml:"sentinel" xml:"sentinel"`
	Logger   RedisLogger `json:"logger" yaml:"logger" xml:"logger"`
}

type RedisConfig added in v1.1.23

type RedisConfig struct {
	Host               []string      `json:"host" yaml:"host" xml:"host"` //ip:port
	User               string        `json:"user" yaml:"user" xml:"user"`
	Pwd                string        `json:"pwd" yaml:"pwd" xml:"pwd"`
	DB                 int           `json:"db" yaml:"db" xml:"db"`
	PoolSize           int           `json:"poolSize" yaml:"poolSize" xml:"poolSize"`
	MinIdleConns       int           `json:"minIdleConns" yaml:"minIdleConns" xml:"minIdleConns"`
	MaxRetries         int           `json:"maxRetries" yaml:"maxRetries" xml:"maxRetries"`
	DialTimeout        time.Duration `json:"dialTimeout" yaml:"dialTimeout" xml:"dialTimeout"`
	ReadTimeout        time.Duration `json:"readTimeout" yaml:"readTimeout" xml:"readTimeout"`
	WriteTimeout       time.Duration `json:"writeTimeout" yaml:"writeTimeout" xml:"writeTimeout"`
	IdleTimeout        time.Duration `json:"idleTimeout" yaml:"idleTimeout" xml:"idleTimeout"`
	MinRetryBackoff    time.Duration `json:"MinRetryBackoff" yaml:"MinRetryBackoff" xml:"MinRetryBackoff"`
	MaxRetryBackoff    time.Duration `json:"MaxRetryBackoff" yaml:"MaxRetryBackoff" xml:"MaxRetryBackoff"`
	MaxConnAge         time.Duration `json:"MaxConnAge" yaml:"MaxConnAge" xml:"MaxConnAge"`
	PoolTimeout        time.Duration `json:"PoolTimeout" yaml:"PoolTimeout" xml:"PoolTimeout"`
	IdleCheckFrequency time.Duration `json:"IdleCheckFrequency" yaml:"IdleCheckFrequency" xml:"IdleCheckFrequency"`
}

type RedisLogger added in v1.1.23

type RedisLogger struct {
	LogLevel int `json:"level" yaml:"level" xml:"level"`
}

type Server

type Server interface {
	Init() error
	Start() error
	Stop()
}

type Sql

type Sql struct {
	Name         string        `json:"name" yaml:"name" xml:"name"` //数据名(不是数据库名)
	Master       Database      `json:"master" yaml:"master" xml:"master"`
	Sources      []Database    `json:"sources" yaml:"sources" xml:"sources"`
	Replicas     []Database    `json:"replicas" yaml:"replicas" xml:"replicas"`
	MaxOpenConns int           `json:"max_open_conns" yaml:"max_open_conns" xml:"max_open_conns"`
	MaxIdleConns int           `json:"max_idle_conns" yaml:"max_idle_conns" xml:"max_idle_conns"`
	MaxIdleTime  time.Duration `json:"max_idle_time" yaml:"max_idle_time" xml:"max_idle_time"`
	Logger       SqlLogger     `json:"logger" yaml:"logger" xml:"logger"`
}

type SqlLogger added in v1.1.23

type SqlLogger struct {
	LogLevel                  int           `json:"level" yaml:"level" xml:"level"`
	SlowThreshold             time.Duration `json:"slowThreshold" yaml:"slowThreshold" xml:"slowThreshold"`
	IgnoreRecordNotFoundError bool          `json:"ignoreRecordNotFoundError" yaml:"ignoreRecordNotFoundError" xml:"ignoreRecordNotFoundError"`
	AlarmEnabled              bool          `json:"alarmEnabled" yaml:"alarmEnabled" xml:"alarmEnabled"`
}

type ValidatingType

type ValidatingType int

验证类型

func (ValidatingType) Int

func (a ValidatingType) Int() int

Jump to

Keyboard shortcuts

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