webfs

package
v0.0.0-...-6c704aa Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxBlobSize = gotfs.DefaultMaxBlobSize
)

Variables

This section is empty.

Functions

func Hash

func Hash(x []byte) cadata.ID

func MarshalVolumeSpec

func MarshalVolumeSpec(x VolumeSpec) ([]byte, error)

Types

type AEADCellSpec

type AEADCellSpec struct {
	Inner  CellSpec `json:"inner"`
	Algo   string   `json:"algo"`
	Secret []byte   `json:"secret"`
}

type BlobcacheStoreSpec

type BlobcacheStoreSpec struct{}

type CellSpec

type CellSpec struct {
	Memory  *struct{}       `json:"memory,omitempty"`
	File    *string         `json:"file,omitempty"`
	HTTP    *HTTPCellSpec   `json:"http,omitempty"`
	Literal json.RawMessage `json:"literal,omitempty"`

	AEAD      *AEADCellSpec      `json:"aead,omitempty"`
	GotBranch *GotBranchCellSpec `json:"got_branch,omitempty"`
}

CellSpec is a specification for a Cell

type ErrBadConfig

type ErrBadConfig struct {
	Path  string
	Data  []byte
	Inner error
}

ErrBadConfig is returned when WebFS encounters an invalid config which it cannot mount.

func (ErrBadConfig) Cause

func (e ErrBadConfig) Cause() error

func (ErrBadConfig) Error

func (e ErrBadConfig) Error() string

type FS

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

FS is an instance of a WebFS filesystem

func New

func New(vspec VolumeSpec, opts ...Option) (*FS, error)

func (*FS) Cat

func (fs *FS) Cat(ctx context.Context, p string, w io.Writer) error

func (*FS) Ls

func (fs *FS) Ls(ctx context.Context, p string, fn func(iofs.DirEntry) error) error

func (*FS) Mkdir

func (fs *FS) Mkdir(ctx context.Context, p string) error

func (*FS) Open

func (fs *FS) Open(ctx context.Context, p string) (*File, error)

func (*FS) PutFile

func (fs *FS) PutFile(ctx context.Context, p string, r io.Reader) error

func (*FS) Remove

func (fs *FS) Remove(ctx context.Context, p string) error

type File

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

func (*File) Close

func (f *File) Close() error

func (*File) Read

func (f *File) Read(p []byte) (int, error)

func (*File) ReadAt

func (f *File) ReadAt(buf []byte, offset int64) (int, error)

func (*File) ReadDir

func (f *File) ReadDir(n int) (ret []iofs.DirEntry, _ error)

func (*File) Stat

func (f *File) Stat() (iofs.FileInfo, error)

func (*File) Sync

func (f *File) Sync() error

type GotBranchCellSpec

type GotBranchCellSpec struct {
	Inner   CellSpec  `json:"inner"`
	VCStore StoreSpec `json:"vc_store"`
}

type HTTPCellSpec

type HTTPCellSpec struct {
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers,omitempty"`
}

type HTTPStoreSpec

type HTTPStoreSpec struct {
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

type IPFSStoreSpec

type IPFSStoreSpec struct{}

type Option

type Option func(c *fsConfig)

Option is used to configure a WebFS instance.

func WithBlobcache

func WithBlobcache(endpoint string) Option

WithBlobcache sets the endpoint to connect to the blobcache daemon

func WithIPFS

func WithIPFS(shell *ipfsapi.Shell) Option

func WithLogger

func WithLogger(l logrus.FieldLogger) Option

WithLogger sets the logger for the WebFS instance

func WithPosixFS

func WithPosixFS(x posixfs.FS) Option

WithPosixFS sets x as the filesystem to use for file backed cells.

func WithTCPDialer

func WithTCPDialer(d func(context.Context, string) (net.Conn, error)) Option

WithTCPDialer sets the dialer used for outbound TCP connections.

type StoreSpec

type StoreSpec struct {
	Memory    *struct{}           `json:"memory,omitempty"`
	FS        *string             `json:"fs,omitempty"`
	HTTP      HTTPStoreSpec       `json:"http,omitempty"`
	Blobcache *BlobcacheStoreSpec `json:"blobcache,omitempty"`
	IPFS      *IPFSStoreSpec      `json:"ipfs,omitempty"`
}

type TCPDialer

type TCPDialer = func(context.Context, string) (net.Conn, error)

type Volume

type Volume struct {
	Cell  cells.Cell
	Store cadata.Store
	Salt  []byte
}

type VolumeSpec

type VolumeSpec struct {
	Cell  CellSpec  `json:"cell"`
	Store StoreSpec `json:"store"`
	Salt  []byte    `json:"salt"`
}

VolumeSpec is a specification for a Volume.

func ParseVolumeSpec

func ParseVolumeSpec(x []byte) (*VolumeSpec, error)

ParseVolumeSpec parses a JSON formatted VolumeSpec from x.

func (VolumeSpec) Fingerprint

func (vs VolumeSpec) Fingerprint() [32]byte

Jump to

Keyboard shortcuts

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