Documentation
¶
Index ¶
- Variables
- func FileNameFromContext(ctx context.Context) string
- func ParseS3URL(s3URL *url.URL) (configOptions []func(*awsconfig.LoadOptions) error, ...)
- func ReadObject(ctx context.Context, fileURL string, opts ...Option) ([]byte, error)
- func StoreTypeFromContext(ctx context.Context) string
- type AzureStore
- func (s *AzureStore) BaseURL() *url.URL
- func (s *AzureStore) Clone(ctx context.Context, opts ...Option) (Store, error)
- func (s *AzureStore) CopyObject(ctx context.Context, src, dest string) error
- func (s *AzureStore) DeleteObject(ctx context.Context, base string) error
- func (s *AzureStore) FileExists(ctx context.Context, base string) (bool, error)
- func (s *AzureStore) ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
- func (s *AzureStore) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
- func (s *AzureStore) ObjectPath(name string) string
- func (s *AzureStore) ObjectURL(name string) string
- func (s *AzureStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
- func (c AzureStore) Overwrite() bool
- func (s *AzureStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) error
- func (s *AzureStore) SetMetadata(ctx context.Context, base string, metadata map[string]string) error
- func (c AzureStore) SetMeter(meter Meter)deprecated
- func (c AzureStore) SetOverwrite(in bool)
- func (s *AzureStore) SubStore(subFolder string) (Store, error)
- func (s *AzureStore) Walk(ctx context.Context, prefix string, f func(filename string) (err error)) error
- func (s *AzureStore) WalkFrom(ctx context.Context, prefix, startingPoint string, ...) error
- func (s *AzureStore) WalkFromTo(ctx context.Context, prefix, startingPoint, exclusiveEndPoint string, ...) error
- func (s *AzureStore) WriteObject(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) (err error)
- type BufferedFileReadCloser
- type Clonable
- type GSStore
- func (s *GSStore) BaseURL() *url.URL
- func (s *GSStore) Clone(ctx context.Context, opts ...Option) (Store, error)
- func (s *GSStore) CopyObject(ctx context.Context, src, dest string) error
- func (s *GSStore) DeleteObject(ctx context.Context, base string) error
- func (s *GSStore) FileExists(ctx context.Context, base string) (bool, error)
- func (s *GSStore) ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
- func (s *GSStore) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
- func (s *GSStore) ObjectPath(name string) string
- func (s *GSStore) ObjectURL(name string) string
- func (s *GSStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
- func (c GSStore) Overwrite() bool
- func (s *GSStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) error
- func (s *GSStore) SetMetadata(ctx context.Context, base string, metadata map[string]string) error
- func (c GSStore) SetMeter(meter Meter)deprecated
- func (c GSStore) SetOverwrite(in bool)
- func (s *GSStore) SubStore(subFolder string) (Store, error)
- func (s *GSStore) Walk(ctx context.Context, prefix string, f func(filename string) (err error)) error
- func (s *GSStore) WalkFrom(ctx context.Context, prefix, startingPoint string, ...) error
- func (s *GSStore) WalkFromTo(ctx context.Context, prefix, startingPoint, exclusiveEndPoint string, ...) error
- func (s *GSStore) WriteObject(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) (err error)
- type GZipReadCloser
- type LocalStore
- func (s *LocalStore) BaseURL() *url.URL
- func (s *LocalStore) Clone(ctx context.Context, opts ...Option) (Store, error)
- func (s *LocalStore) CopyObject(ctx context.Context, src, dest string) error
- func (s *LocalStore) DeleteObject(ctx context.Context, base string) error
- func (s *LocalStore) FileExists(ctx context.Context, base string) (bool, error)
- func (s *LocalStore) ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
- func (s *LocalStore) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
- func (s *LocalStore) ObjectPath(name string) string
- func (s *LocalStore) ObjectURL(name string) string
- func (s *LocalStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
- func (c LocalStore) Overwrite() bool
- func (s *LocalStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) error
- func (s *LocalStore) SetMetadata(ctx context.Context, base string, metadata map[string]string) error
- func (c LocalStore) SetMeter(meter Meter)deprecated
- func (c LocalStore) SetOverwrite(in bool)
- func (s *LocalStore) SubStore(subFolder string) (Store, error)
- func (s *LocalStore) Walk(ctx context.Context, prefix string, f func(filename string) (err error)) error
- func (s *LocalStore) WalkFrom(ctx context.Context, prefix, startingPoint string, ...) error
- func (s *LocalStore) WalkFromTo(ctx context.Context, prefix, startingPoint, exclusiveEndPoint string, ...) error
- func (s *LocalStore) WriteObject(ctx context.Context, base string, reader io.Reader, ...) (err error)
- type MemoryStore
- func (m *MemoryStore) BaseURL() *url.URL
- func (m *MemoryStore) Clone(ctx context.Context, opts ...Option) (Store, error)
- func (m *MemoryStore) CopyObject(_ context.Context, src, dest string) error
- func (m *MemoryStore) DeleteObject(ctx context.Context, base string) error
- func (m *MemoryStore) FileExists(_ context.Context, base string) (bool, error)
- func (m *MemoryStore) ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
- func (m *MemoryStore) ObjectAttributes(_ context.Context, base string) (*ObjectAttributes, error)
- func (m *MemoryStore) ObjectPath(name string) string
- func (m *MemoryStore) ObjectURL(name string) string
- func (m *MemoryStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
- func (c MemoryStore) Overwrite() bool
- func (m *MemoryStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) (err error)
- func (m *MemoryStore) SetMetadata(ctx context.Context, base string, metadata map[string]string) error
- func (c MemoryStore) SetMeter(meter Meter)deprecated
- func (c MemoryStore) SetOverwrite(in bool)
- func (m *MemoryStore) SubStore(subFolder string) (Store, error)
- func (m *MemoryStore) Walk(ctx context.Context, prefix string, f func(filename string) (err error)) error
- func (m *MemoryStore) WalkFrom(_ context.Context, prefix, startingPoint string, ...) error
- func (m *MemoryStore) WalkFromTo(_ context.Context, prefix, startingPoint, exclusiveEndPoint string, ...) error
- func (m *MemoryStore) WriteObject(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) (err error)
- type Meterdeprecated
- type MockStore
- func (s *MockStore) BaseURL() *url.URL
- func (s *MockStore) CopyObject(ctx context.Context, src, dest string) error
- func (s *MockStore) DeleteObject(ctx context.Context, base string) error
- func (s *MockStore) FileExists(ctx context.Context, base string) (bool, error)
- func (s *MockStore) ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
- func (s *MockStore) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
- func (s *MockStore) ObjectPath(base string) string
- func (s *MockStore) ObjectURL(base string) string
- func (s *MockStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
- func (s *MockStore) Overwrite() bool
- func (s *MockStore) PushLocalFile(ctx context.Context, localFile string, toBaseName string) (err error)
- func (s *MockStore) SetFile(name string, content []byte)
- func (s *MockStore) SetMetadata(ctx context.Context, base string, metadata map[string]string) error
- func (_ *MockStore) SetMeter(_ Meter)deprecated
- func (s *MockStore) SetOverwrite(in bool)
- func (s *MockStore) SubStore(subFolder string) (Store, error)
- func (s *MockStore) Walk(ctx context.Context, prefix string, f func(filename string) error) error
- func (s *MockStore) WalkFrom(ctx context.Context, prefix, startingPoint string, ...) error
- func (s *MockStore) WalkFromTo(ctx context.Context, prefix, startingPoint, exclusiveEndPoint string, ...) error
- func (s *MockStore) WriteFiles(toDirectory string) error
- func (s *MockStore) WriteObject(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) (err error)
- type ObjectAttributes
- type Option
- func AllowOverwrite() Option
- func Compression(compressionType string) Option
- func WithCompressedReadCallback(cb func(context.Context, int)) Option
- func WithCompressedWriteCallback(cb func(context.Context, int)) Option
- func WithUncompressedReadCallback(cb func(context.Context, int)) Option
- func WithUncompressedWriteCallback(cb func(context.Context, int)) Option
- type S3Store
- func (s *S3Store) BaseURL() *url.URL
- func (s *S3Store) Clone(ctx context.Context, opts ...Option) (Store, error)
- func (s *S3Store) CopyObject(ctx context.Context, src, dest string) error
- func (s *S3Store) DeleteObject(ctx context.Context, base string) error
- func (s *S3Store) FileExists(ctx context.Context, base string) (bool, error)
- func (s *S3Store) ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
- func (s *S3Store) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
- func (s *S3Store) ObjectPath(name string) string
- func (s *S3Store) ObjectURL(name string) string
- func (s *S3Store) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
- func (c S3Store) Overwrite() bool
- func (s *S3Store) PushLocalFile(ctx context.Context, localFile, toBaseName string) error
- func (s *S3Store) SetMetadata(ctx context.Context, base string, metadata map[string]string) error
- func (c S3Store) SetMeter(meter Meter)deprecated
- func (c S3Store) SetOverwrite(in bool)
- func (s *S3Store) SubStore(subFolder string) (Store, error)
- func (s *S3Store) Walk(ctx context.Context, prefix string, f func(filename string) (err error)) error
- func (s *S3Store) WalkFrom(ctx context.Context, prefix, startingPoint string, ...) error
- func (s *S3Store) WalkFromTo(ctx context.Context, prefix, startingPoint, exclusiveEndPoint string, ...) error
- func (s *S3Store) WriteObject(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) (err error)
- type Store
- func NewDBinStore(baseURL string, opts ...Option) (Store, error)
- func NewJSONLStore(baseURL string, opts ...Option) (Store, error)
- func NewSimpleStore(baseURL string, opts ...Option) (Store, error)
- func NewStore(baseURL, extension, compressionType string, overwrite bool, opts ...Option) (Store, error)
- func NewStoreFromFileURL(fileURL string, opts ...Option) (store Store, filename string, err error)
- func OpenObject(ctx context.Context, fileURL string, opts ...Option) (out io.ReadCloser, store Store, filename string, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrMetadataNotSupported = errors.New("metadata is not supported by local file system store")
var ErrNotFound = errors.New("not found")
var NewStoreFromURL = NewStoreFromFileURL
Deprecated: Use NewStoreFromFileURL
var StopIteration = errors.New("stop iteration")
Functions ¶
func FileNameFromContext ¶
func ParseS3URL ¶
func ReadObject ¶
ReadObject directly reads the giving file URL by parsing the file url, extracting the path and the filename from it, creating the store interface, opening the object directly and returning all this.
This is a shortcut helper function that make it simpler to get store from a single file url.
func StoreTypeFromContext ¶
Types ¶
type AzureStore ¶
type AzureStore struct {
// contains filtered or unexported fields
}
func NewAzureStore ¶
func (*AzureStore) BaseURL ¶
func (s *AzureStore) BaseURL() *url.URL
func (*AzureStore) CopyObject ¶
func (s *AzureStore) CopyObject(ctx context.Context, src, dest string) error
func (*AzureStore) DeleteObject ¶
func (s *AzureStore) DeleteObject(ctx context.Context, base string) error
func (*AzureStore) FileExists ¶
func (*AzureStore) ObjectAttributes ¶
func (s *AzureStore) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
func (*AzureStore) ObjectPath ¶
func (s *AzureStore) ObjectPath(name string) string
func (*AzureStore) ObjectURL ¶
func (s *AzureStore) ObjectURL(name string) string
func (*AzureStore) OpenObject ¶
func (s *AzureStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
func (*AzureStore) PushLocalFile ¶
func (s *AzureStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) error
func (*AzureStore) SetMetadata ¶
func (AzureStore) SetOverwrite ¶
func (c AzureStore) SetOverwrite(in bool)
func (*AzureStore) WalkFromTo ¶
func (*AzureStore) WriteObject ¶
type BufferedFileReadCloser ¶
type BufferedFileReadCloser struct {
// contains filtered or unexported fields
}
func NewBufferedFileReadCloser ¶
func NewBufferedFileReadCloser(file *os.File) *BufferedFileReadCloser
func (*BufferedFileReadCloser) Close ¶
func (readCloser *BufferedFileReadCloser) Close() error
type GSStore ¶
type GSStore struct {
// contains filtered or unexported fields
}
func NewGSStore ¶
func (*GSStore) CopyObject ¶
func (*GSStore) DeleteObject ¶
func (*GSStore) FileExists ¶
func (*GSStore) ObjectAttributes ¶
func (*GSStore) ObjectPath ¶
func (*GSStore) OpenObject ¶
func (*GSStore) PushLocalFile ¶
func (*GSStore) SetMetadata ¶
func (GSStore) SetOverwrite ¶
func (c GSStore) SetOverwrite(in bool)
func (*GSStore) WalkFromTo ¶
type GZipReadCloser ¶
func NewGZipReadCloser ¶
func NewGZipReadCloser(src io.ReadCloser) (*GZipReadCloser, error)
func (*GZipReadCloser) Close ¶
func (g *GZipReadCloser) Close() error
type LocalStore ¶
type LocalStore struct {
// contains filtered or unexported fields
}
func NewLocalStore ¶
func (*LocalStore) BaseURL ¶
func (s *LocalStore) BaseURL() *url.URL
func (*LocalStore) CopyObject ¶
func (s *LocalStore) CopyObject(ctx context.Context, src, dest string) error
func (*LocalStore) DeleteObject ¶
func (s *LocalStore) DeleteObject(ctx context.Context, base string) error
func (*LocalStore) FileExists ¶
func (*LocalStore) ObjectAttributes ¶
func (s *LocalStore) ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
func (*LocalStore) ObjectPath ¶
func (s *LocalStore) ObjectPath(name string) string
func (*LocalStore) ObjectURL ¶
func (s *LocalStore) ObjectURL(name string) string
func (*LocalStore) OpenObject ¶
func (s *LocalStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
func (*LocalStore) PushLocalFile ¶
func (s *LocalStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) error
func (*LocalStore) SetMetadata ¶
func (LocalStore) SetOverwrite ¶
func (c LocalStore) SetOverwrite(in bool)
func (*LocalStore) WalkFromTo ¶
func (*LocalStore) WriteObject ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is a store that keeps all data in memory. Useful for unit testing where a store is required. Work in progress, not all methods are implemented
func NewMemoryStore ¶
func (*MemoryStore) BaseURL ¶
func (m *MemoryStore) BaseURL() *url.URL
func (*MemoryStore) CopyObject ¶
func (m *MemoryStore) CopyObject(_ context.Context, src, dest string) error
func (*MemoryStore) DeleteObject ¶
func (m *MemoryStore) DeleteObject(ctx context.Context, base string) error
func (*MemoryStore) FileExists ¶
func (*MemoryStore) ObjectAttributes ¶
func (m *MemoryStore) ObjectAttributes(_ context.Context, base string) (*ObjectAttributes, error)
func (*MemoryStore) ObjectPath ¶
func (m *MemoryStore) ObjectPath(name string) string
func (*MemoryStore) ObjectURL ¶
func (m *MemoryStore) ObjectURL(name string) string
func (*MemoryStore) OpenObject ¶
func (m *MemoryStore) OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
func (*MemoryStore) PushLocalFile ¶
func (m *MemoryStore) PushLocalFile(ctx context.Context, localFile, toBaseName string) (err error)
func (*MemoryStore) SetMetadata ¶
func (MemoryStore) SetOverwrite ¶
func (c MemoryStore) SetOverwrite(in bool)
func (*MemoryStore) WalkFromTo ¶
func (*MemoryStore) WriteObject ¶
type MockStore ¶
type MockStore struct {
OpenObjectFunc func(ctx context.Context, name string) (out io.ReadCloser, err error)
WriteObjectFunc func(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) error
CopyObjectFunc func(ctx context.Context, src, dest string) error
DeleteObjectFunc func(ctx context.Context, base string) error
FileExistsFunc func(ctx context.Context, base string) (bool, error)
ObjectAttributesFunc func(ctx context.Context, base string) (*ObjectAttributes, error)
SetMetadataFunc func(ctx context.Context, base string, metadata map[string]string) error
ListFilesFunc func(ctx context.Context, prefix string, max int) ([]string, error)
WalkFunc func(ctx context.Context, prefix string, f func(filename string) error) error
WalkFromFunc func(ctx context.Context, prefix, startingPoint string, f func(filename string) error) error
WalkFromToFunc func(ctx context.Context, prefix, startingPoint, exclusiveEndPoint string, f func(filename string) error) error
PushLocalFileFunc func(ctx context.Context, localFile string, toBaseName string) (err error)
Files map[string][]byte
Metadata map[string]map[string]string
// contains filtered or unexported fields
}
func NewMockStore ¶
func (*MockStore) CopyObject ¶
func (*MockStore) DeleteObject ¶
func (*MockStore) FileExists ¶
func (*MockStore) ObjectAttributes ¶
func (*MockStore) ObjectPath ¶
func (*MockStore) OpenObject ¶
func (*MockStore) PushLocalFile ¶
func (*MockStore) SetFile ¶
SetFile sets the content of a file. Set the value "err" to trigger an error when reading this file.
func (*MockStore) SetMetadata ¶
func (*MockStore) SetOverwrite ¶
func (*MockStore) WalkFromTo ¶
func (*MockStore) WriteFiles ¶
WriteFiles dumps currently know file
type ObjectAttributes ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func AllowOverwrite ¶
func AllowOverwrite() Option
AllowOverwrite allow files to be overwritten when already exist at a given location.
func Compression ¶
Compression defines which kind of compression to use when creating the store instance.
Valid `compressionType` values: - <empty> No compression - zstd Use ZSTD compression - gzip Use GZIP compression
func WithCompressedReadCallback ¶
WithCompressedReadCallback allows you to set a callback function that is invoked when a compressed read operation is performed.
func WithCompressedWriteCallback ¶
WithCompressedWriteCallback allows you to set a callback function that is invoked when a compressed write operation is performed.
func WithUncompressedReadCallback ¶
WithUncompressedReadCallback allows you to set a callback function that is invoked when an uncompressed read operation is performed.
type S3Store ¶
type S3Store struct {
// contains filtered or unexported fields
}
func NewS3Store ¶
func (*S3Store) CopyObject ¶
func (*S3Store) DeleteObject ¶
func (*S3Store) FileExists ¶
func (*S3Store) ObjectAttributes ¶
func (*S3Store) ObjectPath ¶
func (*S3Store) OpenObject ¶
func (*S3Store) PushLocalFile ¶
func (*S3Store) SetMetadata ¶
func (S3Store) SetOverwrite ¶
func (c S3Store) SetOverwrite(in bool)
func (*S3Store) WalkFromTo ¶
type Store ¶
type Store interface {
OpenObject(ctx context.Context, name string) (out io.ReadCloser, err error)
FileExists(ctx context.Context, base string) (bool, error)
ObjectPath(base string) string
ObjectURL(base string) string
ObjectAttributes(ctx context.Context, base string) (*ObjectAttributes, error)
SetMetadata(ctx context.Context, base string, metadata map[string]string) error
WriteObject(ctx context.Context, base string, f io.Reader, metadataKeyValues ...string) (err error)
PushLocalFile(ctx context.Context, localFile, toBaseName string) (err error)
CopyObject(ctx context.Context, src, dest string) error
Overwrite() bool
SetOverwrite(enabled bool)
// Walk recursively all files starting with the given prefix within this store. The `f` callback is invoked
// for each file found.
//
// If you return `dstore.StopIteration` from your callback, iteration stops right away and `nil` will
// returned by the `Walk` function. If your callback returns any error, iteration stops right away and
// callback returned error is return by the `Walk` function.
Walk(ctx context.Context, prefix string, f func(filename string) (err error)) error
WalkFrom(ctx context.Context, prefix, inclusiveFrom string, f func(filename string) (err error)) error
WalkFromTo(ctx context.Context, prefix, inclusiveFrom, exclusiveTo string, f func(filename string) (err error)) error
ListFiles(ctx context.Context, prefix string, max int) ([]string, error)
DeleteObject(ctx context.Context, base string) error
// Used to retrieve original query parameters, allowing further
// configurability of the consumers of this store.
BaseURL() *url.URL
SubStore(subFolder string) (Store, error)
// Deprecated: Use the Options to add callbacks to inject metering from the upstream code instead
SetMeter(meter Meter)
}
func NewStore ¶
func NewStore(baseURL, extension, compressionType string, overwrite bool, opts ...Option) (Store, error)
NewStore creates a new Store instance. The baseURL is always a directory, and does not end with a `/`.
func NewStoreFromFileURL ¶
NewStoreFromFileURL works against a full file URL to derive the store from it as well as the filename it points to. Use this method **only and only if** the input points to a file directly, if your input is to build a store, use NewStore instead.
This is a shortcut helper function that make it simpler to get store from a single file url.
func OpenObject ¶
func OpenObject(ctx context.Context, fileURL string, opts ...Option) (out io.ReadCloser, store Store, filename string, err error)
OpenObject directly opens the giving file URL by parsing the file url, extracting the path and the filename from it, creating the store interface, opening the object directly and returning all this.
This is a shortcut helper function that make it simpler to get store from a single file url.