暂存一下,防止丢失
This commit is contained in:
90
pkg/constants/card_observation.go
Normal file
90
pkg/constants/card_observation.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package constants
|
||||
|
||||
import "time"
|
||||
|
||||
// 卡实名观测来源
|
||||
const (
|
||||
CardObservationSourcePolling = "polling" // 周期轮询
|
||||
CardObservationSourceManualSync = "manual_sync" // 手动同步
|
||||
CardObservationSourceManualOverride = "manual_override" // 人工纠偏
|
||||
CardObservationSourceCarrierCallback = "carrier_callback" // 运营商回调
|
||||
CardObservationSourceBusinessEvent = "business_event" // 业务成功后的观测
|
||||
)
|
||||
|
||||
// 卡观测事件序列同步类型。
|
||||
const (
|
||||
CardObservationSyncTypeRealname = "realname" // 实名状态
|
||||
CardObservationSyncTypeTraffic = "traffic" // 流量读数
|
||||
CardObservationSyncTypeNetwork = "network" // 网络状态
|
||||
CardObservationSyncTypeDeviceInfo = "device_info" // 设备信息
|
||||
)
|
||||
|
||||
// 卡观测事件序列资源类型。
|
||||
const (
|
||||
CardObservationResourceTypeCard = "iot_card" // IoT 卡
|
||||
CardObservationResourceTypeDevice = "device" // 设备
|
||||
)
|
||||
|
||||
// 卡观测事件序列执行参数。
|
||||
const (
|
||||
CardObservationSeriesAttemptCount = 3 // 每个序列固定尝试次数
|
||||
CardObservationSeriesTTL = 7 * time.Minute // 活跃序列覆盖最后一次任务及缓冲
|
||||
CardObservationSeriesResultTTL = 24 * time.Hour // 尝试幂等与提前完成结果保留时间
|
||||
CardObservationGatewayLockTTL = 70 * time.Second // Gateway 请求互斥超时加安全余量
|
||||
CardObservationGatewayMinInterval = 10 * time.Second // 未配置时的运营商最小请求间隔
|
||||
)
|
||||
|
||||
// CardObservationAttemptDelay 返回固定的立即、3 分钟、5 分钟阶梯延迟。
|
||||
func CardObservationAttemptDelay(attempt int) time.Duration {
|
||||
switch attempt {
|
||||
case 1:
|
||||
return 0
|
||||
case 2:
|
||||
return 3 * time.Minute
|
||||
case 3:
|
||||
return 5 * time.Minute
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// 卡观测副作用消费状态
|
||||
const (
|
||||
CardObservationEffectStatusPending = 0 // 等待处理
|
||||
CardObservationEffectStatusProcessing = 1 // 正在处理或结果未知
|
||||
CardObservationEffectStatusDailySaved = 2 // 日流量缓冲已记录
|
||||
CardObservationEffectStatusDeducted = 3 // 套餐流量已扣减
|
||||
CardObservationEffectStatusCompleted = 4 // 全部副作用已完成
|
||||
)
|
||||
|
||||
// 卡观测副作用类型
|
||||
const (
|
||||
CardObservationEffectTypeTrafficIncrement = "traffic_increment" // 流量正增量副作用
|
||||
)
|
||||
|
||||
// Gateway 轮询 Integration Log 操作编码。
|
||||
const (
|
||||
IntegrationProviderGateway = "gateway" // Gateway 外部系统
|
||||
IntegrationOperationGatewayRealname = "query_realname_status" // 查询实名状态
|
||||
IntegrationOperationGatewayTraffic = "query_flow" // 查询流量
|
||||
IntegrationOperationGatewayNetwork = "query_card_status" // 查询网络状态
|
||||
)
|
||||
|
||||
// 卡实名观测场景
|
||||
const (
|
||||
CardObservationSceneRealnamePolling = "realname_polling" // 实名轮询
|
||||
CardObservationSceneTrafficPolling = "traffic_polling" // 流量轮询
|
||||
CardObservationSceneNetworkPolling = "network_polling" // 网络状态轮询
|
||||
CardObservationSceneManualRefresh = "manual_refresh" // 手动刷新
|
||||
CardObservationSceneCarrierCallback = "carrier_realname_callback" // 运营商实名回调
|
||||
)
|
||||
|
||||
// 卡实名状态变更 Outbox 事件
|
||||
const (
|
||||
OutboxEventTypeCardRealnameChanged = "card.realname.changed" // 卡实名状态变化
|
||||
CardRealnameChangedPayloadVersionV1 = 1 // 卡实名状态变化载荷版本
|
||||
OutboxEventTypeCardTrafficIncremented = "card.traffic.incremented" // 卡流量正增量
|
||||
CardTrafficIncrementedPayloadVersionV1 = 1 // 卡流量正增量载荷版本
|
||||
OutboxEventTypeCardNetworkChanged = "card.network.changed" // 卡网络状态变化
|
||||
CardNetworkChangedPayloadVersionV1 = 1 // 卡网络状态变化载荷版本
|
||||
)
|
||||
Reference in New Issue
Block a user