Documentation ¶
Index ¶
- Constants
- Variables
- func Code2Id(code []byte) (id int64, err error)
- func Code6(id int64) (code []byte, err error)
- func Code6String(id int64) (code string, err error)
- func Code6To8(code6 []byte) (code8 []byte, err error)
- func Code8(id int64) (code []byte, err error)
- func Code8String(id int64) (code string, err error)
- func CodeString2Id(code string) (id int64, err error)
- func CodeString6To8(code6 string) (code8 string, err error)
- func CreatePkcs1Keys(keyLength int) (privateKey, publicKey string)
- func CreatePkcs8Keys(keyLength int) (privateKey, publicKey string)
- func MarshalPkcs8PrivateKey(key *rsa.PrivateKey) []byte
- func Max6() int64
- func Max8() int64
- type Aes
- type Chain
- type Config
- type Context
- func (c *Context) Abort()
- func (c *Context) Close()
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) Event() *Event
- func (c *Context) Get(key string, defaultVal any) (value any)
- func (c *Context) GetBool(key string, defaultVal bool) (value bool)
- func (c *Context) GetInt(key string, defaultVal int64) (value int64)
- func (c *Context) GetString(key, defaultVal string) (value string)
- func (c *Context) GetUint(key string, defaultVal uint64) (value uint64)
- func (c *Context) IsAborted() bool
- func (c *Context) Next()
- func (c *Context) Set(key string, value any)
- func (c *Context) SetEvent(event *Event)
- func (c *Context) Value(key any) any
- type Event
- type EventManager
- type GetMachineId
- type Handler
- type HashRing
- type I18n
- type IdCode
- func (ic *IdCode) Code2Id(code []byte) (id int64, err error)
- func (ic *IdCode) Code6(id int64) (code []byte, err error)
- func (ic *IdCode) Code6String(id int64) (code string, err error)
- func (ic *IdCode) Code6To8(code6 []byte) (code8 []byte, err error)
- func (ic *IdCode) Code8(id int64) (code []byte, err error)
- func (ic *IdCode) Code8String(id int64) (code string, err error)
- func (ic *IdCode) CodeString2Id(code string) (id int64, err error)
- func (ic *IdCode) CodeString6To8(code6 string) (code8 string, err error)
- func (ic *IdCode) Max6() int64
- func (ic *IdCode) Max8() int64
- type Node
- type NodeList
- type Package
- type Rsa
- func NewRsa(publicKey, privateKey string) (r *Rsa, err error)
- func NewRsaBytes(public, private []byte) (r *Rsa, err error)
- func NewRsaWithPkcs1(publicKey, privateKey string) (r *Rsa, err error)
- func NewRsaWithPkcs1Bytes(public, private []byte) (r *Rsa, err error)
- func NewRsaWithPkcs8(publicKey, privateKey string) (r *Rsa, err error)
- func NewRsaWithPkcs8Bytes(public, private []byte) (r *Rsa, err error)
- type SnowFlake
- type Status
- func (s *Status) Close()
- func (s *Status) ConvertGrpcStatus(details ...proto.Message) (*status.Status, error)
- func (s *Status) Error() string
- func (s *Status) IsCode(code codes.Code) bool
- func (s *Status) IsOK() bool
- func (s *Status) JsonMarshal() []byte
- func (s *Status) ToError() error
- func (s *Status) WithData(data any) *Status
- func (s *Status) WithFlag(flag uint8) *Status
- func (s *Status) WithMsg(msg string) *Status
Constants ¶
View Source
const ( EnvPro = `pro` EnvDev = `dev` EnvTest = `test` )
View Source
const ( ModeWait = 1 ModeMaxTime = 2 ModeError = 3 )
View Source
const (
ZhCn = `zh_CN`
)
Variables ¶
View Source
var ( ErrInvalidPaddingChar = errors.New(`invalid padding char`) ErrAesDecrypt = errors.New(`aes decrypt error`) )
View Source
var ( ErrDataEmpty = errors.New("data is empty") ErrDataFormat = errors.New("invalid data format") ErrOutOfRange = errors.New("out of range") ErrAlphanumeric = errors.New("alphanumeric must be [a-zA-Z0-9] and not repeat") ErrAlphanumericLength = errors.New("alphanumeric length must be [50, 62]") ErrTimeBack = errors.New("time go back") ErrMachineId = errors.New("illegal machine id") )
View Source
var ( ErrMsgMapEmpty = errors.New("msgMap can not empty") ErrNoYamlFiles = errors.New("there are no `.yml` or `.yaml` files in this directory") ErrNoJsonFiles = errors.New("there are no `.json` files in this directory") )
View Source
var ErrNoServer = errors.New("no server")
Functions ¶
func Code6String ¶
func Code8String ¶
func CodeString2Id ¶
func CodeString6To8 ¶
func CreatePkcs1Keys ¶
CreatePkcs1Keys 生成pkcs1格式公钥私钥
func CreatePkcs8Keys ¶
CreatePkcs8Keys 生成pkcs8格式公钥私钥
func MarshalPkcs8PrivateKey ¶
func MarshalPkcs8PrivateKey(key *rsa.PrivateKey) []byte
Types ¶
type Aes ¶
type Aes struct {
// contains filtered or unexported fields
}
Aes Aes加密
func NewAesWithBytes ¶
NewAesWithBytes 实例化Aes
func (*Aes) CbcDecrypt ¶
CbcDecrypt cbc解密
func (*Aes) CbcEncrypt ¶
CbcEncrypt cbc加密
type Chain ¶ added in v2.0.9
type Chain struct {
// contains filtered or unexported fields
}
func (*Chain) RunWithCtx ¶ added in v2.0.9
type Config ¶
type Config struct { Name string `json:"name" yaml:"name"` Addr string `json:"addr" yaml:"addr"` PprofAddr string `json:"pprofAddr" yaml:"pprofAddr"` Env string `json:"env" yaml:"env"` Ver string `json:"ver" yaml:"ver"` Logger logger.Option `json:"logger" yaml:"logger"` Params kind.JsonParam `json:"params" yaml:"params"` }
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context 上下文
type EventManager ¶ added in v2.0.9
type EventManager struct {
// contains filtered or unexported fields
}
func (*EventManager) Has ¶ added in v2.0.9
func (em *EventManager) Has(name string) bool
func (*EventManager) On ¶ added in v2.0.9
func (em *EventManager) On(name string, handlers ...Handler)
func (*EventManager) Trigger ¶ added in v2.0.9
func (em *EventManager) Trigger(name string, data any)
type GetMachineId ¶
GetMachineId 获取机器Id
func GetMachineIdByEnv ¶
func GetMachineIdByEnv(key string) GetMachineId
GetMachineIdByEnv 根据环境变量获取机器Id
type HashRing ¶
type HashRing interface { // Store 存储servers Store(servers ...kind.CanHash) // Get 获取server Get(key any) (server kind.CanHash, err error) // Index 根据index获取server Index(index int) (server kind.CanHash, err error) // Add 添加server Add(server kind.CanHash) // Remove 移除server Remove(server kind.CanHash) // Length 获取servers长度 Length() int // Range 遍历servers Range(handler func(index int, server kind.CanHash, hitCount uint64) (handled bool)) }
HashRing Hash环
func NewHashRing ¶
type I18n ¶
I18n 多语言接口
func NewI18nFromJson ¶
NewI18nFromJson 从Json文件配置实例化多语言
type IdCode ¶
type IdCode struct {
// contains filtered or unexported fields
}
func (*IdCode) CodeString6To8 ¶
type Package ¶
type Rsa ¶
type Rsa struct {
// contains filtered or unexported fields
}
Rsa Rsa
func NewRsaWithPkcs1 ¶
NewRsaWithPkcs1 pkcs1实例化Rsa
func NewRsaWithPkcs1Bytes ¶
NewRsaWithPkcs1Bytes pkc1实例化Rsa
func NewRsaWithPkcs8 ¶
NewRsaWithPkcs8 pkcs8实例化Rsa
func NewRsaWithPkcs8Bytes ¶
type SnowFlake ¶
type SnowFlake interface { // Id 生成id Id() (int64, error) // Info 根据id获取信息 Info(id int64) (timestamp int64, machineId uint8, index int16) }
SnowFlake 雪花算法接口,1位0,41位毫秒时间戳,8位机器码,14位递增值
func NewSFByMachineFunc ¶
func NewSFByMachineFunc(mode uint8, machindFunc GetMachineId, beginSeconds int64) (sfl SnowFlake, err error)
NewSFByMachineFunc GetMachineId方式实例化雪花算法
type Status ¶
type Status struct { Code codes.Code `json:"code"` Msg string `json:"msg"` Flag uint8 `json:"flag"` Data any `json:"data"` }
func StatusWithCodeMsg ¶
StatusWithCodeMsg 实例化Status
func StatusWithJsonUnmarshal ¶
StatusWithJsonUnmarshal 指定json []byte获取一个Status
func (*Status) ConvertGrpcStatus ¶
ConvertGrpcStatus 转换为grpc状态码
Click to show internal directories.
Click to hide internal directories.