Closed
Description
This is a followup to a recent discussion that occurred in #2049.
Between S3/GCS/Azure/BoltDB, there is a lot of duplicated code between our chunk object stores. Specifically the GetChunks
and PutChunks
functions. After #2049, each of these backends supports the follow functions:
type ObjectClient interface {
PutObject(ctx context.Context, objectKey string, object io.ReadSeeker)
GetObject(ctx context.Context, objectKey string) (io.ReadCloser, error)
List(ctx context.Context, prefix string) ([]StorageObject, error)
}
For each of the Object backend stores, the current ObjectClient
interface is implemented using the above functions.
As mentioned in the PR, I propose the following refactor:
- Rename
ObjectClient
toClient
without changing any functionality.Client
is chosen as opposed toChunkClient
since the package name ischunk
- Create a new
ObjectClient
interface that contains the thePutObject
,GetObject
andList
functions - Create a generic implementation of the
Client
that would be built on top of theObjectClient
. This would allow a singleClient
to abstract differences between S3/GCS/AzureBS/BoltDB. It would also allow theObjectClient
to be used to store things other than chunks.DeletePlans
or rule configs for example.