conf

package
v0.13.6-0...-d3ad96a Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSetting = errors.New("未配置")

ErrNoSetting 未配置

Functions

This section is empty.

Types

type APIServerConf

type APIServerConf struct {
	Address   string `json:"address,omitempty" valid:"dialstring"`
	Status    string `json:"status,omitempty" valid:"in(start|stop)"`
	RTimeout  int    `json:"readTimeout,omitempty"`
	WTimeout  int    `json:"writeTimeout,omitempty"`
	RHTimeout int    `json:"readHeaderTimeout,omitempty"`
	Host      string `json:"host,omitempty"`
	Domain    string `json:"dn,omitempty"`
	Trace     bool   `json:"trace,omitempty"`
}

APIServerConf api server配置信息

func NewAPIServerConf

func NewAPIServerConf(address string) *APIServerConf

NewAPIServerConf 构建api server配置信息

func (*APIServerConf) WithDNS

func (a *APIServerConf) WithDNS(host string, ip ...string) *APIServerConf

WithDNS 设置请求域名

func (*APIServerConf) WithDisable

func (a *APIServerConf) WithDisable() *APIServerConf

WithDisable 禁用任务

func (*APIServerConf) WithEnable

func (a *APIServerConf) WithEnable() *APIServerConf

WithEnable 启用任务

func (*APIServerConf) WithHeaderReadTimeout

func (a *APIServerConf) WithHeaderReadTimeout(htimeout int) *APIServerConf

WithHeaderReadTimeout 构建api server配置信息

func (*APIServerConf) WithHost

func (a *APIServerConf) WithHost(host ...string) *APIServerConf

WithHost 设置host

func (*APIServerConf) WithTimeout

func (a *APIServerConf) WithTimeout(rtimeout int, wtimout int) *APIServerConf

WithTimeout 构建api server配置信息

func (*APIServerConf) WithTrace

func (a *APIServerConf) WithTrace() *APIServerConf

WithTrace 构建api server配置信息

type Authes

type Authes struct {
	JWT                  *JWTAuth         `json:"jwt,omitempty"`
	FixedScret           *FixedSecretAuth `json:"fixed-secret,omitempty"`
	RemotingServiceAuths ServiceAuths     `json:"remotings,omitempty"`
}

Authes 安全认证组

func NewAuthes

func NewAuthes() *Authes

NewAuthes 构建安全认证

func (*Authes) WithFixedSecretSign

func (a *Authes) WithFixedSecretSign(auth *FixedSecretAuth) *Authes

WithFixedSecretSign 添加固定签名认证

func (*Authes) WithJWT

func (a *Authes) WithJWT(jwt *JWTAuth) *Authes

WithJWT 添加jwt验证

func (*Authes) WithServiceAuth

func (a *Authes) WithServiceAuth(auth ...*ServiceAuth) *Authes

WithServiceAuth 添加远程服务验证

type Breaker

type Breaker struct {
	URL              string `json:"url" valid:"ascii,required"`
	RequestPerSecond int    `json:"request-per-second,omitempty"`
	FailedPercent    int    `json:"failed-request,omitempty"`
	RejectPerSecond  int    `json:"reject-per-second,omitempty"`
	Disable          bool   `json:"disable,omitempty"`
}

Breaker URL熔断配置项

type CNode

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

CNode 集群节点

func NewCNode

func NewCNode(root string, name string, mid string, index int) *CNode

NewCNode 构建集群节点信息

func (*CNode) GetClusterID

func (c *CNode) GetClusterID() string

GetClusterID 获取节点编号

func (*CNode) GetFullPath

func (c *CNode) GetFullPath() string

GetFullPath 获取完整路径信息

func (*CNode) GetHost

func (c *CNode) GetHost() string

GetHost 获取服务器信息

func (*CNode) GetIndex

func (c *CNode) GetIndex() int

GetIndex 获取当前节点的索引编号

func (*CNode) GetName

func (c *CNode) GetName() string

GetName 获取当前服务名称

func (*CNode) IsCurrent

func (c *CNode) IsCurrent() bool

IsCurrent 是否是当前服务

type CNodes

type CNodes []*CNode

CNodes 所有集群节点

func (CNodes) GetCurrent

func (c CNodes) GetCurrent() *CNode

GetCurrent 获取当前节点

type CacheConf

type CacheConf map[string]interface{}

CacheConf 消息队列配置

func (CacheConf) GetProto

func (q CacheConf) GetProto() string

GetProto 获取协议

type CircuitBreaker

type CircuitBreaker struct {
	ForceBreak      bool       `json:"force-break,omitempty"`
	Disable         bool       `json:"disable,omitempty"`
	SwitchWindow    int        `json:"switch-window,omitempty"`
	CircuitBreakers []*Breaker `json:"circuit-breakers,omitempty"`
}

CircuitBreaker 熔断配置

func NewCircuitBreaker

func NewCircuitBreaker(window int) *CircuitBreaker

NewCircuitBreaker 构建熔断配置

func (*CircuitBreaker) Append

func (c *CircuitBreaker) Append(url string, requestPerSecond int, failedPercent int, rejectPreSecond int) *CircuitBreaker

Append 添加URL的熔断配置

func (*CircuitBreaker) AppendAll

func (c *CircuitBreaker) AppendAll(requestPerSecond int, failedPercent int, rejectPreSecond int) *CircuitBreaker

AppendAll 所有URL使用此熔断配置

func (*CircuitBreaker) WithDisable

func (c *CircuitBreaker) WithDisable() *CircuitBreaker

WithDisable 禁用熔断配置

func (*CircuitBreaker) WithEnable

func (c *CircuitBreaker) WithEnable() *CircuitBreaker

