Skip to content

Commit

Permalink
add some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
steviebps committed Sep 15, 2023
1 parent 8866bfc commit efbb849
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/storage/inheritable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit efbb849

Please sign in to comment.