factory

package
v0.0.0-...-51a0f74 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

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

Factory provides a mechanism for building various type of proxy based on their unique type key. This is primarily developed for use when serialising proxy connection information to and from yaml files for Juju.

func NewDefaultFactory

func NewDefaultFactory() (*Factory, error)

NewDefaultFactory constructs a factory with all the known proxy implementations in juju registered.

func NewFactory

func NewFactory() *Factory

NewFactory creates a new empty factory

func (*Factory) MakerForTypeKey

func (f *Factory) MakerForTypeKey(typeKey string) (*FactoryMaker, error)

MakerForTypeKey provides a new factory maker for the given type key if one has been registered.

func (*Factory) ProxierFromConfig

func (f *Factory) ProxierFromConfig(typeKey string, config map[string]interface{}) (proxy.Proxier, error)

ProxierFromConfig is a utility function for making a proxier from this factory using raw config data within in a map[string]interface{}. The type key cannot be an empty string.

func (*Factory) Register

func (f *Factory) Register(typeKey string, register FactoryRegister) error

Register registers a new proxier type and creationg methods to this factory

type FactoryMaker

type FactoryMaker struct {
	RawConfig interface{}
	Register  FactoryRegister
}

FactoryMaker is shell object used for facilitating the making of a proxy object

func (*FactoryMaker) Config

func (f *FactoryMaker) Config() interface{}

Config returns a raw config for a given proxy type that can be used to unmarshal against.

func (*FactoryMaker) Make

func (f *FactoryMaker) Make() (proxy.Proxier, error)

Make attempts to make the proxy from the filled config.

type FactoryRegister

type FactoryRegister struct {
	ConfigFn func() interface{}
	MakerFn  func(interface{}) (proxy.Proxier, error)
}

FactoryRegister describe registration details for building a new proxy.

Jump to

Keyboard shortcuts

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