factory

package
v2.6.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2017 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(name string, parameters map[string]interface{}) (storagedriver.StorageDriver, error)

Create a new storagedriver.StorageDriver with the given name and parameters. To use a driver, the StorageDriverFactory must first be registered with the given name. If no drivers are found, an InvalidStorageDriverError is returned

func Register

func Register(name string, factory StorageDriverFactory)

Register makes a storage driver available by the provided name. If Register is called twice with the same name or if driver factory is nil, it panics. Additionally, it is not concurrency safe. Most Storage Drivers call this function in their init() functions. See the documentation for StorageDriverFactory for more.

Types

type InvalidStorageDriverError

type InvalidStorageDriverError struct {
	Name string
}

InvalidStorageDriverError records an attempt to construct an unregistered storage driver

func (InvalidStorageDriverError) Error

func (err InvalidStorageDriverError) Error() string

type StorageDriverFactory

type StorageDriverFactory interface {
	// Create returns a new storagedriver.StorageDriver with the given parameters
	// Parameters will vary by driver and may be ignored
	// Each parameter key must only consist of lowercase letters and numbers
	Create(parameters map[string]interface{}) (storagedriver.StorageDriver, error)
}

StorageDriverFactory is a factory interface for creating storagedriver.StorageDriver interfaces Storage drivers should call Register() with a factory to make the driver available by name. Individual StorageDriver implementations generally register with the factory via the Register func (below) in their init() funcs, and as such they should be imported anonymously before use. See below for an example of how to register and get a StorageDriver for S3

import _ "github.com/docker/distribution/registry/storage/driver/s3-aws"
s3Driver, err = factory.Create("s3", storageParams)
// assuming no error, s3Driver is the StorageDriver that communicates with S3 according to storageParams

Jump to

Keyboard shortcuts

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