WithEnable 启用熔断配置

func (*CircuitBreaker) WithForceBreak

func (c *CircuitBreaker) WithForceBreak(b bool) *CircuitBreaker

WithForceBreak 强制熔断

type Comparer

type Comparer struct {
	Oconf IServerConf
	Nconf IServerConf
	*JSONComparer
}

func NewComparer

func NewComparer(Oconf IServerConf, Nconf IServerConf) *Comparer

func (*Comparer) IsRequiredSubConfChanged

func (s *Comparer) IsRequiredSubConfChanged(name string) (isChanged bool, err error)

IsRequiredSubConfChanged 检查必须节点是否发生变化

func (*Comparer) IsSubConfChanged

func (s *Comparer) IsSubConfChanged(name string) (isChanged bool)

IsSubConfChanged 检查节点是否发生变化

func (*Comparer) IsVarChanged

func (s *Comparer) IsVarChanged() bool

IsVarChanged var节点是否发生变化

type Connect

type Connect struct {
	KeyValue string         `json:"kv,omitempty" valid:"ascii"`
	Chain    string         `json:"chain,omitempty" valid:"ascii"`
	Sort     string         `json:"sort,omitempty" valid:"in(all|data|static)"`
	Fields   string         `json:"fields,omitempty" valid:"ascii"`
	Secret   *SecretConnect `json:"secret,omitempty"`
	// contains filtered or unexported fields
}

Connect 签名拼接串

func (*Connect) Auth

func (c *Connect) Auth() *ServiceAuth

Auth 返回Auth对象

func (*Connect) Set

func (c *Connect) Set(kv string, chain string) *Connect

Set 设置字段拼接方式

func (*Connect) SetSecretConnect

func (c *Connect) SetSecretConnect() *SecretConnect

SetSecretConnect 设置secrect拼接方式

func (*Connect) SortAll

func (c *Connect) SortAll() *Connect

SortAll 排序所有字段,包括数据,secrect

func (*Connect) SortByData

func (c *Connect) SortByData() *Connect

SortByData 只排序数据字段,不排序secrect

func (*Connect) SortStatic

func (c *Connect) SortStatic(fields ...string) *Connect

SortStatic 使用指定的字段进行排序

type CronServerConf

type CronServerConf struct {
	Status   string `json:"status,omitempty" valid:"in(start|stop)"`
	Sharding int    `json:"sharding,omitempty"`
	Trace    bool   `json:"trace,omitempty"`
	Timeout  int    `json:"timeout,omitempty"`
}

func NewCronServerConf

func NewCronServerConf() *CronServerConf

NewCronServerConf 构建mqc server配置,默认为对等模式

func (*CronServerConf) WitchMasterSlave

func (a *CronServerConf) WitchMasterSlave() *CronServerConf

WitchMasterSlave 设置为主备模式

func (*CronServerConf) WitchP2P

func (a *CronServerConf) WitchP2P() *CronServerConf

WitchP2P 设置为对等模式

func (*CronServerConf) WitchSharding

func (a *CronServerConf) WitchSharding(i int) *CronServerConf

WitchSharding 设置为分片模式

func (*CronServerConf) WithDisable

func (a *CronServerConf) WithDisable() *CronServerConf

WithDisable 禁用任务

func (*CronServerConf) WithEnable

func (a *CronServerConf) WithEnable() *CronServerConf

WithEnable 启用任务

func (*CronServerConf) WithTimeout

func (a *CronServerConf) WithTimeout(timeout int) *CronServerConf

WithTimeout 构建api server配置信息

func (*CronServerConf) WithTrace

func (a *CronServerConf) WithTrace() *CronServerConf

WithTrace 构建api server配置信息

type CrossDomainHeader

type CrossDomainHeader = Headers

CrossDomainHeader 跨域配置

func (CrossDomainHeader) WithAllowHeaders

func (c CrossDomainHeader) WithAllowHeaders(header ...string) CrossDomainHeader

WithAllowHeaders 设置允许的头信息

type DBConf

type DBConf struct {
	Provider   string `json:"provider" valid:"required"`
	ConnString string `json:"connString" valid:"required"`
	MaxOpen    int    `json:"maxOpen" valid:"required"`
	MaxIdle    int    `json:"maxIdle" valid:"required"`
	LifeTime   int    `json:"lifeTime" valid:"required"`
}

DBConf 数据库配置

func NewDBConf

func NewDBConf(provider string, connString string, maxOpen int, maxIdle int, lifeTime int) *DBConf

NewDBConf 构建数据库配置对象

func NewMysqlConf

func NewMysqlConf(uName string, pwd string, serverIP string, dbName string) *DBConf

NewMysqlConf 创建mysql数据库

func NewMysqlConfForProd

func NewMysqlConfForProd(name ...string) *DBConf

NewMysqlConfForProd 创建prod mysql数据库#connectStr

func NewOracleConf

func NewOracleConf(uName string, pwd string, tnsName string) *DBConf

NewOracleConf 创建oracle数据库

func NewOracleConfForProd

func NewOracleConfForProd(name ...string) *DBConf

NewOracleConfForProd 创建prod oracle数据库#connectStr

func (*DBConf) WithConnect

func (d *DBConf) WithConnect(maxOpen int, maxIdle int, lifeTime int) *DBConf

WithConnect 设置连接数与超时时间

type FixedSecretAuth

type FixedSecretAuth struct {
	Mode    string   `json:"mode" valid:"in(MD5|SHA1|SHA256),required"`
	Secret  string   `json:"secret" valid:"ascii,required"`
	Include []string `json:"include" valid:"required"`
	Disable bool     `json:"disable,omitempty"`
}

