constants

package
v0.0.0-...-f578327 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)
View Source
const (
	CheckFileTypeBufferSize = 512 // 适用于判断文件类型,需要读取前512个字节

	SnowflakeWorkerID     = 0
	SnowflakeDatacenterID = 0

	ClassroomWorker        = 1              // (class_room) 同时启用的 goroutine 数量
	ClassroomScheduledTime = 24 * time.Hour // (class_room) 空教室非当天同步时间
	ClassroomUpdatedTime   = 6 * time.Hour  // (class_room) 当天空教室更新间隔

	NoticeWorker     = 1
	NoticeUpdateTime = 8 * time.Hour // (notice) 通知更新间隔
	NoticePageSize   = 20            // 教务处教学通知一页大小固定 20

	CacheFileDir = "UssFileDir" // (paper) 文件缓存目录

	// ValidateCodeURL 获取验证码结果的本地python服务url,需要保证 login-verify 和 api 处于同一个 dokcer 网络中
	ValidateCodeURL = "http://login-verify:8081/api/v1/jwch/user/validateCode"
	// UmengURL 友盟推送 API
	UmengURL = "https://msgapi.umeng.com/api/send"
)
View Source
const (
	MaxConnections  = 1000             // (DB) 最大连接数
	MaxIdleConns    = 10               // (DB) 最大空闲连接数
	ConnMaxLifetime = 10 * time.Second // (DB) 最大可复用时间
	ConnMaxIdleTime = 5 * time.Minute  // (DB) 最长保持空闲状态时间
)
View Source
const (
	UserTableName         = "student"
	CourseTableName       = "course"
	LaunchScreenTableName = "launch_screen"
	NoticeTableName       = "notice"
)
View Source
const (
	MaxRetries   = 5               // 最大重试次数
	InitialDelay = 1 * time.Second // 初始等待时间

	// GetPlanMethod GetPlan接口在得到url后的请求方法
	GetPlanMethod = http.MethodGet
)
View Source
const (
	KafkaReadMinBytes      = 512 * B
	KafkaReadMaxBytes      = 1 * MB
	KafkaRetries           = 3
	DefaultReaderGroupID   = "r"
	DefaultTimeRetainHours = 6 // 6小时
)
View Source
const (
	// LogFilePath 对应 ${pwd}/{LogFilePath}/log.log 相对于当前运行路径而言
	LogFilePath = "log"

	LogFilePathTemplate      = "%s/%s/%s/%s.log"
	ErrorLogFilePathTemplate = "%s/%s/%s/%s_stderr.log"

	// DefaultLogLevel 是默认的日志等级. Supported Level: debug info warn error fatal
	DefaultLogLevel = "INFO"

	StackTraceKey = "stacktrace"
	ServiceKey    = "service"
	SourceKey     = "source"

	KlogSource  = "klog"
	MysqlSource = "mysql"
	RedisSource = "redis"
)
View Source
const (
	ClassroomKeyExpire    = 2 * 24 * time.Hour
	LaunchScreenKeyExpire = 2 * 24 * time.Hour
	LastLaunchScreenIdKey = "last_launch_screen_id"
)

Redis Key and Expire Time

View Source
const (
	RedisDBEmptyRoom    = 0
	RedisDBLaunchScreen = 1
	RedisDBPaper        = 2
)

Redis DB Name

View Source
const (
	MuxConnection    = 1                     // (RPC) 最大连接数
	StreamBufferSize = 1024                  // (RPC) 流请求 Buffer 尺寸
	MaxQPS           = 100                   // (RPC) 最大 QPS
	RPCTimeout       = 3 * time.Second       // (RPC) RPC请求超时时间
	ConnectTimeout   = 50 * time.Millisecond // (RPC) 连接超时时间
)
View Source
const (
	ClassroomServiceName    = "classroom"
	CourseServiceName       = "course"
	UserServiceName         = "user"
	ApiServiceName          = "api"
	LaunchScreenServiceName = "launch_screen"
	PaperServiceName        = "paper"
	VersionServiceName      = "version"
	AcademicServiceName     = "academic"
	CommonServiceName       = "common"
)

Service Name

View Source
const (
	TypeAccessToken  = 0
	TypeRefreshToken = 1

	AccessTokenTTL  = time.Hour * 24 * 7  // Access Token 有效期7天
	RefreshTokenTTL = time.Hour * 24 * 30 // Refresh Token 有效期30天
	Issuer          = "west2-online"      // token 颁发者

	AuthHeader         = "Authorization" // 获取 Token 时的请求头
	AccessTokenHeader  = "Access-Token"  // 响应时的访问令牌头
	RefreshTokenHeader = "Refresh-Token" // 响应时的刷新令牌头
)
View Source
const (
	OneDay = 24 * time.Hour // 一天的时间,适用于 classroom、paper 等服务计算时间
)
View Source
const (
	RedisSlowQuery = 10 // ms redis默认的慢查询时间,适用于 logger
)

Variables

View Source
var CampusArray = []string{"旗山校区", "厦门工艺美院", "铜盘校区", "怡山校区", "晋江校区", "泉港校区"}

CampusArray 校区数组

View Source
var PublicKey = fmt.Sprintf("%v\n%v\n%v", "-----BEGIN PUBLIC KEY-----",
	"MCowBQYDK2VwAyEAT+ypuz7wIltf8HoFUEI/rDBrQNhZShqLv88j4aAWnT0=",
	"-----END PUBLIC KEY-----")

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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