inter

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GRPCSchema = "GRPC"
	HTTPSchema = "HTTP"
)
View Source
const (
	RedisStore  = "redis"
	MongoStore  = "mongo"
	MemoryStore = "memory"
)

Variables

This section is empty.

Functions

func ConfigDataWithLogger

func ConfigDataWithLogger(cd *ConfigData) error

func ConfigDataWithMongo

func ConfigDataWithMongo(cd *ConfigData) error

func ConfigDataWithRedis

func ConfigDataWithRedis(cd *ConfigData) error

func ConfigDataWithValidatorAddr

func ConfigDataWithValidatorAddr(cd *ConfigData) error

func ConfigDataWithValidatorStore

func ConfigDataWithValidatorStore(cd *ConfigData) error

func ConfigDataWithValidatorTimer

func ConfigDataWithValidatorTimer(cd *ConfigData) error

func ConfigDataWithValidatorWorker

func ConfigDataWithValidatorWorker(cd *ConfigData) error

Types

type Config

type Config struct {
	BaseLevel   string `toml:"base_level"`
	ConfigScale int64  `toml:"config_scale" valid:"required"` // 原始刻度
	Role        uint
	DataSource  *DataSourceConfig `toml:"data_source"`
	Timer       *TimerConfig
	Worker      *WorkerConfig
	Log         *LogConfig
	Redis       *RedisConnectConfig
	Mongo       *MongoConnectConfig
	Services    *ServiceConfig
	GenerateId  *GenerateIdConfig `toml:"generate_id"`
	Gp          *GpConfig         `toml:"gp"`
}

type ConfigBoot

type ConfigBoot struct {
	Logger system.Logger
	Redis  *redis.Pool
	Mongo  MongoInfo
}

type ConfigData

type ConfigData struct {
	C  *Config
	CB *ConfigBoot
}

type DataSourceConfig

type DataSourceConfig struct {
	Dst   string `valid:"required"` // data source type
	Redis *RedisStoreConfig
	Rst   string `toml:"rst"` // ready queue type
}

type Format

type Format struct {
}

func (*Format) Format

func (lf *Format) Format(entry *logrus.Entry) ([]byte, error)

type GRPCServiceConfig

type GRPCServiceConfig struct {
	Addr string
}

type GenerateConfig

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

func NewGenerateConfig

func NewGenerateConfig(opts ...GenerateConfigOption) *GenerateConfig

func NewGenerateConfigWithDefaultAfters

func NewGenerateConfigWithDefaultAfters(opts ...GenerateConfigOption) *GenerateConfig

func (*GenerateConfig) ConfigData

func (gc *GenerateConfig) ConfigData() *ConfigData

这里需要先执行Run

func (*GenerateConfig) Run

func (gc *GenerateConfig) Run() (err error)

这里不能出现并发(ch是公用的)

type GenerateConfigOption

type GenerateConfigOption func(*GenerateConfig)

func GenerateConfigWithAfter

func GenerateConfigWithAfter(after ...func(*ConfigData) error) GenerateConfigOption

func GenerateConfigWithConfigName

func GenerateConfigWithConfigName(configName string) GenerateConfigOption

func GenerateConfigWithConfigType

func GenerateConfigWithConfigType(configType string) GenerateConfigOption

type GenerateIdConfig

type GenerateIdConfig struct {
	Type    string
	Timeout int64
	Group   *GroupConfig
	Redis   *RedisGenerateIdConfig
}

type GpConfig

type GpConfig struct {
	Limit     int32
	Idle      int
	IdleTime  int `toml:"idle_time"`
	CheckNum  int `toml:"check_num"`
	BlockTime int `toml:"block_time"`
	SpanNum   int `toml:"span_num"`
}

type GroupConfig

type GroupConfig struct {
	Id    string `valid:"required"`
	Group string `valid:"required"`
	Num   int    `valid:"required"`
}

type HttpServiceConfig

type HttpServiceConfig struct {
	Addr string
}

type LogConfig

type LogConfig struct {
	Dir      string // 日志路径
	Level    string
	StdPrint bool   `toml:"std_print"` // 是否打印到控制台
	Category string // 分类
}

type MongoConnectConfig

type MongoConnectConfig struct {
	Uri             string `toml:"uri"`                // uri
	DbName          string `toml:"db_name"`            // 数据库名字
	MaxPoolSize     uint64 `toml:"max_pool_size"`      // 最大连接数
	ConnectTimeout  uint64 `toml:"connect_timeout"`    // 连接超时时间, 毫秒
	MaxConnIdleTime uint64 `toml:"max_conn_idle_time"` // 连接空闲时间,毫秒
	Transaction     bool   `toml:"transaction"`        // 是否开启事务
}

type MongoInfo

type MongoInfo struct {
	Client  *mongo.Client
	Version int // 只考虑大版本
}

type RedisConnectConfig

type RedisConnectConfig struct {
	Addr           string // 地址
	Auth           string // 密码
	Db             int    // 数据库
	Idle           int    // 最大连接数
	Active         int    // 一次性活跃
	Wait           bool   // 是否等待空闲连接
	ConnectTimeout int64  `toml:"connect_timeout"` // 连接超时时间, 毫秒
}

type RedisGenerateIdConfig

type RedisGenerateIdConfig struct {
	Prefix     string
	CacheNum   int    `toml:"cache_num"`
	ValidTime  int    `toml:"valid_time"`
	CheckTime  int    `toml:"check_time"`
	HashKey    string `toml:"hash_key"`
	MaxLostNum int    `toml:"max_lost_num"`
}

type RedisStoreConfig

type RedisStoreConfig struct {
	Prefix string
	Name   string `valid:"required"`
}

type ServiceConfig

type ServiceConfig struct {
	Types []string           // GRPC\HTTP
	Wait  bool               // 是否等待
	HTTP  *HttpServiceConfig `toml:"http"`
	GRPC  *GRPCServiceConfig `toml:"grpc"`
}

type TimerConfig

type TimerConfig struct {
	St               string             // scanner type
	ConfigScaleLevel int64              `toml:"config_scale_level" valid:"required"` // 级别
	TimingWheel      *TimingWheelConfig `toml:"timing_wheel"`
	MaxCheckTime     int                `toml:"max_check_time"`
	Timeout          int64
	CheckMulti       int `toml:"check_multi"`
}

type TimingWheelConfig

type TimingWheelConfig struct {
	MaxLevel          int                    `toml:"max_level" valid:"required"` // 最大层级
	SlotNum           int                    `toml:"slot_num" valid:"required"`
	ReloadGoNum       int                    `toml:"reload_go_num" valid:"required"`
	ReloadConfigScale int64                  `toml:"reload_config_scale" valid:"required"`
	ReloadPerNum      int                    `toml:"reload_per_num" valid:"required"`
	ReloadType        string                 `toml:"reload_type"`
	MaxCheckTime      int64                  `toml:"max_check_time"`
	FileStore         *TimingWheelFileConfig `toml:"file_store"`
}

type TimingWheelFileConfig

type TimingWheelFileConfig struct {
	Dir            string `toml:"dir"`
	MaxMemoryNum   int    `toml:"max_memory_num"` // 最大内存存储数量
	LevelMaxReader int    `toml:"level_max_reader"`
	LevelMaxWriter int    `toml:"level_max_writer"`
}

type WorkerConfig

type WorkerConfig struct {
	RetryTimes    int `toml:"retry_times"`
	Timeout       int64
	RepeatedTimes int64 `toml:"repeated_times"`
}

Jump to

Keyboard shortcuts

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