files

package
v0.0.0-...-4607e62 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(path string) (bool, error)

FileExists validates that the specified path exists. Path may be a directory or file.

func FormatBytes

func FormatBytes(size uint64) string

func GetOrCreateFile

func GetOrCreateFile(path string) (*os.File, error)

GetOrCreateFile gets a pointer to the file at the path specified. If the path does not exist, it is created. If the parent directory or directories don't exist, they are also created.

func Join

func Join(path, file string) string

func Parent

func Parent(path string) string

Types

type FileSystem

type FileSystem struct {

	// Name is a unique identifier for the file system.
	Name string

	// Description should be a brief note.
	Description string

	// Addresses are a list of the name nodes for the file system.
	Addresses []string
}

FileSystem defines a simple pointer to an HDFS file system.

func (*FileSystem) Connect

func (r *FileSystem) Connect() (FileSystemClient, error)

Connect opens a FileSystemClient.

type FileSystemClient

type FileSystemClient interface {
	Close() error
	Name() string
	Upload(source, destination string) error
	Download(source, destination string) error
	Move(oldpath, newpath string) error
	MakeDir(path string, permission os.FileMode) error
	List(path string) ([]HdfsFileInfo, error)
	Delete(path string) error
	Read(path string) (*io.Reader, error)
	Write(path string, append bool) (*io.Writer, error)
	Status(path string) (HdfsFileInfo, error)
}

FileSystemClient interface is an abstraction around requests to an hdfs file system.

func CreateHDFSFileSystemClient

func CreateHDFSFileSystemClient(name string, client *hdfs.Client) FileSystemClient

CreateHDFSFileSystemClient wraps an hdfs.Client in order to produce the FileSystemClient interface.

type FileSystemRepository

type FileSystemRepository interface {
	List() ([]FileSystem, error)
	FindByName(name string) (*FileSystem, error)
	Remove(name string) error
	Store(fileSystem FileSystem) error
}

FileSystemRepository is used to load/store/find all of the previously configured FileSystems.

func GetFileSystemRepository

func GetFileSystemRepository() (FileSystemRepository, error)

GetFileSystemRepository loads an instance of the FileSystemRepository interface. This call will default to reading the data from $HOME/.fsrepo/fs.repo.

func GetFileSystemRepositoryFromPath

func GetFileSystemRepositoryFromPath(path string) (FileSystemRepository, error)

GetFileSystemRepositoryFromPath loads an instance of the FileSystemRepository found at a specified location.

type HdfsFileInfo

type HdfsFileInfo interface {
	IsDir() bool
	ModTime() time.Time
	AccessTime() time.Time
	Mode() fs.FileMode
	Name() string
	Size() int64
	Owner() string
	OwnerGroup() string
	Replication() uint32
	BlockSize() uint64
}

HdfsFileInfo wrapper around os.FileInfo with some additional functions related to HDFS files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL