driver: cache features

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
pull/1846/head
CrazyMax 2 years ago
parent 9b723ece46
commit d196ac347e
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7

@ -147,9 +147,11 @@ func GetFactories(instanceRequired bool) []Factory {
type cachedDriver struct {
Driver
client *client.Client
err error
once sync.Once
client *client.Client
err error
once sync.Once
featuresOnce sync.Once
features map[Feature]bool
}
func (d *cachedDriver) Client(ctx context.Context) (*client.Client, error) {
@ -158,3 +160,10 @@ func (d *cachedDriver) Client(ctx context.Context) (*client.Client, error) {
})
return d.client, d.err
}
func (d *cachedDriver) Features() map[Feature]bool {
d.featuresOnce.Do(func() {
d.features = d.Driver.Features()
})
return d.features
}

Loading…
Cancel
Save