provider

package
v1.2.3-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainedProvider

type ChainedProvider[Value Providable] struct {
	Providers []Provider[Value]
}

ChainedProvider tries multiple different providers when trying to retrieve a certain value.

func (*ChainedProvider[Value]) Get

func (c *ChainedProvider[Value]) Get(ctx context.Context, key string) (v Value, err error)

func (*ChainedProvider[Value]) Has

func (c *ChainedProvider[Value]) Has(ctx context.Context, key string) bool

func (*ChainedProvider[Value]) Keys

func (c *ChainedProvider[Value]) Keys(ctx context.Context) (keys []string)

type ConfiguredProvider

type ConfiguredProvider[Value Providable] struct {
	// contains filtered or unexported fields
}

ConfiguredProvider prevents access to certain values based on a passed in block-list of types. It appears as if the disabled types are not installed.

func (*ConfiguredProvider[Value]) Get

func (c *ConfiguredProvider[Value]) Get(ctx context.Context, key string) (v Value, err error)

func (*ConfiguredProvider[Value]) Has

func (c *ConfiguredProvider[Value]) Has(ctx context.Context, key string) bool

func (*ConfiguredProvider[Value]) Keys

func (c *ConfiguredProvider[Value]) Keys(ctx context.Context) (keys []string)

type MappedProvider

type MappedProvider[Value Providable] struct {
	// contains filtered or unexported fields
}

A MappedProvider is a Provider that stores the providables in a simple map, and caches permanently the results of checking installation status

func NewMappedProvider

func NewMappedProvider[Value Providable](providables map[string]Value) *MappedProvider[Value]

func (*MappedProvider[Value]) Add

func (provider *MappedProvider[Value]) Add(key string, value Value)

func (*MappedProvider[Value]) Get

func (provider *MappedProvider[Value]) Get(ctx context.Context, key string) (v Value, err error)

Get implements Provider

func (*MappedProvider[Value]) Has

func (provider *MappedProvider[Value]) Has(ctx context.Context, key string) bool

Has implements Provider

func (*MappedProvider[Value]) Keys

func (provider *MappedProvider[Value]) Keys(ctx context.Context) (keys []string)

type NoopProvider

type NoopProvider[Value Providable] struct {
	// contains filtered or unexported fields
}

A NoopProvider is a provider that always returns a noop providable regardless of the key

func (*NoopProvider[Value]) Get

func (p *NoopProvider[Value]) Get(ctx context.Context, key string) (v Value, err error)

Get implements Provider

func (*NoopProvider[Value]) Has

func (p *NoopProvider[Value]) Has(ctx context.Context, key string) bool

Has implements Provider

func (*NoopProvider[Value]) Keys

func (p *NoopProvider[Value]) Keys(context.Context) []string

Keys implements Provider

type Providable

type Providable interface {
	IsInstalled(context.Context) (bool, error)
}

A Providable is something that a Provider can check for installation status

type Provider

type Provider[Value Providable] interface {
	// Get returns the object with the given key
	Get(context.Context, string) (Value, error)
	// Has returns true if the provider can provide the object with the given key
	Has(context.Context, string) bool
	// Keys returns the keys of the objects that the provider can provide
	Keys(context.Context) []string
}

A Provider is an object which is configured to provide certain objects and will check their installation status before providing them

func NewConfiguredProvider

func NewConfiguredProvider[Value Providable](inner Provider[Value], disabled []string) Provider[Value]

func NewNoopProvider

func NewNoopProvider[Value Providable](providable Value) Provider[Value]

func NewSingletonProvider

func NewSingletonProvider[Value Providable](key string, providable Value) Provider[Value]

type SingletonProvider

type SingletonProvider[Value Providable] struct {
	// contains filtered or unexported fields
}

A SingletonProvider is a provider that always returns a singleton providable

func (*SingletonProvider[Value]) Get

func (p *SingletonProvider[Value]) Get(ctx context.Context, key string) (v Value, err error)

Get implements Provider

func (*SingletonProvider[Value]) Has

func (p *SingletonProvider[Value]) Has(ctx context.Context, key string) bool

Has implements Provider

func (*SingletonProvider[Value]) Keys

func (p *SingletonProvider[Value]) Keys(context.Context) []string

Keys implements Provider

Jump to

Keyboard shortcuts

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