Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gateway): add gateway specific config using x-ms-config header
Gatewaty specific config can be added using header by passing a stringify json For ex. x-ms-config: {retry: { times: 2 }}
- Loading branch information
Showing
4 changed files
with
96 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package schema | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type CacheConfig struct { | ||
// Mode specifies the type of cache with two possible modes: simple and semantic. | ||
Mode string `json:"mode" default:"simple"` | ||
// TTL (Time To Live) is the duration for which cache entries should be considered valid. | ||
TTL time.Duration `json:"ttl"` | ||
} | ||
|
||
type RetryConfig struct { | ||
Times int32 `json:"times" default:"1"` | ||
// Status codes for retry | ||
OnStatusCodes []string `json:"on_status_codes"` | ||
} | ||
|
||
type StrategyConfig struct { | ||
Mode string `json:"mode" default:"fallback"` | ||
// Status codes for retry | ||
OnStatusCodes []string `json:"on_status_codes"` | ||
} | ||
|
||
type GatewayConfigHeaders struct { | ||
// Virtual key is temporary key with configurations for the gateway | ||
Provider string `json:"provider"` | ||
VirtualKey string `json:"virtual_key"` | ||
// Cache represents the cache configuration for the gateway. | ||
Cache CacheConfig `json:"cache"` | ||
Retry RetryConfig `json:"retry"` | ||
Strategy StrategyConfig `json:"strategy"` | ||
Providers []any `json:"providers"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters