1package physical 2 3import ( 4 "context" 5) 6 7// PhysicalAccess is a wrapper around physical.Backend that allows Core to 8// expose its physical storage operations through PhysicalAccess() while 9// restricting the ability to modify Core.physical itself. 10type PhysicalAccess struct { 11 physical Backend 12} 13 14var _ Backend = (*PhysicalAccess)(nil) 15 16func NewPhysicalAccess(physical Backend) *PhysicalAccess { 17 return &PhysicalAccess{physical: physical} 18} 19 20func (p *PhysicalAccess) Put(ctx context.Context, entry *Entry) error { 21 return p.physical.Put(ctx, entry) 22} 23 24func (p *PhysicalAccess) Get(ctx context.Context, key string) (*Entry, error) { 25 return p.physical.Get(ctx, key) 26} 27 28func (p *PhysicalAccess) Delete(ctx context.Context, key string) error { 29 return p.physical.Delete(ctx, key) 30} 31 32func (p *PhysicalAccess) List(ctx context.Context, prefix string) ([]string, error) { 33 return p.physical.List(ctx, prefix) 34} 35 36func (p *PhysicalAccess) Purge(ctx context.Context) { 37 if purgeable, ok := p.physical.(ToggleablePurgemonster); ok { 38 purgeable.Purge(ctx) 39 } 40} 41