cnf

package
v0.0.0-...-ae84a6d Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(filename string, v any) (e error)

Types

type DB

type DB struct {
	Driver           string
	Source           []string
	ShowSQL          bool
	Cache            DBCache
	MaxOpen, MaxIdle int
}

數據庫設定

type DBCache

type DBCache struct {
	// 存儲後端
	Redis Redis
	// 時間緩存
	Modtime Redis
	// 禁用緩存列表
	Direct []string
	// 表獨立緩存
	Special []struct {
		// 表名
		Name string
		// 存儲後端
		Redis Redis
	}
}

數據庫緩存

type HTTP

type HTTP struct {
	// 服務器監聽地址
	Addr string

	// tls 證書,如果爲空字符串則使用 http
	CertFile string
	KeyFile  string

	// 爲 api 提供 Swagger 服務 /serve/swagger/
	Swagger bool
	// 爲 靜態檔案提供 服務 /serve/assets/
	Assets bool
	// 爲 項目提供在線 說明 /serve/document/
	Document bool
	// 提供在線的 protobuf 定義 /serve/protobuf/
	Protobuf bool

	// 服務器一些細節定義
	Option ServerOption
}

http 服務定義

func (*HTTP) H2

func (h *HTTP) H2() bool

func (*HTTP) H2C

func (h *HTTP) H2C() bool

type Logger

type Logger struct {
	// 日誌存儲路徑
	Filename string
	// 單個檔案最大尺寸 MB
	MaxSize int
	// 最多保存多少個檔案
	MaxBackups int
	// 最多保存多少天日誌
	MaxDays int
	// 日誌寫入緩存大小
	BufferSize int
	// 如果爲 true 在日誌中輸出代碼所在行
	Caller bool
	// 輸出到檔案的日誌等級 [debug info warn error dpanic panic fatal]
	FileLevel string
	// 輸出到控制檯的日誌等級 [debug info warn error dpanic panic fatal]
	ConsoleLevel string
}

日誌定義

type Redis

type Redis struct {
	Write string
	Read  string
	// 緩存過期時間
	Timeout time.Duration
}

func (*Redis) IsValid

func (r *Redis) IsValid() bool

func (*Redis) Key

func (r *Redis) Key() string

type ServerOption

type ServerOption struct {
	WriteBufferSize, ReadBufferSize          int
	InitialWindowSize, InitialConnWindowSize int32
	MaxRecvMsgSize, MaxSendMsgSize           int
	MaxConcurrentStreams                     uint32
	ConnectionTimeout                        time.Duration
	Keepalive                                keepalive.ServerParameters
}

type Session

type Session struct {
	// 會話數據存儲路徑
	Path string

	// redis 寫入地址,如果設置則使用 redis 爲會話提供緩存
	Write string
	// redis 讀取地址,可以使用 redis 讀寫分離
	// 如果爲空字符串,則使用 Write 設定的值
	Read string
	// 訪問 token 有效時間
	Access time.Duration
	// 刷新 token 有效時間
	Refresh time.Duration
	// session 最長維持多久
	Deadline time.Duration
	// 支持的平臺,每個平臺同一時刻只允許相同用戶存在一個會話,但不同平臺可以存在同一用戶的多個會話
	Platform []string

	// session 簽名算法 HMD5 HS1 HS256 HS384 HS512
	Alg string
	// 簽名密鑰
	Key string
}

定義會話

Jump to

Keyboard shortcuts

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