feat: 004/phase 1
This commit is contained in:
44
internal/hubmodule/interfaces.go
Normal file
44
internal/hubmodule/interfaces.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package hubmodule
|
||||
|
||||
import "time"
|
||||
|
||||
// MigrationState 描述模块上线阶段,方便观测端区分 legacy/beta/ga。
|
||||
type MigrationState string
|
||||
|
||||
const (
|
||||
MigrationStateLegacy MigrationState = "legacy"
|
||||
MigrationStateBeta MigrationState = "beta"
|
||||
MigrationStateGA MigrationState = "ga"
|
||||
)
|
||||
|
||||
// ValidationMode 描述缓存再验证的默认策略。
|
||||
type ValidationMode string
|
||||
|
||||
const (
|
||||
ValidationModeETag ValidationMode = "etag"
|
||||
ValidationModeLastModified ValidationMode = "last-modified"
|
||||
ValidationModeNever ValidationMode = "never"
|
||||
)
|
||||
|
||||
// CacheStrategyProfile 描述模块的缓存读写策略及其默认值。
|
||||
type CacheStrategyProfile struct {
|
||||
TTLHint time.Duration
|
||||
ValidationMode ValidationMode
|
||||
DiskLayout string
|
||||
RequiresMetadataFile bool
|
||||
SupportsStreamingWrite bool
|
||||
}
|
||||
|
||||
// ModuleMetadata 记录一个模块的静态信息,供配置校验和诊断端使用。
|
||||
type ModuleMetadata struct {
|
||||
Key string
|
||||
Description string
|
||||
MigrationState MigrationState
|
||||
SupportedProtocols []string
|
||||
CacheStrategy CacheStrategyProfile
|
||||
}
|
||||
|
||||
// DefaultModuleKey 返回内置 legacy 模块的键值。
|
||||
func DefaultModuleKey() string {
|
||||
return defaultModuleKey
|
||||
}
|
||||
Reference in New Issue
Block a user