func NewFixedSecretAuth

func NewFixedSecretAuth(secret string, mode ...string) *FixedSecretAuth

NewFixedSecretAuth 创建固定Secret签名认证

func (*FixedSecretAuth) Contains

func (a *FixedSecretAuth) Contains(p string) bool

Contains 检查指定的路径是否允许签名

func (*FixedSecretAuth) WithDisable

func (a *FixedSecretAuth) WithDisable() *FixedSecretAuth

WithDisable 禁用配置

func (*FixedSecretAuth) WithEnable

func (a *FixedSecretAuth) WithEnable() *FixedSecretAuth

WithEnable 启用配置

func (*FixedSecretAuth) WithInclude

func (a *FixedSecretAuth) WithInclude(path ...string) *FixedSecretAuth

WithInclude 设置include的请求服务路径

type Headers

type Headers map[string]string

Headers http头信息

func NewHeader

func NewHeader(kv ...string) Headers

NewHeader 构建http头信息

func (Headers) WithCrossDomain

func (imp Headers) WithCrossDomain(host ...string) CrossDomainHeader

WithCrossDomain 添加跨域头配置

type Hosts

type Hosts []string

type IConf

type IConf interface {
	GetVersion() int32
	GetString(key string, def ...string) (r string)
	GetStrings(key string, def ...string) (r []string)
	GetInt(key string, def ...int) int
	GetArray(key string, def ...interface{}) (r []interface{})
	GetBool(key string, def ...bool) (r bool)
	GetJSON(section string) (r []byte, version int32, err error)
	GetSection(section string) (c *JSONConf, err error)
	HasSection(section string) bool
	GetRaw() []byte
	Unmarshal(v interface{}) error
	GetSignature() string
}

type IMainConf

type IMainConf interface {
	IConf
	GetSystemRootfPath(server ...string) string
	GetMainConfPath() string
	GetServicePubRootPath(name string) string
	GetServerPubRootPath(serverType ...string) string
	GetDNSPubRootPath(svName string) string
	GetClusterNodes(serverType ...string) CNodes
	IsStop() bool
	ForceRestart() bool
	GetSubObject(name string, v interface{}) (int32, error)
	GetSubConf(name string) (*JSONConf, error)
	HasSubConf(name ...string) bool
	GetSubConfClone() map[string]JSONConf
	SetSubConf(data map[string]JSONConf)
	IterSubConf(f func(k string, conf *JSONConf) bool)
	GetClusterID() string
}

type IRegistryConf

type IRegistryConf interface {
	GetConf(name string) (*JSONConf, error)
	GetObject(name string, v interface{}) (int32, error)
}

type IServerConf

type IServerConf interface {
	ISystemConf
	IMainConf
	IVarConf
}

IServerConf 服务器配置

type ISystemConf

type ISystemConf interface {
	GetPlatName() string
	GetSysName() string
	GetServerType() string
	GetClusterName() string
	GetServerName() string
	GetAppConf(v interface{}) error
	Get(key string) interface{}
	Set(key string, value interface{})
}

type IVarConf

type IVarConf interface {
	GetVarVersion() int32
	GetVarConf(tp string, name string) (*JSONConf, error)
	GetVarObject(tp string, name string, v interface{}) (int32, error)
	HasVarConf(tp string, name string) bool
	GetVarConfClone() map[string]JSONConf
	SetVarConf(map[string]JSONConf)
	IterVarConf(f func(k string, conf *JSONConf) bool)
}

type JSONComparer

type JSONComparer struct {
	Oconf IConf
	Nconf IConf
}

func NewJSONComparer

func NewJSONComparer(Oconf IConf, Nconf IConf) *JSONComparer

func (*JSONComparer) IsChanged

func (s *JSONComparer) IsChanged() bool

func (*JSONComparer) IsValueChanged

func (s *JSONComparer) IsValueChanged(names ...string) (isChanged bool)

IsValueChanged 检查值是否发生变化

type JSONConf

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

JSONConf json配置文件

func NewJSONConf

func NewJSONConf(message []byte, version int32) (c *JSONConf, err error)

NewJSONConf 初始化JsonConf

func NewJSONConfByMap

func NewJSONConfByMap(data map[string]interface{}, version int32) (c *JSONConf, err error)

NewJSONConfByMap 根据map初始化对象

func (*JSONConf) GetArray

func (j *JSONConf) GetArray(key string, def ...interface{}) (r []interface{})

GetArray 获取数组对象

func (*JSONConf) GetBool

func (j *JSONConf) GetBool(key string, def ...bool) (r bool)

GetBool 获取bool类型值

func (*JSONConf) GetInt

func (j *JSONConf) GetInt(key string, def ...int) int

GetInt 获取数字

func (*JSONConf) GetJSON

func (j *JSONConf) GetJSON(section string) (r []byte, version int32, err error)

GetJSON 获取section原始JSON串

func (*JSONConf) GetRaw

func (j *JSONConf) GetRaw() []byte

GetRaw 获取json数据

func (*JSONConf) GetSection

func (j *JSONConf) GetSection(section string) (c *JSONConf, err error)

GetSection 指定节点名称获取JSONConf

func (*JSONConf) GetSignature

func (j *JSONConf) GetSignature() string

GetSignature 获取当前对象的唯一标识

func (*JSONConf) GetString

func (j *JSONConf) GetString(key string, def ...string) (r string)

GetString 获取字符串

func (*JSONConf) GetStrings

func (j *JSONConf) GetStrings(key string, def ...string) (r []string)

GetStrings 获取字符串数组

func (*JSONConf) GetVersion

func (j *JSONConf) GetVersion() int32

GetVersion 获取当前配置的版本号

