Documentation ¶
Index ¶
- func AuthToken(ctx context.Context) (*types.AuthToken, bool)
- 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 MustAuthToken(ctx context.Context) *types.AuthToken
- func MustClient(ctx context.Context) types.Client
- func MustDriver(ctx context.Context) types.StorageDriver
- func MustInstanceID(ctx context.Context) *types.InstanceID
- func MustPathConfig(ctx context.Context) *types.PathConfig
- func MustService(ctx context.Context) types.StorageService
- func MustSession(ctx context.Context) interface{}
- func MustTransaction(ctx context.Context) *types.Transaction
- func New(parent context.Context) types.Context
- func PathConfig(ctx context.Context) (*types.PathConfig, bool)
- func Profile(ctx context.Context) (string, bool)
- func RegisterCustomKey(key interface{}, mask CustomKeyTypes) error
- func RegisterCustomKeyWithContext(ctx types.Context, 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 Session(ctx context.Context) (interface{}, 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 WithStorageSession(parent context.Context) (types.Context, error)
- 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 AuthToken ¶ added in v0.6.0
AuthToken returns the context's security token. This value is valid on both the client and the server.
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 MustAuthToken ¶ added in v0.6.0
MustAuthToken returns the context's security token and panics if it does not exist and/or cannot be type cast.
func MustClient ¶
MustClient returns the context's Client and panics if the client is not available and/or not castable..
func MustDriver ¶ added in v0.3.0
func MustDriver(ctx context.Context) types.StorageDriver
MustDriver returns the context's storage driver or panics if no driver exists.
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 MustPathConfig ¶ added in v0.6.0
func MustPathConfig(ctx context.Context) *types.PathConfig
MustPathConfig returns the context's path config 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 MustSession ¶ added in v0.3.0
MustSession returns the context's session object and panics if a session does not exist.
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 PathConfig ¶ added in v0.6.0
func PathConfig(ctx context.Context) (*types.PathConfig, bool)
PathConfig returns the context's path config. This value is valid on both the client and the server.
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 RegisterCustomKeyWithContext ¶ added in v0.6.0
func RegisterCustomKeyWithContext( ctx types.Context, key interface{}, mask CustomKeyTypes) error
RegisterCustomKeyWithContext 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 Session ¶ added in v0.3.0
Session returns the context's session object. This value is valid only on the server.
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.
func WithStorageSession ¶ added in v0.3.0
WithStorageSession returns a context that is logged into the storage platform.
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 ( // PathConfigKey is a context key. PathConfigKey Key // LoggerKey is a context key. LoggerKey // 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 // AdminTokenKey is the key for the server's admin token. AdminTokenKey // SessionKey is the key for the storage driver's session. SessionKey // EncodedAuthTokenKey is the key for an encoded authentication token. EncodedAuthTokenKey // AuthTokenKey is a context key. AuthTokenKey // 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 )