seaweed

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

View Source
const (
	MaxChunkSize       = 16 * 1024 * 1024
	MaxChunkNameLength = math.MaxUint8
)

Constants used to determine when a chunk or collection of chunks is valid.

View Source
const (
	DefaultMasterPort = 9333
	DefaultFilerPort  = 8888
	DefaultHostname   = "localhost"
)

The default options values.

View Source
const (
	ErrNilConfiguration = seaweedError(iota)
	ErrEmptyMasterHostname
	ErrInvalidMasterScheme
	ErrIllegalMasterPath
	ErrIllegalMasterURL
	ErrEmptyFilerHostname
	ErrInvalidFilerScheme
	ErrIllegalFilerPath
	ErrIllegalFilerURL
	ErrUninitialised
	ErrInvalidChunkName
	ErrChunkTooLarge
)

The valid errors

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	log.BasicLogable
	// contains filtered or unexported fields
}

Client represents the client view of a SeaweedFS file system

func New

func New(ctx context.Context, cfg *ClientConfig) (*Client, error)

New returns a new client connection to the SeaweedFS server specified by the configuration cfg.

func (*Client) Dir

func (c *Client) Dir(ctx context.Context, p string) (fs.DirIterator, error)

Dir returns an iterator containing metadata for the files and directories within the directory with path p. If the path p does not exist then an fs/errors.NotExist error is returned; if the path p exists but is not a directory then an fs/errors.NotDirectory error will be returned. It is the caller's responsibility to call Close on the returned fs.DirIterator, otherwise resources may leak.

func (*Client) DirFrom

func (c *Client) DirFrom(ctx context.Context, p string, lastName string) (fs.DirIterator, error)

DirFrom returns an iterator containing metadata for the files and directories within the directory with path p. If lastName is empty, the first entry in this iterator will be metadata for the first file or directory in p; otherwise the first entry in the iterator is metadata for the file or directory after lastName. File and directory names are ordered lexicographically. Note that lastName need not exist in p. Note also that lastName can be given as either an absolute path whose directory is p, or as a path relative to p whose directory is p. If the path p does not exist then an fs/errors.NotExist error is returned; if the path p exists but is not a directory then an fs/errors.NotDirectory error will be returned. If lastName does not have p as its directory, an fs/errors.InvalidPath error is returned. It is the caller's responsibility to call Close on the returned fs.DirIterator, otherwise resources may leak.

func (*Client) Download

func (c *Client) Download(ctx context.Context, p string) (fs.Reader, error)

Download returns an fs.Reader reading from contents of the file with the path p. If no file with path p exists, an fs/errors.NotFile is returned. It is the caller's responsibility to call Close on the returned fs.Reader, otherwise resources may leak.

func (*Client) DownloadMetadata

func (c *Client) DownloadMetadata(ctx context.Context, p string) (*fs.Metadata, error)

DownloadMetadata returns the metadata for the file or directory with the path p. If a file or directory with this path does not exist, an fs/errors.NotExist error is returned.

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, p string) (bool, error)

Exists returns true if and only if path p exists.

func (*Client) FilerURL

func (c *Client) FilerURL() string

FilerURL returns the URL of the SeaweedFS filer server. For example, "http://localhost:8888".

func (*Client) IsDir

func (c *Client) IsDir(ctx context.Context, p string) (bool, error)

IsDir returns true if and only if path p exists and is a directory.

func (*Client) IsDirEmpty

func (c *Client) IsDirEmpty(ctx context.Context, p string) (bool, error)

IsDirEmpty returns true if and only if path p exists and is an empty directory. If the path is not a directory, returns fs/errors.NotDirectory.

func (*Client) IsFile

func (c *Client) IsFile(ctx context.Context, p string) (bool, error)

IsFile returns true if and only if path p exists in s and is a file.

func (*Client) MasterURL

func (c *Client) MasterURL() string

MasterURL returns the URL of the SeaweedFS master server. For example, "http://localhost:9333".

func (*Client) Mkdir

func (c *Client) Mkdir(ctx context.Context, p string) error

Mkdir creates the directory with the path p. If p's parent directory does not exist, an fs/errors.NotExist error is returned; if the parent exists but is not a directory then an fs/errors.NotDirectory error is returned; if a file or directory with that path already exists then an fs/errors.Exist error is returned.

func (*Client) Remove

func (c *Client) Remove(ctx context.Context, p string) error

Remove attempts to remove the file or directory with the path p. If the path does not exist, an fs/errors.NotExist error is returned. If the path is a directory and is non-empty or is "/", an fs/errors.DirNotEmpty error is returned.

func (*Client) Rmdir

func (c *Client) Rmdir(ctx context.Context, p string) error

Rmdir removes the path p if p is an empty directory. If the path is not a directory, returns fs/errors.NotDirectory; if the directory is not empty or is "/", returns fs/errors.DirNotEmpty.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, p string) (fs.Writer, error)

Upload returns an fs.Writer writing to the path p. If p's parent directory does not exist, an fs/errors.NotExist error is returned; if the parent exists but is not a directory then an fs/errors.NotDirectory error is returned; if a file or directory with path p already exists then an fs/errors.Exist error is returned. It is the caller's responsibility to call Close on the returned fs.Writer, otherwise resources may leak.

type ClientConfig

type ClientConfig struct {
	Master  *url.URL // The address of the master server
	Filer   *url.URL // The address of the filer server
	AppName string   // The application name to identify ourselves via
}

ClientConfig describes the configuration options we allow a user to set on a client connection.

func DefaultConfig

func DefaultConfig() *ClientConfig

DefaultConfig returns a new client configuration initialised with the default values.

func SetDefaultConfig

func SetDefaultConfig(c *ClientConfig) *ClientConfig

SetDefaultConfig sets the default client configuration to c and returns the old default configuration. This change will be reflected in future calls to DefaultConfig.

func (*ClientConfig) Copy

func (c *ClientConfig) Copy() *ClientConfig

Copy returns a copy of the configuration.

func (*ClientConfig) Validate

func (c *ClientConfig) Validate() error

Validate validates the client configuration, returning an error if there's a problem.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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