func (*JSONConf) HasSection

func (j *JSONConf) HasSection(section string) bool

HasSection 是否存在节点

func (*JSONConf) Unmarshal

func (j *JSONConf) Unmarshal(v interface{}) error

Unmarshal 将当前[]byte反序列化为对象

type JWTAuth

type JWTAuth struct {
	Name       string   `json:"name" valid:"ascii,required"`
	ExpireAt   int64    `json:"expireAt" valid:"required"`
	Mode       string   `json:"mode" valid:"in(HS256|HS384|HS512|RS256|ES256|ES384|ES512|RS384|RS512|PS256|PS384|PS512),required"`
	Source     string   `json:"source,omitempty" valid:"in(header|cookie|HEADER|COOKIE|H)"`
	Secret     string   `json:"secret" valid:"ascii,required"`
	Exclude    []string `json:"exclude,omitempty"`
	FailedCode string   `json:"failed-code,omitempty"`
	Redirect   string   `json:"redirect,omitempty" valid:"ascii"`
	Domain     string   `json:"domain,omitempty" valid:"ascii"`
	Disable    bool     `json:"disable,omitempty"`
}

JWTAuth jwt安全认证

func NewJWT

func NewJWT(name string, mode string, secret string, expireAt int64, exclude ...string) *JWTAuth

NewJWT 构建JWT安全认证

func (*JWTAuth) IsExcluded

func (a *JWTAuth) IsExcluded(service string) bool

IsExcluded 是否是排除验证的服务

func (*JWTAuth) WithCookieStore

func (a *JWTAuth) WithCookieStore(domain ...string) *JWTAuth

WithCookieStore 将jwt信息存储到cookie中

func (*JWTAuth) WithDisable

func (a *JWTAuth) WithDisable() *JWTAuth

WithDisable 禁用配置

func (*JWTAuth) WithEnable

func (a *JWTAuth) WithEnable() *JWTAuth

WithEnable 启用配置

func (*JWTAuth) WithFailedCode

func (a *JWTAuth) WithFailedCode(code string) *JWTAuth

WithFailedCode 设置jwt验证失败后的返回给客户端的错误码

func (*JWTAuth) WithHeaderStore

func (a *JWTAuth) WithHeaderStore() *JWTAuth

WithHeaderStore 将jwt信息存储到header中

func (*JWTAuth) WithRedirect

func (a *JWTAuth) WithRedirect(url string) *JWTAuth

WithRedirect 设置jwt验证失败后的跳转地址

type LMQConf

type LMQConf = QueueConf

LMQConf 本地消息队列

func NewLMQConf

func NewLMQConf() LMQConf

NewLMQConf 本地消息队列

type MQCServerConf

type MQCServerConf struct {
	Status   string `json:"status,omitempty" valid:"in(start|stop)"`
	Sharding int    `json:"sharding,omitempty"`
	Trace    bool   `json:"trace,omitempty"`
	Timeout  int    `json:"timeout,omitempty"`
}

MQCServerConf mqc服务配置

func NewMQCServerConf

func NewMQCServerConf() *MQCServerConf

NewMQCServerConf 构建mqc server配置,默认为对等模式

func (*MQCServerConf) WithDisable

func (a *MQCServerConf) WithDisable() *MQCServerConf

WithDisable 禁用任务

func (*MQCServerConf) WithEnable

func (a *MQCServerConf) WithEnable() *MQCServerConf

WithEnable 启用任务

func (*MQCServerConf) WithMasterSlave

func (a *MQCServerConf) WithMasterSlave() *MQCServerConf

WithMasterSlave 设置为主备模式

func (*MQCServerConf) WithP2P

func (a *MQCServerConf) WithP2P() *MQCServerConf

WithP2P 设置为对等模式

func (*MQCServerConf) WithSharding

func (a *MQCServerConf) WithSharding(i int) *MQCServerConf

WithSharding 设置为分片模式

func (*MQCServerConf) WithTimeout

func (a *MQCServerConf) WithTimeout(timeout int) *MQCServerConf

WithTimeout 构建api server配置信息

func (*MQCServerConf) WithTrace

func (a *MQCServerConf) WithTrace() *MQCServerConf

WithTrace 构建api server配置信息

type MQTTConf

type MQTTConf = QueueConf

MQTTConf MQTT配置

func NewMQTTConf

func NewMQTTConf(address string, userName string, password string) MQTTConf

NewMQTTConf 构建MQTT消息队列配置

func (MQTTConf) WithCert

func (m MQTTConf) WithCert(cert string) MQTTConf

WithCert 添加证书

type MetadataConf

type MetadataConf struct {
	Name string
	Type string
	// contains filtered or unexported fields
}

func (*MetadataConf) GetMetadata

func (s *MetadataConf) GetMetadata(key string) interface{}

func (*MetadataConf) SetMetadata

func (s *MetadataConf) SetMetadata(key string, v interface{})

type Metric

type Metric struct {
	Host     string `json:"host" valid:"requrl,required"`
	DataBase string `json:"dataBase" valid:"ascii,required"`
	Cron     string `json:"cron" valid:"ascii,required"`
	UserName string `json:"userName,omitempty" valid:"ascii"`
	Password string `json:"password,omitempty" valid:"ascii"`
	Disable  bool   `json:"disable,omitempty"`
}

func NewMetric

func NewMetric(host string, db string, cron string) *Metric

NewMetric 构建api server配置信息

func (*Metric) WithDisable

func (m *Metric) WithDisable() *Metric

WithDisable 禁用配置

func (*Metric) WithEnable

func (m *Metric) WithEnable() *Metric

WithEnable 启用配置

func (*Metric) WithUserName

