Skip to content

Commit

Permalink
feat(store): update plugin api
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed Aug 31, 2023
1 parent 91e5e3b commit caeb4ac
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions manager-plugin/objstore/objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,30 @@ type Store interface {
// InstanceInfo returns the information of this store.
InstanceInfo(ctx context.Context) (InstanceInfo, error)

// Get returns an io.ReadCloser object for reading the file corresponding to the fullPath from this store.
Get(ctx context.Context, fullPath string) (io.ReadCloser, error)
// Del removes the file corresponding to given path from this store
Del(ctx context.Context, fullPath string) error
// Stat returns a Stat describing the file corresponding to given path
Stat(ctx context.Context, fullPath string) (Stat, error)
// Put copies from src to dstPath until either EOF is reached
// Get returns an io.ReadCloser object for reading the file corresponding to the resourceName from this store.
// the resourceName value looks like this:
// - "cache/sc-02-data-tree-r-last.dat"
Get(ctx context.Context, resourceName string) (io.ReadCloser, error)
// Del removes the file corresponding to given resourceName from this store
Del(ctx context.Context, resourceName string) error
// Stat returns a Stat describing the file corresponding to given resourceName
Stat(ctx context.Context, resourceName string) (Stat, error)
// Put copies from src to destResourceName until either EOF is reached
// on src or an error occurs.
// It returns the number of bytes copied.
Put(ctx context.Context, dstFullPath string, src io.Reader) (int64, error)
Put(ctx context.Context, destResourceName string, src io.Reader) (int64, error)

// FullPath returns the full path of the given relative path.
// Uri returns the uri corresponding to the given resourceName in this store.
//
// Example:
// ```go
// assert(FullPath(context.TODO(), "cache/s-t04040-1001") == "depends_on_your_store/cache/s-t04040-1001")
// assert(Uri(context.TODO(), "cache/s-t04040-1001") == "/path/to/my_prefix/cache/s-t04040-1001")
// assert(Uri(context.TODO(), "cache/s-t04040-1001") == "/path/to/3777f34f2e99477b512a7a4507318f72")
// ...
// ```
//
// Example(for filesystem):
// ```go
// assert(FullPath(context.TODO(), "cache/s-t04040-1001") == "/path/to/your_store_dir/cache/s-t04040-1001")
// assert(Uri(context.TODO(), "cache/s-t04040-1001") == "/path/to/my_store_dir/cache/s-t04040-1001")
// ```
FullPath(ctx context.Context, relPath string) string
Uri(ctx context.Context, resourceName string) (string, error)
}

0 comments on commit caeb4ac

Please sign in to comment.