mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(core): implement namespace support and routing bindings
Introduce namespace-aware routing capabilities through a new Binding model and updates to Master/Key entities. - Add Binding model for configuring model routes per namespace - Add DefaultNamespace and Namespaces fields to Master and Key models - Update auto-migration to include Binding table - Implement Redis synchronization for binding configurations - Propagate namespace settings during master creation and key issuance
This commit is contained in:
@@ -15,6 +15,8 @@ type Master struct {
|
||||
MasterKey string `gorm:"size:255" json:"-"` // bcrypt hash of master key
|
||||
MasterKeyDigest string `gorm:"size:64;uniqueIndex" json:"-"` // sha256 digest for lookup
|
||||
Group string `gorm:"size:100;default:'default'" json:"group"` // routing group
|
||||
DefaultNamespace string `gorm:"size:100;default:'default'" json:"default_namespace"`
|
||||
Namespaces string `gorm:"size:1024;default:'default'" json:"namespaces"` // Comma-separated namespaces
|
||||
Epoch int64 `gorm:"default:1" json:"epoch"` // used for revocation/rotation
|
||||
Status string `gorm:"size:50;default:'active'" json:"status"` // active, suspended
|
||||
MaxChildKeys int `gorm:"default:5" json:"max_child_keys"`
|
||||
@@ -29,6 +31,8 @@ type Key struct {
|
||||
TokenHash string `gorm:"size:64;uniqueIndex" json:"token_hash"` // sha256 digest of child key
|
||||
Group string `gorm:"size:100;default:'default'" json:"group"` // routing group
|
||||
Scopes string `gorm:"size:1024" json:"scopes"` // Comma-separated scopes
|
||||
DefaultNamespace string `gorm:"size:100;default:'default'" json:"default_namespace"`
|
||||
Namespaces string `gorm:"size:1024;default:'default'" json:"namespaces"` // Comma-separated namespaces
|
||||
IssuedAtEpoch int64 `gorm:"not null" json:"issued_at_epoch"` // copy of master epoch at issuance
|
||||
Status string `gorm:"size:50;default:'active'" json:"status"` // active, suspended
|
||||
IssuedBy string `gorm:"size:20;default:'master'" json:"issued_by"`
|
||||
@@ -63,3 +67,15 @@ type Model struct {
|
||||
SupportsFIM bool `json:"supports_fim"`
|
||||
MaxOutputTokens int `json:"max_output_tokens"`
|
||||
}
|
||||
|
||||
// Binding defines a stable "namespace.public_model" routing key and its target RouteGroup + selector.
|
||||
// RouteGroup currently reuses Provider.Group.
|
||||
type Binding struct {
|
||||
gorm.Model
|
||||
Namespace string `gorm:"size:100;not null;index:idx_binding_key,unique" json:"namespace"`
|
||||
PublicModel string `gorm:"size:255;not null;index:idx_binding_key,unique" json:"public_model"`
|
||||
RouteGroup string `gorm:"size:100;not null" json:"route_group"`
|
||||
SelectorType string `gorm:"size:50;default:'exact'" json:"selector_type"`
|
||||
SelectorValue string `gorm:"size:255" json:"selector_value"`
|
||||
Status string `gorm:"size:50;default:'active'" json:"status"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user