func (m *Metric) WithUserName(uname string, p string) *Metric

WithUserName 设置用户名密码

type Package

type Package struct {
	URL     string `json:"url" valid:"requrl,required"`
	Version string `json:"version" valid:"ascii,required"`
	CRC32   uint32 `json:"crc32" valid:"required"`
}

func NewPackage

func NewPackage(url string, version string, crc32 uint32) *Package

NewPackage 构建CRON任务

type Queue

type Queue struct {
	Name        string            `json:"name,omitempty" valid:"ascii"`
	Queue       string            `json:"queue" valid:"ascii,required"`
	Engine      string            `json:"engine,omitempty"  valid:"ascii,uppercase,in(*|RPC)"`
	Service     string            `json:"service" valid:"ascii,required"`
	Setting     map[string]string `json:"args,omitempty"`
	Concurrency int               `json:"concurrency,omitempty"`
	Disable     bool              `json:"disable,omitemptye"`
	Handler     interface{}       `json:"-"`
}

func NewQueue

func NewQueue(queue string, service string) *Queue

NewQueue 构建Queue注册项

func NewQueueWithConcurrency

func NewQueueWithConcurrency(queue string, service string, concurrency int) *Queue

NewQueueWithConcurrency 构建Queue注册项

func (*Queue) WithConcurrency

func (t *Queue) WithConcurrency(c int) *Queue

WithConcurrency 设置并发协程数

func (*Queue) WithDisable

func (t *Queue) WithDisable() *Queue

WithDisable 禁用任务

func (*Queue) WithEnable

func (t *Queue) WithEnable() *Queue

WithEnable 启用任务

type QueueConf

type QueueConf map[string]interface{}

QueueConf 消息队列配置

func (QueueConf) GetProto

func (q QueueConf) GetProto() string

GetProto 获取协议

type Queues

type Queues struct {
	Setting map[string]string `json:"args,omitempty"`
	Queues  []*Queue          `json:"queues"`
}

func NewQueues

func NewQueues() *Queues

NewQueues 构建Queue注册列表

func (*Queues) Append

func (h *Queues) Append(queue string, service string) *Queues

Append 添加Queue注册信息

type RPCServerConf

type RPCServerConf struct {
	Address   string `json:"address,omitempty" valid:"dialstring"`
	Status    string `json:"status,omitempty" valid:"in(start|stop)"`
	RTimeout  int    `json:"readTimeout,omitempty"`
	WTimeout  int    `json:"writeTimeout,omitempty"`
	RHTimeout int    `json:"readHeaderTimeout,omitempty"`
	Trace     bool   `json:"trace,omitempty"`
	Host      string `json:"host,omitempty"`
	Domain    string `json:"dn,omitempty"`
}

RPCServerConf api server配置信息

func NewRPCServerConf

func NewRPCServerConf(address string) *RPCServerConf

NewRPCServerConf 构建api server配置信息

func (*RPCServerConf) WithDNS

func (a *RPCServerConf) WithDNS(host string, ip string) *RPCServerConf

WithDNS 设置请求域名

func (*RPCServerConf) WithDisable

func (a *RPCServerConf) WithDisable() *RPCServerConf

WithDisable 禁用任务

func (*RPCServerConf) WithEnable

func (a *RPCServerConf) WithEnable() *RPCServerConf

WithEnable 启用任务

func (*RPCServerConf) WithTrace

func (a *RPCServerConf) WithTrace() *RPCServerConf

WithTrace 构建api server配置信息

type RedisCacheConf

type RedisCacheConf = CacheConf

RedisCacheConf redis消息队列

func NewRedisCacheConf

func NewRedisCacheConf(dbIndex int, address ...string) RedisCacheConf

NewRedisCacheConf 构建redis消息队列配置

func NewRedisCacheConfForProd

func NewRedisCacheConfForProd(dbIndex int, name ...string) RedisCacheConf

NewRedisCacheConfForProd 创建prod redis配置

func (RedisCacheConf) WithPoolSize

func (m RedisCacheConf) WithPoolSize(poolSize int) RedisCacheConf

WithPoolSize 修改连接数

func (RedisCacheConf) WithTimeout

func (m RedisCacheConf) WithTimeout(dialTimeout int, readTimeout int, writeTimeout int, poolSize int) RedisCacheConf

WithTimeout 设置超时时长

type RedisQueueConf

type RedisQueueConf = QueueConf

RedisQueueConf redis消息队列

func NewRedisQueueConf

func NewRedisQueueConf(address []string, dbIndex int) RedisQueueConf

NewRedisQueueConf 构建redis消息队列配置

func NewRedisQueueConfForProd

func NewRedisQueueConfForProd(dbIndex int, name ...string) RedisQueueConf

NewRedisQueueConfForProd 创建prod redis配置

func (RedisQueueConf) WithTimeout

func (m RedisQueueConf) WithTimeout(dialTimeout int, readTimeout int, writeTimeout int, poolSize int) RedisQueueConf

WithTimeout 设置超时时长

type RegistryConf

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

RegistryConf 基于注册中心的配置管理器

func NewRegistryConf

func NewRegistryConf(rgst registry.IRegistry) (s *RegistryConf)

NewRegistryConf 构建服务器配置缓存

func (*RegistryConf) GetConf

func (c *RegistryConf) GetConf(name string) (*JSONConf, error)

GetConf 指定配置文件名称,获取系统配置信息

func (*RegistryConf) GetObject

func (c *RegistryConf) GetObject(name string, v interface{}) (int32, error)

GetObject 获取子系统配置

type Response

type Response struct {
	Params    map[string]interface{} `json:"params,omitempty"`
	Templates []*Template            `json:"templates,omitempty" valid:"required"`
}

