Documentation
¶
Overview ¶
Package middleware provides decorators for backend implementations, including logging and latency simulation.
Index ¶
- Variables
- type BackendLogger
- func (b BackendLogger) Delete(ctx context.Context, path string) error
- func (b BackendLogger) DeleteIf(ctx context.Context, path string, expected backend.Version) error
- func (b BackendLogger) GetMetadata(ctx context.Context, path string) (backend.Metadata, error)
- func (b BackendLogger) List(ctx context.Context, dirPath string) (backend.ListIter, error)
- func (b BackendLogger) Read(ctx context.Context, path string) (backend.ReadReply, error)
- func (b BackendLogger) ReadIfModified(ctx context.Context, path string, version int64) (backend.ReadReply, error)
- func (b BackendLogger) SetTagsIf(ctx context.Context, path string, expected backend.Version, t backend.Tags) (backend.Metadata, error)
- func (b BackendLogger) Write(ctx context.Context, path string, value []byte, t backend.Tags) (backend.Metadata, error)
- func (b BackendLogger) WriteIf(ctx context.Context, path string, value []byte, expected backend.Version, ...) (backend.Metadata, error)
- func (b BackendLogger) WriteIfNotExists(ctx context.Context, path string, value []byte, t backend.Tags) (backend.Metadata, error)
- type DelayBackend
- func (b *DelayBackend) Delete(ctx context.Context, path string) error
- func (b *DelayBackend) DeleteIf(ctx context.Context, path string, expected backend.Version) error
- func (b *DelayBackend) GetMetadata(ctx context.Context, path string) (backend.Metadata, error)
- func (b *DelayBackend) List(ctx context.Context, dirPath string) (backend.ListIter, error)
- func (b *DelayBackend) Read(ctx context.Context, path string) (backend.ReadReply, error)
- func (b *DelayBackend) ReadIfModified(ctx context.Context, path string, version int64) (backend.ReadReply, error)
- func (b *DelayBackend) SetTagsIf(ctx context.Context, path string, expected backend.Version, t backend.Tags) (backend.Metadata, error)
- func (b *DelayBackend) Write(ctx context.Context, path string, value []byte, t backend.Tags) (backend.Metadata, error)
- func (b *DelayBackend) WriteIf(ctx context.Context, path string, value []byte, expected backend.Version, ...) (backend.Metadata, error)
- func (b *DelayBackend) WriteIfNotExists(ctx context.Context, path string, value []byte, t backend.Tags) (backend.Metadata, error)
- type DelayOptions
- type Latency
Constants ¶
This section is empty.
Variables ¶
var GCSDelays = DelayOptions{ MetaRead: Latency{22 * time.Millisecond, 7 * time.Millisecond}, MetaWrite: Latency{31 * time.Millisecond, 8 * time.Millisecond}, ObjRead: Latency{57 * time.Millisecond, 7 * time.Millisecond}, ObjWrite: Latency{70 * time.Millisecond, 15 * time.Millisecond}, List: Latency{10 * time.Millisecond, 3 * time.Millisecond}, SameObjWritePs: 1, }
GCSDelays contains typical latency values observed with Google Cloud Storage.
Functions ¶
This section is empty.
Types ¶
type BackendLogger ¶
type BackendLogger struct {
// contains filtered or unexported fields
}
BackendLogger is a backend.Backend decorator that logs all operations.
func NewBackendLogger ¶
NewBackendLogger creates a BackendLogger that wraps inner with debug logging.
func (BackendLogger) Delete ¶
func (b BackendLogger) Delete(ctx context.Context, path string) error
Delete implements backend.Backend.
func (BackendLogger) DeleteIf ¶
func (b BackendLogger) DeleteIf( ctx context.Context, path string, expected backend.Version, ) error
DeleteIf implements backend.Backend.
func (BackendLogger) GetMetadata ¶
GetMetadata implements backend.Backend.
func (BackendLogger) ReadIfModified ¶
func (b BackendLogger) ReadIfModified( ctx context.Context, path string, version int64, ) (backend.ReadReply, error)
ReadIfModified implements backend.Backend.
func (BackendLogger) SetTagsIf ¶
func (b BackendLogger) SetTagsIf( ctx context.Context, path string, expected backend.Version, t backend.Tags, ) (backend.Metadata, error)
SetTagsIf implements backend.Backend.
type DelayBackend ¶
type DelayBackend struct {
// contains filtered or unexported fields
}
DelayBackend is a backend.Backend decorator that simulates network latency and per-object write rate limiting.
func NewDelayBackend ¶
func NewDelayBackend( inner backend.Backend, clock clockwork.Clock, opts DelayOptions, ) *DelayBackend
NewDelayBackend creates a DelayBackend that adds simulated latency to backend operations.
func (*DelayBackend) Delete ¶
func (b *DelayBackend) Delete(ctx context.Context, path string) error
Delete implements backend.Backend.
func (*DelayBackend) DeleteIf ¶
func (b *DelayBackend) DeleteIf( ctx context.Context, path string, expected backend.Version, ) error
DeleteIf implements backend.Backend.
func (*DelayBackend) GetMetadata ¶
GetMetadata implements backend.Backend.
func (*DelayBackend) ReadIfModified ¶
func (b *DelayBackend) ReadIfModified( ctx context.Context, path string, version int64, ) (backend.ReadReply, error)
ReadIfModified implements backend.Backend.
func (*DelayBackend) SetTagsIf ¶
func (b *DelayBackend) SetTagsIf( ctx context.Context, path string, expected backend.Version, t backend.Tags, ) (backend.Metadata, error)
SetTagsIf implements backend.Backend.
type DelayOptions ¶
type DelayOptions struct {
MetaRead Latency
MetaWrite Latency
ObjRead Latency
ObjWrite Latency
List Latency
// How many writes per second to the same object before being
// rate limited?
SameObjWritePs int
}
DelayOptions configures simulated latency for each type of backend operation.