mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-24 04:25:00 +00:00
feat: make initializer accept gRPC delay times (#900)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
7ffd21dbc8
commit
0ec695f9e4
7 changed files with 60 additions and 4 deletions
|
@ -16,6 +16,9 @@ type Options struct {
|
|||
gRPCOptions *pb.ModelOptions
|
||||
|
||||
externalBackends map[string]string
|
||||
|
||||
grpcAttempts int
|
||||
grpcAttemptsDelay int
|
||||
}
|
||||
|
||||
type Option func(*Options)
|
||||
|
@ -29,6 +32,18 @@ func WithExternalBackend(name string, uri string) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithGRPCAttempts(attempts int) Option {
|
||||
return func(o *Options) {
|
||||
o.grpcAttempts = attempts
|
||||
}
|
||||
}
|
||||
|
||||
func WithGRPCAttemptsDelay(delay int) Option {
|
||||
return func(o *Options) {
|
||||
o.grpcAttemptsDelay = delay
|
||||
}
|
||||
}
|
||||
|
||||
func WithBackendString(backend string) Option {
|
||||
return func(o *Options) {
|
||||
o.backendString = backend
|
||||
|
@ -67,8 +82,10 @@ func WithContext(ctx context.Context) Option {
|
|||
|
||||
func NewOptions(opts ...Option) *Options {
|
||||
o := &Options{
|
||||
gRPCOptions: &pb.ModelOptions{},
|
||||
context: context.Background(),
|
||||
gRPCOptions: &pb.ModelOptions{},
|
||||
context: context.Background(),
|
||||
grpcAttempts: 20,
|
||||
grpcAttemptsDelay: 2,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue