Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decorator ¶
type Decorator interface {
Decorate(v interface{}) interface{}
}
Decorator provides an interface for intercepting object creation within a registry. The single method accepts an registry storage object, such as a Layer, optionally replacing it upon with an alternative object or a wrapper.
For example, if one wants to intercept the instantiation of a layer, an implementation might be as follows:
func (md *DecoratorImplementation) Decorate(v interface{}) interface{} {
switch v := v.(type) {
case Layer:
return wrapLayer(v)
}
// Make sure to return the object or nil if the decorator doesn't require
// replacement.
return v
}
Such a decorator can be used to intercept calls to support implementing complex features outside of the storage package.
Click to show internal directories.
Click to hide internal directories.