Response 请求响应配置

func NewResponse

func NewResponse(content string, service ...string) *Response

NewResponse 构建响应配置

func NewResponseByStatus

func NewResponseByStatus(status string, content string, service ...string) *Response

NewResponseByStatus 构建响应配置根据状态码模块内容

func (*Response) Append

func (r *Response) Append(s string, t string, service ...string) *Response

Append 追加模板配置

func (*Response) GetTemplate

func (r *Response) GetTemplate(s string) (bool, *Template)

GetTemplate 获取指定请求对应的模板

func (*Response) SetParam

func (r *Response) SetParam(k string, v interface{}) *Response

SetParam 追加模板配置

type Router

type Router struct {
	Name    string            `json:"name,omitempty" valid:"ascii,required"`
	Action  []string          `json:"action,omitempty" valid:"uppercase,in(GET|POST|PUT|DELETE|HEAD|TRACE|OPTIONS)"`
	Engine  string            `json:"-" valid:"-"`
	Service string            `json:"service" valid:"ascii,required"`
	Setting map[string]string `json:"args,omitempty"`
	Disable bool              `json:"disable,omitempty"`
	Handler interface{}       `json:"-" valid:"-"`
}

type Routers

type Routers struct {
	Routers []*Router         `json:"routers,omitempty"`
	RPCS    []*Router         `json:"rpcs,omitempty"`
	Setting map[string]string `json:"args,omitempty"`
}

func NewRouters

func NewRouters() *Routers

NewRouters 构建路由

func (*Routers) Append

func (h *Routers) Append(name string, service string) *Routers

Append 添加路由信息

func (*Routers) AppendRPCProxy

func (h *Routers) AppendRPCProxy(name string, service string, settings ...map[string]string) *Routers

AppendRPCProxy 添加proxy信息

func (*Routers) AppendWithAction

func (h *Routers) AppendWithAction(name string, service string, action ...string) *Routers

AppendWithAction 添加路由信息

type SecretConnect

type SecretConnect struct {
	Name     string `json:"name,omitempty" valid:"ascii"`
	KeyValue string `json:"kv,omitempty" valid:"ascii"`
	Chain    string `json:"chain,omitempty" valid:"ascii"`
	Mode     string `json:"mode,omitempty" valid:"in(head|tail|headTail)"`
	// contains filtered or unexported fields
}

SecretConnect secret拼接串

func (*SecretConnect) Connect

func (c *SecretConnect) Connect() *Connect

Connect 获取父级拼接串

func (*SecretConnect) SetChainWithHead

func (c *SecretConnect) SetChainWithHead(chain string) *SecretConnect

SetChainWithHead 设置secrect与数据串之间的拼接方式,并将secret串拼接到数据串的头部

func (*SecretConnect) SetChainWithHeadAndTail

func (c *SecretConnect) SetChainWithHeadAndTail(chain string) *SecretConnect

SetChainWithHeadAndTail 设置secrect与数据串之间的拼接方式,并将secret串拼接到数据串的头部和尾部

func (*SecretConnect) SetChainWithTail

func (c *SecretConnect) SetChainWithTail(chain string) *SecretConnect

SetChainWithTail 设置secrect与数据串之间的拼接方式,并将secret串拼接到数据串的尾部

func (*SecretConnect) SetName

func (c *SecretConnect) SetName(name string, kv string) *SecretConnect

SetName 设置secrect的键名称

type ServerConf

type ServerConf struct {
	*JSONConf
	// contains filtered or unexported fields
}

ServerConf 服务器配置信息

func NewServerConf

func NewServerConf(mainConfpath string, mainConfRaw []byte, mainConfVersion int32, rgst registry.IRegistry) (s *ServerConf, err error)

NewServerConf 构建服务器配置缓存

func (*ServerConf) ForceRestart

func (c *ServerConf) ForceRestart() bool

ForceRestart 强制重启

func (ServerConf) Get

func (m ServerConf) Get(key string) interface{}

func (*ServerConf) GetAppConf

func (c *ServerConf) GetAppConf(v interface{}) error

GetAppConf 获取系统配置

func (*ServerConf) GetClusterID

func (c *ServerConf) GetClusterID() string

GetClusterID 获取当前服务的集群编号

func (*ServerConf) GetClusterName

func (c *ServerConf) GetClusterName() string

GetClusterName 获取集群名称

func (*ServerConf) GetClusterNodes

func (c *ServerConf) GetClusterNodes(serverType ...string) CNodes

GetClusterNodes 获取集群其它服务器节点

func (*ServerConf) GetDNSPubRootPath

func (c *ServerConf) GetDNSPubRootPath(svName string) string

GetDNSPubRootPath 获取DNS服务路径

func (*ServerConf) GetMainConfPath

func (c *ServerConf) GetMainConfPath() string

GetMainConfPath 获取主配置文件路径

func (*ServerConf) GetPlatName

func (c *ServerConf) GetPlatName() string

GetPlatName 获取平台名称

func (*ServerConf) GetServerName

func (c *ServerConf) GetServerName() string

GetServerName 获取服务器名称

func (*ServerConf) GetServerPubRootPath

func (c *ServerConf) GetServerPubRootPath(serverType ...string) string

GetServerPubRootPath 获取服务器发布的跟路径

func (*ServerConf) GetServerType

func (c *ServerConf) GetServerType() string

GetServerType 获取服务器类型

func (*ServerConf) GetServicePubRootPath

func (c *ServerConf) GetServicePubRootPath(svName string) string

GetServicePubRootPath 获取服务发布跟路径

func (*ServerConf) GetSubConf

func (c *ServerConf) GetSubConf(name string) (*JSONConf, error)

