fsclient

package
Version: v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaCellRow = config.SheetMetaCellRow
	MetaCellCol = config.SheetMetaCellCol
)

Variables

This section is empty.

Functions

func DynamicCopy

func DynamicCopy(dst *[]byte, src []byte)

Types

type CancelledError

type CancelledError struct {
}

func (*CancelledError) Error

func (c *CancelledError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config *ClientConfig) (*Client, error)

func (*Client) Create

func (c *Client) Create(ctx context.Context, name string) (f *File, err error)

Create @para

name(string):  the name of the file

@return

f(*File): fd
error(error): nil is no error
			fs.ErrExist: already exist
			fs.ErrInvalid: wrong para

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, name string) (err error)

Delete @para

name(string) : the name of the file

@return

error(error): nil is no error
			fs.ErrExist: already exist
			fs.ErrInvalid: wrong para

func (*Client) Open

func (c *Client) Open(ctx context.Context, name string) (f *File, err error)

Open @para

name(string):  the name of the file

@return

fd(uint64): the fd of the open file
status(Status)
error(error)

type ClientConfig added in v1.0.0

type ClientConfig struct {
	ZookeeperServers    []string
	ZookeeperTimeout    time.Duration
	MasterZnode         string
	DataNodeZnodePrefix string
	MaxRetry            int
}

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Read

func (f *File) Read(ctx context.Context) (b []byte, n int64, err error)

Read Request Master to get a list of all Chunks of a file. For each chunk, start a worker goroutine to fetch them, and reassemble them into a complete file.

Sometimes(e.g. due to network delay), client will receive a newer Version from master which is not actually written to DataNode by another client. If so, this function will spin until it success or cancelled by ctx, so ctx is generally necessary. @para

b([]byte): return the read data. It will return partially read data if
there are some workers failed.

@return

n(int64): the read size, -1 if error
error(error)
	*UnexpectedStatusError: MasterNode or DataNode returns a unexpected status
	some other errors returned by rpc
	*CancelledError: If operations(spin or rpc call) are cancelled by ctx. And only if there is no
	other errors happened and ctx cancelled, a CancelledError will be returned.

func (*File) ReadAt

func (f *File) ReadAt(ctx context.Context, b []byte, row uint32, col uint32) (n int64, err error)

ReadAt Sometimes(e.g. due to network delay), client will receive a newer Version from master which is not actually written to DataNode by another client. If so, this function will spin until it success or cancelled by ctx, so ctx is generally necessary.

@para

ctx: context.Context used to cancel operation
b: buffer for reading cell
row, col

@return

fd(uint64): the fd of the open file
status(Status)
error(error)
	*UnexpectedStatusError: MasterNode or DataNode returns a unexpected status
	some other errors returned by rpc
	*CancelledError: If operations(spin or rpc call) are cancelled by ctx. And only if there is no
	other errors happened and ctx cancelled, a CancelledError will be returned.

func (*File) WriteAt

func (f *File) WriteAt(ctx context.Context, b []byte, row uint32, col uint32, padding string) (n int64, err error)

WriteAt Sometimes(e.g. due to network delay), client will receive a newer Version from master which is not actually written to DataNode by another client. If so, this function will spin until it success or cancelled by ctx, so ctx is generally necessary.

@para

@para
ctx: context.Context used to cancel operation
b: buffer for reading cell
padding: padding character used to pad a cell to its maximum size, for LuckySheet file,
a " " should be passed in.
row, col

@return

fd(uint64): the fd of the open file
status(Status)
error(error)
	*UnexpectedStatusError: MasterNode or DataNode returns a unexpected status
	some other errors returned by rpc
	*CancelledError: If operations(spin or rpc call) are cancelled by ctx. And only if there is no
	other errors happened and ctx cancelled, a CancelledError will be returned.

type UnexpectedStatusError

type UnexpectedStatusError struct {
	// contains filtered or unexported fields
}

func NewUnexpectedStatusError

func NewUnexpectedStatusError(status fsrpc.Status) *UnexpectedStatusError

func (*UnexpectedStatusError) Error

func (u *UnexpectedStatusError) Error() string

func (*UnexpectedStatusError) Status

func (u *UnexpectedStatusError) Status() fsrpc.Status

Jump to

Keyboard shortcuts

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