Documentation
¶
Index ¶
Constants ¶
View Source
const ( B = 1 KB = 1024 * B MB = 1024 * KB GB = 1024 * MB )
View Source
const ( CheckFileTypeBufferSize = 512 // 适用于判断文件类型,需要读取前512个字节 FileStreamBufferSize = 1024 )
View Source
const ( MaxConnections = 1000 // (DB) 最大连接数 MaxIdleConns = 10 // (DB) 最大空闲连接数 ConnMaxLifetime = 10 * time.Second // (DB) 最大可复用时间 ConnMaxIdleTime = 5 * time.Minute // (DB) 最长保持空闲状态时间 )
View Source
const ( UserTableName = "users" CategoryTableName = "categories" OrderTableName = "orders" OrderGoodsTableName = "order_goods" SpuTableName = "spu_info" SpuImageTableName = "spu_image" SpuSkuTableName = "spu_to_sku" CartTableName = "cart" PaymentTableName = "payments" PaymentRefundTableName = "payment_refunds" PaymentLedgerTableName = "payment_ledgers" )
View Source
const ( // 请求体最大体积 ServerMaxRequestBodySize = 1 << 31 CorsMaxAge = 12 * time.Hour SentinelThreshold = 100 SentinelStatIntervalInMs = 1000 LoginDataKey = "loginData" )
View Source
const ( KafkaReadMinBytes = 512 * B KafkaReadMaxBytes = 1 * MB KafkaRetries = 3 DefaultReaderGroupID = "r" DefaultTimeRetainHours = 6 // 6小时 DefaultConsumerChanCap = 20 DefaultKafkaProductorSyncWrite = false DefaultKafkaNumPartitions = -1 DefaultKafkaReplicationFactor = -1 )
View Source
const ( KafkaImageTopic = "ImageTopic" KafkaPartitionNum = 3 KafkaImageGroupId = "ImageGroupId" )
Commodity Service
View Source
const ( KafkaCartTopic = "cart" // Kafka的话题 KafkaCartAddGoodsPartitionNum = 10 // Kafka的分区数 KafkaCartAddGoodsConsumerNum = 10 // Kafka的并发消费者数 KafkaCartAddGoodsGroupId = "cart_add_goods" // Kafka的订阅组id )
CartService
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" ErrorCodeKey = "error_code" KlogSource = "klog" MysqlSource = "mysql" RedisSource = "redis" KafkaSource = "kafka" )
View Source
const ( OrderNotExist = false PaymentExist = true PaymentNotExist = false UserNotExist = false PaymentSecretKey = "west2online" RefundSecretKey = "west2online" ExpirationDuration = 15 * time.Minute RefundExpirationDuration = 15 * time.Minute // TODO 这一个常量要改 PingTime = 2 )
View Source
const ( RedisStoreSuccess = true // 成功 RedisStoreFailed = false // Redis 存储失败 RedisValid = true RedisMinute = 60 RedisHour = 3600 RedisDay = 86400 RedisDayPlaceholder = "1" RedisCheckTimesInMinute = 3 )
View Source
const ( PaymentStatusPending = iota // 待支付 PaymentStatusProcessing // 处理中 PaymentStatusSuccess // 成功支付 PaymentStatusFailed // 支付失败 )
View Source
const ( RefundStatusPending = iota RefundStatusProcessing RefundStatusSuccess RefundStatusFailed )
View Source
const ( RedisCartExpireTime = 5 * 60 * time.Second RedisCartStoreNum = 30 RedisSpuImageExpireTime = 5 * 60 * time.Second )
Redis Key and Expire Time
View Source
const ( RedisDBOrder = 0 RedisDBCommodity = 1 RedisDBCart = 2 )
Redis DB Name
View Source
const ( RedisPoolSize = 50 // 最大连接数 RedisMinIdleConnections = 10 // 最小空闲连接数 RedisDialTimeout = 5 * time.Second // 连接超时时间 )
Redis Connection Pool Configuration
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 ( GatewayServiceName = "gateway" OrderServiceName = "order" UserServiceName = "user" PaymentServiceName = "payment" CommodityServiceName = "commodity" CartServiceName = "cart" )
Service Name
View Source
const ( UserMaximumPasswordLength = 72 // DO NOT EDIT (ref: bcrypt.GenerateFromPassword) UserMinimumPasswordLength = 5 UserDefaultEncryptPasswordCost = 10 UserTestId = 1 )
UserService
View Source
const ( OrderStatusUnpaidCode = -1 OrderStatusPaidCode = 1 OrderStatusCompletedCode = 2 OrderStatusCancelledCode = 3 )
OrderService
View Source
const ( OrderStatusUnpaid = "待支付" OrderStatusPaid = "已支付" OrderStatusCompleted = "已完成" OrderStatusCancelled = "已取消" OrderStatusUnknown = "未知状态" )
OrderService Status Messages
View Source
const ( CommodityAllowedForSale = 1 CommodityNotAllowedForSale = 2 )
CommodityService
View Source
const ( DefaultDataCenterID = int64(0) DefaultWorkerID = int64(0) )
View Source
const ( WorkerOfUserService = 1 + int64(iota) WorkerOfOrderService )
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 ( SpuDirDest = "/spu/" SpuImageDirDest = "/spu_image/" )
View Source
const (
RedisSlowQuery = 10 // ms redis默认的慢查询时间,适用于 logger
)
View Source
const (
TestUserID = 123
)
TODO 最后要删除这个东西
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.