anchorfs

package
v0.0.0-...-fd2add7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package anchorfs exposes the programming interface for accessing the anchor file system

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrName     = errors.NewError("anchor name")
	ErrNotFound = errors.NewError("not found")
)

Functions

func Bind

func Bind(v System)

Bind is used internally to bind an implementation of this package to the public methods of this package

func Created

func Created() []string

Created returns a slive of anchor directories within which this worker has created files with CreateFile.

func SanitizeDir

func SanitizeDir(anchor string) (parts []string, full string, err error)

SanitizeDir ensures that anchor is a valid directory path in the fs and returns its parts and a normalized absolute path string.

Types

type Dir

type Dir interface {

	// Path returns the fully-qualified name of the directory
	Path() string

	// List returns the list of file and directory names within this directory alongside with the respective revision.
	List() (rev Rev, files, dirs []string)

	// Change blocks until the contents of this directory changes relative to its contents at revision sinceRev.
	// It then returns the new revision number and contents.
	Change(sinceRev Rev) (rev Rev, files, dirs []string)

	// ChangeExpire is similar to Change, except it timeouts if a change does not occur within an expire interval.
	ChangeExpire(sinceRev Rev, expire time.Duration) (rev Rev, files, dir []string, err error)

	// OpenFile opens the file, registered by the given worker ID, if it exists
	OpenFile(string) (File, error)

	// OpenDir opens a subdirectory
	OpenDir(string) (Dir, error)
}

Dir is the interface for a directory of workers in the anchor file system

func OpenDir

func OpenDir(anchor string) (Dir, error)

OpenDir opens the anchor directory anchor

type File

type File interface {

	// Path returns the fully-qualified name of the file
	Path() string

	// Anchor returns the worker address of the worker who created this file
	Anchor() n.Addr
}

File is the interface of an anchor file system file

func OpenFile

func OpenFile(anchor string) (File, error)

OpenFile opens the anchor file anchor

type Rev

type Rev int32

Rev is the sequentially-increasing revision number of a file system object

type System

type System interface {
	OpenFile(string) (File, error)
	OpenDir(string) (Dir, error)

	// Created returns the anchors created by this worker
	Created() []string
}

System represents an anchor file system

Jump to

Keyboard shortcuts

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