Documentation ¶
Index ¶
- func Background() types.Context
- func Client(ctx context.Context) (types.Client, bool)
- func CustomHeaderKeys() <-chan interface{}
- func CustomLoggerKeys() <-chan interface{}
- func Driver(ctx context.Context) (types.StorageDriver, bool)
- func GetLogLevel(ctx context.Context) (log.Level, bool)
- func InstanceID(ctx context.Context) (*types.InstanceID, bool)
- func Join(left types.Context, right context.Context) types.Context
- func LocalDevices(ctx context.Context) (*types.LocalDevices, bool)
- func MustClient(ctx context.Context) types.Client
- func MustInstanceID(ctx context.Context) *types.InstanceID
- func MustService(ctx context.Context) types.StorageService
- func MustTransaction(ctx context.Context) *types.Transaction
- func Profile(ctx context.Context) (string, bool)
- func RegisterCustomKey(key interface{}, mask CustomKeyTypes) error
- func RequireTX(ctx context.Context) types.Context
- func Route(ctx context.Context) (types.Route, bool)
- func Server(ctx context.Context) (string, bool)
- func Service(ctx context.Context) (types.StorageService, bool)
- func ServiceName(ctx context.Context) (string, bool)
- func SetLogLevel(ctx context.Context, lvl log.Level)
- func Transaction(ctx context.Context) (*types.Transaction, bool)
- func Value(ctx context.Context, key interface{}) interface{}
- func WithRequestRoute(parent context.Context, req *http.Request, route types.Route) types.Context
- func WithStorageService(parent context.Context, service types.StorageService) types.Context
- func WithValue(ctx context.Context, key, val interface{}) types.Context
- type CustomKeyTypes
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Background ¶
Background returns a new context with logging capabilities.
func Client ¶
Client returns the context's Client. This value is only valid for contexts created on the client.
func CustomHeaderKeys ¶
func CustomHeaderKeys() <-chan interface{}
CustomHeaderKeys returns a channel on which can be received all the registered, custom header keys.
func CustomLoggerKeys ¶
func CustomLoggerKeys() <-chan interface{}
CustomLoggerKeys returns a channel on which can be received all the registered, custom logger keys.
func Driver ¶
func Driver(ctx context.Context) (types.StorageDriver, bool)
Driver returns the context's storage driver. This value is valid only on the server and subject to the same restrictions as listed in the Service function.
func GetLogLevel ¶
GetLogLevel gets the context's log level.
func InstanceID ¶
func InstanceID(ctx context.Context) (*types.InstanceID, bool)
InstanceID returns the context's InstanceID. This value is valid on both the client and the server.
func Join ¶
Join joins this context with another, such that value lookups will first first check the current context, and if no such value exist, a lookup will be performed against the right side.
func LocalDevices ¶
func LocalDevices(ctx context.Context) (*types.LocalDevices, bool)
LocalDevices returns the context's local devices map. This value is valid on both the client and the server.
func MustClient ¶
MustClient returns the context's Client and panics if the client is not available and/or not castable..
func MustInstanceID ¶
func MustInstanceID(ctx context.Context) *types.InstanceID
MustInstanceID returns the context's InstanceID and panics if it does not exist and/or cannot be type cast.
func MustService ¶
func MustService(ctx context.Context) types.StorageService
MustService returns the context's StorageService and panics if it does not exist and/or cannot be type cast.
func MustTransaction ¶
func MustTransaction(ctx context.Context) *types.Transaction
MustTransaction returns the context's Transaction and will panic if the value is missing or not castable.
func Profile ¶
Profile returns the context's profile. This value is only valid for contexts created on the server after the profile handler has been executred.
func RegisterCustomKey ¶
func RegisterCustomKey(key interface{}, mask CustomKeyTypes) error
RegisterCustomKey registers a custom key with the context package.
func RequireTX ¶
RequireTX ensures a context has a transaction, and if it doesn't creates a new one.
func Route ¶
Route returns the context's route. This value is only valid for contexts created on the server after a mux has received an incoming HTTP request. Any part of the libStorage workflow after that, including the handlers, routers, and storage drivers, should have access to the Route.
func Server ¶
Server returns the context's server name. This value is valid on both the client and the server.
func Service ¶
func Service(ctx context.Context) (types.StorageService, bool)
Service returns the context's storage service. This value is valid only for contexts created on the server. The value is only available after the service has been injected as part of the ServiceValidator handler or by one of the routes that injects it manually such as Volumes or Snapshots.
func ServiceName ¶
ServiceName returns the context's service name. This value is valid for contexts created on both the client and the server. On the server this value is subject to the same restrictions as listed in the Service function.
func SetLogLevel ¶
SetLogLevel sets the context's log level.
func Transaction ¶
func Transaction(ctx context.Context) (*types.Transaction, bool)
Transaction returns the context's Transaction. This value is valid on both the client and the server.
func Value ¶
Value returns the value associated with this context for key, or nil if no value is associated with key. Successive calls to Value with the same key returns the same result.
func WithRequestRoute ¶
WithRequestRoute returns a new context with the injected *http.Request and Route.
func WithStorageService ¶
WithStorageService returns a new context with the StorageService as the value and attempts to assign the service's associated InstanceID and LocalDevices (by way of the service's StorageDriver) to the context as well.
Types ¶
type CustomKeyTypes ¶
type CustomKeyTypes int
CustomKeyTypes is a bitmask used when registering a custom key with the context at runtime.
const ( // CustomLoggerKey indicates a value set for this key should be logged as // a member of a log entry's fields collection when using the context's // structured logger. CustomLoggerKey CustomKeyTypes = 1 << iota // CustomHeaderKey indicates a value set for this key should be sent along // with HTTP requests as an HTTP header. CustomHeaderKey )
type Key ¶
type Key int
Key is the type used as a context key.
const ( // LoggerKey is a context key. LoggerKey Key // HTTPRequestKey is a context key. HTTPRequestKey // AllInstanceIDsKey is the key for the map[string]*types.InstanceID value // that maps all drivers to their instance IDs. AllInstanceIDsKey // LocalDevicesKey is a context key. LocalDevicesKey // AllLocalDevicesKey is the key for the map[string]*types.LocalDevices // value that maps all drivers to their instance IDs. AllLocalDevicesKey // ClientKey is a context key. ClientKey // TaskKey is a context key. TaskKey // InstanceIDKey is a context key. InstanceIDKey // ProfileKey is a context key. ProfileKey // RouteKey is a context key. RouteKey // ServerKey is a context key. ServerKey // ServiceKey is an alias for StorageService. ServiceKey // StorageServiceKey is a context key. StorageServiceKey // TransactionKey is a context key. TransactionKey // DriverKey is an alias for StorageDriver. DriverKey // UserKey is a context key. UserKey // HostKey is a context key. HostKey // TLSKey is a context key. TLSKey )