provider

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MsgMissingProvider         = "provider '%s' required"
	MsgUnsupportedProviderType = "unsupported provider type '%d'"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GenericProvider

type GenericProvider interface {
	Close() error
}

type InstanceProviderFunc

type InstanceProviderFunc func() interface{}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...ProviderConfig) (*Provider, error)

New creates a new provider instance and configures it with provider implementations

func (*Provider) Close

func (p *Provider) Close() bool

Close iterates over all registered ProviderConfigs and asks them to 'close'

func (*Provider) Find

func (p *Provider) Find(providerType ProviderType) (interface{}, bool)

Find returns the registered provider instance if defined. The bool flag is set to true if there is a provider and false otherwise.

func (*Provider) RegisterProviders

func (p *Provider) RegisterProviders(ignoreExists bool, opts ...ProviderConfig) error

RegisterProviders registers one or more providers. An existing provider will be overwritten if ignoreExists is true, otherwise the function returns an error.

type ProviderConfig

type ProviderConfig struct {
	ID   string
	Type ProviderType
	Impl InstanceProviderFunc
}

func WithProvider

func WithProvider(ID string, providerType ProviderType, impl InstanceProviderFunc) ProviderConfig

WithProvider returns a populated ProviderConfig struct.

type ProviderType

type ProviderType int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL