feat: allow to preload models before startup via env var or configs (#391)

This commit is contained in:
Ettore Di Giacinto 2023-05-27 09:26:33 +02:00 committed by GitHub
parent 835a20610b
commit 76c881043e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 112 additions and 38 deletions

View file

@ -15,6 +15,8 @@ type Option struct {
debug, disableMessage bool
imageDir string
cors bool
preloadJSONModels string
preloadModelsFromPath string
corsAllowOrigins string
}
@ -53,6 +55,17 @@ func WithContext(ctx context.Context) AppOption {
}
}
func WithYAMLConfigPreload(configFile string) AppOption {
return func(o *Option) {
o.preloadModelsFromPath = configFile
}
}
func WithJSONStringPreload(configFile string) AppOption {
return func(o *Option) {
o.preloadJSONModels = configFile
}
}
func WithConfigFile(configFile string) AppOption {
return func(o *Option) {
o.configFile = configFile