diff --git a/pkg/storage/inheritable.go b/pkg/storage/inheritable.go index 9d6e067..94f6915 100644 --- a/pkg/storage/inheritable.go +++ b/pkg/storage/inheritable.go @@ -20,6 +20,7 @@ var ( _ Storage = (*InheritableStorage)(nil) ) +// NewInheritableStorage returns a InheritableStorage with the source Storage func NewInheritableStorage(source Storage) (Storage, error) { return &InheritableStorage{ source: source, diff --git a/pkg/storage/storage.go b/pkg/storage/storage.go index 4d7b8bc..7dfdf18 100644 --- a/pkg/storage/storage.go +++ b/pkg/storage/storage.go @@ -13,23 +13,32 @@ type StorageEntry struct { } type Storage interface { + // Get retrieves the entry by key from the underlying storage Get(ctx context.Context, key string) (*StorageEntry, error) + // Put adds the entry to the underlying storage Put(ctx context.Context, e StorageEntry) error + // Delete removes the entry by key from the underlying storage Delete(ctx context.Context, key string) error + // List returns a slice of paths at the specified prefix List(ctx context.Context, prefix string) ([]string, error) } +// StorageCreator is a factory function to be used for all storage types type StorageCreator func(conf map[string]string) (Storage, error) +// StorageOptions is a map of available storage options specified at the server.storage config path var StorageOptions = map[string]StorageCreator{ "file": NewFileStorage, "bigcache": NewBigCacheStorage, "cacheable": NewCacheableStorageWithConf, + "gcs": NewGCSStorage, } +// CacheableStorageOptions is a map of available storage options specified at the server.options.cache config path var CacheableStorageOptions = map[string]StorageCreator{ "file": NewFileStorage, "bigcache": NewBigCacheStorage, + "gcs": NewGCSStorage, } func ValidatePath(path string) error {