forked from haproxytech/client-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
45 lines (38 loc) · 1.14 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package clientnative
import (
"context"
"github.com/haproxytech/client-native/v6/configuration"
"github.com/haproxytech/client-native/v6/options"
"github.com/haproxytech/client-native/v6/runtime"
"github.com/haproxytech/client-native/v6/spoe"
"github.com/haproxytech/client-native/v6/storage"
)
type HAProxyClient interface {
Configuration() (configuration.Configuration, error)
Runtime() (runtime.Runtime, error)
ReplaceConfiguration(configurationClient configuration.Configuration)
ReplaceRuntime(runtimeClient runtime.Runtime)
MapStorage() (storage.Storage, error)
SSLCertStorage() (storage.Storage, error)
GeneralStorage() (storage.Storage, error)
Spoe() (spoe.Spoe, error)
}
func New(ctx context.Context, opt ...options.Option) (HAProxyClient, error) { //nolint:revive
o := options.Options{}
var err error
for _, option := range opt {
err = option.Set(&o)
if err != nil {
return nil, err
}
}
c := &haProxyClient{
configuration: o.Configuration,
runtime: o.Runtime,
mapStorage: o.MapStorage,
sslCertStorage: o.SSLCertStorage,
generalStorage: o.GeneralStorage,
spoe: o.Spoe,
}
return c, nil
}