GetSubConf 指定配置文件名称,获取系统配置信息

func (*ServerConf) GetSubConfClone

func (c *ServerConf) GetSubConfClone() map[string]JSONConf

GetSubConfClone 获取sub配置拷贝

func (*ServerConf) GetSubObject

func (c *ServerConf) GetSubObject(name string, v interface{}) (int32, error)

GetSubObject 获取子系统配置

func (*ServerConf) GetSysName

func (c *ServerConf) GetSysName() string

GetSysName 获取系统名称

func (*ServerConf) GetSystemRootfPath

func (c *ServerConf) GetSystemRootfPath(tp ...string) string

GetSystemRootfPath 获取系统根路径

func (*ServerConf) GetVarConf

func (c *ServerConf) GetVarConf(tp string, name string) (*JSONConf, error)

GetVarConf 指定配置文件名称,获取var配置信息

func (*ServerConf) GetVarConfClone

func (c *ServerConf) GetVarConfClone() map[string]JSONConf

GetVarConfClone 获取var配置拷贝

func (*ServerConf) GetVarObject

func (c *ServerConf) GetVarObject(tp string, name string, v interface{}) (int32, error)

GetVarObject 指定配置文件名称,获取var配置信息

func (*ServerConf) GetVarVersion

func (c *ServerConf) GetVarVersion() int32

GetVarVersion 获取var路径版本号

func (*ServerConf) HasSubConf

func (c *ServerConf) HasSubConf(names ...string) bool

HasSubConf 是否存在子级配置

func (*ServerConf) HasVarConf

func (c *ServerConf) HasVarConf(tp string, name string) bool

HasVarConf 是否存在子级配置

func (*ServerConf) IsStop

func (c *ServerConf) IsStop() bool

IsStop 当前服务是否已停止

func (*ServerConf) IterSubConf

func (c *ServerConf) IterSubConf(f func(k string, conf *JSONConf) bool)

IterSubConf 迭代所有子配置

func (*ServerConf) IterVarConf

func (c *ServerConf) IterVarConf(f func(k string, conf *JSONConf) bool)

IterVarConf 迭代所有子配置

func (ServerConf) Set

func (m ServerConf) Set(key string, value interface{})

func (*ServerConf) SetSubConf

func (c *ServerConf) SetSubConf(data map[string]JSONConf)

SetSubConf 获取sub配置参数

func (*ServerConf) SetVarConf

func (c *ServerConf) SetVarConf(data map[string]JSONConf)

SetVarConf 获取var配置参数

type ServiceAuth

type ServiceAuth struct {
	Service  string                 `json:"service,omitempty" valid:"required"`
	Requests []string               `json:"requests,omitempty" valid:"required"`
	Required []string               `json:"required,omitempty"`
	Connect  *Connect               `json:"connect,omitempty"`
	Alias    map[string]string      `json:"alias,omitempty"`
	Params   map[string]interface{} `json:"params,omitempty"`
	Decrypt  []string               `json:"decrypt,omitempty"`
	CheckTS  bool                   `json:"check-timestamp,omitempty"`
	Disable  bool                   `json:"disable,omitempty"`
}

ServiceAuth 服务认证配置

func NewServiceAuth

func NewServiceAuth(service string, request ...string) *ServiceAuth

NewServiceAuth 创建远程服务验证参数

func (*ServiceAuth) AuthString

func (a *ServiceAuth) AuthString() (string, error)

AuthString 获取签名串

func (*ServiceAuth) String

func (a *ServiceAuth) String() (string, error)

String 获取签名串

func (*ServiceAuth) WithCheckTimestamp

func (a *ServiceAuth) WithCheckTimestamp(e ...bool) *ServiceAuth

WithCheckTimestamp 设置需要检查时间戳

func (*ServiceAuth) WithConnect

func (a *ServiceAuth) WithConnect() *Connect

WithConnect 设置签名链接方式

func (*ServiceAuth) WithDecryptName

func (a *ServiceAuth) WithDecryptName(name ...string) *ServiceAuth

WithDecryptName 设置需要解密的字段名

func (*ServiceAuth) WithDisable

func (a *ServiceAuth) WithDisable() *ServiceAuth

WithDisable 禁用配置

func (*ServiceAuth) WithEnable

func (a *ServiceAuth) WithEnable() *ServiceAuth

WithEnable 启用配置

func (*ServiceAuth) WithParam

func (a *ServiceAuth) WithParam(key string, value interface{}) *ServiceAuth

WithParam 设置扩展参数

func (*ServiceAuth) WithRequest

func (a *ServiceAuth) WithRequest(path ...string) *ServiceAuth

WithRequest 设置requests的请求服务路径

func (*ServiceAuth) WithRequired

func (a *ServiceAuth) WithRequired(fieldName ...string) *ServiceAuth

WithRequired 设置必须字段

func (*ServiceAuth) WithSignAlias

func (a *ServiceAuth) WithSignAlias(name string) *ServiceAuth

WithSignAlias 设置sign的字段名

func (*ServiceAuth) WithTimestampAlias

func (a *ServiceAuth) WithTimestampAlias(name string) *ServiceAuth

WithTimestampAlias 设置timestamp的字段名

func (*ServiceAuth) WithUIDAlias

func (a *ServiceAuth) WithUIDAlias(name string) *ServiceAuth

WithUIDAlias 设置用户id的字段名

type ServiceAuths

type ServiceAuths []*ServiceAuth

ServiceAuths 远程服务验证组

func (ServiceAuths) Contains

func (a ServiceAuths) Contains(p string) (bool, *ServiceAuth)

Contains 检查指定的路径是否允许签名

type Static

