feat: sync deployed v1.0.0-rc.38-custom.42
Sync production source including routing, billing, Astra detection and public uptime. Update custom build instructions and license packaging.
This commit is contained in:
1 parent
aa6c3f50f4
commit
ceddfd3d6b
828 files changed
+122253
-13702
No files matched your search
@@ -195,13 +195,28 @@ func InitOptionMap() {
|
||||
}
|
||||
|
||||
func loadOptionsFromDatabase() {
|
||||
requestPolicyOptionMutex.Lock()
|
||||
defer requestPolicyOptionMutex.Unlock()
|
||||
defer func() {
|
||||
if err := refreshRequestPolicySnapshot(); err != nil {
|
||||
common.SysError("invalid request policy: " + err.Error())
|
||||
}
|
||||
}()
|
||||
passkeyOptionMutex.Lock()
|
||||
defer passkeyOptionMutex.Unlock()
|
||||
options, _ := AllOption()
|
||||
passkeyOptions := make(map[string]string)
|
||||
for _, option := range options {
|
||||
if IsPasskeyDomainOption(option.Key) {
|
||||
passkeyOptions[option.Key] = option.Value
|
||||
continue
|
||||
}
|
||||
err := updateOptionMap(option.Key, option.Value)
|
||||
if err != nil {
|
||||
common.SysLog("failed to update option map: " + err.Error())
|
||||
}
|
||||
}
|
||||
applyPasskeyDomainOptions(passkeyOptions)
|
||||
}
|
||||
|
||||
func SyncOptions(frequency int) {
|
||||
@@ -226,6 +241,13 @@ func validateOptionValue(key string, value string) error {
|
||||
}
|
||||
|
||||
func UpdateOption(key string, value string) error {
|
||||
if IsRequestPolicyOption(key) {
|
||||
return UpdateRequestPolicyOptions(map[string]string{key: value})
|
||||
}
|
||||
if IsPasskeyDomainOption(key) {
|
||||
_, err := UpdatePasskeyDomainOptions(map[string]string{key: value}, false, "")
|
||||
return err
|
||||
}
|
||||
if IsModelPricingOption(key) {
|
||||
return UpdateModelPricingOptions(map[string]string{key: value})
|
||||
}
|
||||
@@ -256,11 +278,37 @@ func UpdateOptionsBulk(values map[string]string) error {
|
||||
if len(values) == 0 {
|
||||
return nil
|
||||
}
|
||||
for key := range values {
|
||||
if IsPasskeyDomainOption(key) {
|
||||
_, err := UpdatePasskeyDomainOptions(values, false, "")
|
||||
return err
|
||||
}
|
||||
}
|
||||
for key, value := range values {
|
||||
if err := validateOptionValue(key, value); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var policySnapshot *RequestPolicySnapshot
|
||||
for key := range values {
|
||||
if IsRequestPolicyOption(key) {
|
||||
requestPolicyOptionMutex.Lock()
|
||||
defer requestPolicyOptionMutex.Unlock()
|
||||
options := maps.Clone(CurrentRequestPolicy().Options)
|
||||
for key, value := range values {
|
||||
if IsRequestPolicyOption(key) {
|
||||
options[key] = value
|
||||
}
|
||||
}
|
||||
var err error
|
||||
policySnapshot, err = BuildRequestPolicy(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err := DB.Transaction(func(tx *gorm.DB) error {
|
||||
for k, v := range values {
|
||||
option := Option{Key: k}
|
||||
@@ -282,6 +330,9 @@ func UpdateOptionsBulk(values map[string]string) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if policySnapshot != nil {
|
||||
requestPolicySnapshot.Store(policySnapshot)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user