Documentation ¶
Overview ¶
Package filesystem contains an extensible file system abstraction. It allows various kinds of storage systems to be used uniformly, notably through textio.
Registered file systems at minimum implement the Interface abstraction, and can then optionally implement Remover, Renamer, and Copier to support rename operations. Filesystems are only expected to handle their own IO, and not cross file system IO. Should cross file system IO be required, additional utility methods should be added to this package to support them.
Index ¶
- func Copy(ctx context.Context, fs Interface, oldpath, newpath string) error
- func Match(pattern, name string) (bool, error)
- func Read(ctx context.Context, fs Interface, filename string) ([]byte, error)
- func Register(scheme string, fs func(context.Context) Interface)
- func Rename(ctx context.Context, fs Interface, oldpath, newpath string) error
- func ValidateScheme(path string)
- func Write(ctx context.Context, fs Interface, filename string, data []byte) error
- type Copier
- type Interface
- type LastModifiedGetter
- type Remover
- type Renamer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy replicates the file at oldpath to newpath. Requires the paths to be on the same filesystem.
If the file system implements Copier, it uses that, otherwise it does so manually.
func Match ¶
Match is a platform agnostic version of filepath.Match where \ is treated as / on Windows.
func Register ¶
Register registers a file system backend under the given scheme. For example, "hdfs" would be registered a HFDS file system and HDFS paths used transparently.
func Rename ¶
Rename moves the file at oldpath to newpath. Requires the paths to be on the same filesystem.
Rename will use Renamer, Remover, and Copier interfaces if implemented. Renamer is tried first, and used if available. Otherwise, Rename requires Remover to be implemented, and calls Copy.
func ValidateScheme ¶
func ValidateScheme(path string)
ValidateScheme panics if the given path's scheme does not have a corresponding file system registered.
Types ¶
type Interface ¶
type Interface interface { io.Closer // List expands a pattern to a list of filenames. // Returns nil if there are no matching files. List(ctx context.Context, glob string) ([]string, error) // OpenRead opens a file for reading. OpenRead(ctx context.Context, filename string) (io.ReadCloser, error) // OpenWrite opens a file for writing. If the file already exist, it will be // overwritten. The returned io.WriteCloser should be closed to commit the write. OpenWrite(ctx context.Context, filename string) (io.WriteCloser, error) // Size returns the size of a file in bytes. Size(ctx context.Context, filename string) (int64, error) }
Interface is a filesystem abstraction that allows beam io sources and sinks to use various underlying storage systems transparently.
type LastModifiedGetter ¶
type LastModifiedGetter interface {
LastModified(ctx context.Context, filename string) (time.Time, error)
}
LastModifiedGetter is an interface for getting the last modified time of a file.
Directories ¶
Path | Synopsis |
---|---|
Package gcs contains a Google Cloud Storage (GCS) implementation of the Beam file system.
|
Package gcs contains a Google Cloud Storage (GCS) implementation of the Beam file system. |
Package local contains a local file implementation of the Beam file system.
|
Package local contains a local file implementation of the Beam file system. |
Package memfs contains a in-memory Beam filesystem.
|
Package memfs contains a in-memory Beam filesystem. |
Package s3 contains an AWS S3 implementation of the Beam file system.
|
Package s3 contains an AWS S3 implementation of the Beam file system. |