type Static struct {
	Dir       string   `json:"dir,omitempty" valid:"ascii"`
	Archive   string   `json:"archive,omitempty" valid:"ascii"`
	Prefix    string   `json:"prefix,omitempty" valid:"ascii"`
	Exts      []string `json:"exts,omitempty" valid:"ascii"`
	Exclude   []string `json:"exclude,omitempty" valid:"ascii"`
	FirstPage string   `json:"first-page,omitempty" valid:"ascii"`
	Rewriters []string `json:"rewriters,omitempty" valid:"ascii"`
	Disable   bool     `json:"disable,omitempty"`
}

Static 设置静态文件配置

func NewImageStaticConf

func NewImageStaticConf() *Static

NewImageStaticConf 构建图片文件配置

func NewWebServerStaticConf

func NewWebServerStaticConf() *Static

NewWebServerStaticConf 构建Web服务静态文件配置

func (*Static) AppendExts

func (s *Static) AppendExts(exts ...string) *Static

AppendExts 设置静态文件跟目录

func (*Static) WithArchive

func (s *Static) WithArchive(archive string) *Static

WithArchive 设置静态文件跟目录

func (*Static) WithDisable

func (s *Static) WithDisable() *Static

WithDisable 禁用配置

func (*Static) WithEnable

func (s *Static) WithEnable() *Static

WithEnable 启用配置

func (*Static) WithExts

func (s *Static) WithExts(exts ...string) *Static

WithExts 设置静态文件跟目录

func (*Static) WithFirstPage

func (s *Static) WithFirstPage(firstPage string) *Static

WithFirstPage 设置静首页地址

func (*Static) WithPrefix

func (s *Static) WithPrefix(prefix string) *Static

WithPrefix 设置静态文件跟目录

func (*Static) WithRoot

func (s *Static) WithRoot(dir string) *Static

WithRoot 设置静态文件跟目录

type Task

type Task struct {
	Name    string                 `json:"name,omitempty" valid:"ascii"`
	Cron    string                 `json:"cron" valid:"ascii,required"`
	Input   map[string]interface{} `json:"-"`
	Engine  string                 `json:"engine,omitempty"  valid:"ascii,uppercase,in(*|RPC)"`
	Service string                 `json:"service"  valid:"ascii,required"`
	Setting map[string]string      `json:"args,omitempty"`
	Next    string                 `json:"-"`
	Last    string                 `json:"-"`
	Handler interface{}            `json:"-" valid:"-"`
	Disable bool                   `json:"disable,omitempty"`
}

func NewTask

func NewTask(cron string, service string) *Task

NewTask 构建CRON任务

func (*Task) WithDisable

func (t *Task) WithDisable() *Task

WithDisable 禁用任务

func (*Task) WithEnable

func (t *Task) WithEnable() *Task

WithEnable 启用任务

type Tasks

type Tasks struct {
	Setting map[string]string `json:"args,omitempty"`
	Tasks   []*Task           `json:"tasks"`
}

func NewTasks

func NewTasks() *Tasks

NewTasks 构建CRON任务列表

func (*Tasks) Append

func (h *Tasks) Append(cron string, service string) *Tasks

Append 添加路由信息

type Template

type Template struct {
	Params   map[string]interface{} `json:"params,omitempty"`
	Content  string                 `json:"content,omitempty" valid:"required"`
	Status   string                 `json:"status,omitempty" valid:"required"`
	Services []string               `json:"services,omitempty" valid:"required"`
}

func (*Template) GetContent

func (r *Template) GetContent(input interface{}) (c string, err error)

GetContent 获取翻译后的返回内容

func (*Template) GetStatus

func (r *Template) GetStatus(input interface{}) (c string, err error)

GetStatus 获取翻译后的状态码

type View

type View struct {
	Path    string   `json:"path" valid:"ascii,required"`
	Left    string   `json:"left,omitempty" valid:"ascii"`
	Right   string   `json:"right,omitempty" valid:"ascii"`
	Files   []string `json:"-"`
	Disable bool     `json:"disable,omitempty"`
}

View web服务器view解析配置

func NewView

func NewView(path string) *View

NewView 构建web服务view配置

func (*View) WithDisable

func (a *View) WithDisable() *View

WithDisable 禁用配置

func (*View) WithEnable

func (a *View) WithEnable() *View

WithEnable 启用配置

func (*View) WithExpression

func (a *View) WithExpression(left string, right string) *View

WithExpression 设置view绑定变量的左,右解析符

type WSServerConf

type WSServerConf struct {
	Address   string `json:"address,omitempty" valid:"dialstring"`
	Status    string `json:"status,omitempty" valid:"in(start|stop)"`
	RTimeout  int    `json:"readTimeout,omitempty"`
	WTimeout  int    `json:"writeTimeout,omitempty"`
	RHTimeout int    `json:"readHeaderTimeout,omitempty"`
	Trace     bool   `json:"trace,omitempty"`
}

WSServerConf api server配置信息

func NewWSServerConf

func NewWSServerConf(address string) *WSServerConf

NewWSServerConf 构建api server配置信息

func (*WSServerConf) WithDisable

func (a *WSServerConf) WithDisable() *WSServerConf

WithDisable 禁用任务

func (*WSServerConf) WithEnable

func (a *WSServerConf) WithEnable() *WSServerConf

WithEnable 启用任务

func (*WSServerConf) WithTrace

func (a *WSServerConf) WithTrace() *WSServerConf

WithTrace 构建api server配置信息

type WebServerConf

type WebServerConf = APIServerConf

WebServerConf web服务器配置

func NewWebServerConf

func NewWebServerConf(address string) *WebServerConf

NewWebServerConf 构建api server配置信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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