node

package
v0.0.0-...-9f5cd3f Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2013 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Overview

Package node implements node related functioniality

Index

Constants

This section is empty.

Variables

View Source
var (
	LockMgr = NewLocker()
)

Functions

func Initialize

func Initialize()

func ReloadFromDisk

func ReloadFromDisk(path string) (err error)

Types

type FormFile

type FormFile struct {
	Name     string
	Path     string
	Checksum map[string]string
}

type FormFiles

type FormFiles map[string]FormFile

type IdxInfo

type IdxInfo struct {
	Type        string `bson:"index_type" json:"-"`
	TotalUnits  int64  `bson:"total_units" json:"total_units"`
	AvgUnitSize int64  `bson:"average_unit_size" json:"average_unit_size"`
}

type Indexes

type Indexes map[string]IdxInfo

type Locker

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

func NewLocker

func NewLocker() *Locker

func (*Locker) LockPartOp

func (l *Locker) LockPartOp()

func (*Locker) UnlockPartOp

func (l *Locker) UnlockPartOp()

type Node

type Node struct {
	Id           string            `bson:"id" json:"id"`
	Version      string            `bson:"version" json:"version"`
	File         file.File         `bson:"file" json:"file"`
	Attributes   interface{}       `bson:"attributes" json:"attributes"`
	Indexes      Indexes           `bson:"indexes" json:"indexes"`
	Acl          acl.Acl           `bson:"acl" json:"-"`
	VersionParts map[string]string `bson:"version_parts" json:"-"`
	Tags         []string          `bson:"tags" json:"tags"`
	Revisions    []Node            `bson:"revisions" json:"-"`
	Linkages     []linkage         `bson:"linkage" json:"linkages"`
	CreatedOn    string            `bson:"created_on" json:"created_on"`
	LastModified string            `bson:"last_modified" json:"last_modified"`
}

func CreateNodeUpload

func CreateNodeUpload(u *user.User, params map[string]string, files FormFiles) (node *Node, err error)

CreateNodeUpload will create a new node from upload parameters and files.

func Load

func Load(id string, uuid string) (n *Node, err error)

func LoadFromDisk

func LoadFromDisk(id string) (n *Node, err error)

LoadFromDisk will load a node from disk

func LoadUnauth

func LoadUnauth(id string) (n *Node, err error)

func New

func New() (node *Node)

New creates a new Node and initializes default values.

func (*Node) Delete

func (node *Node) Delete() (err error)

Delete will delete an node and the contents on disk if it is not referenced from other nodes.

func (*Node) FileExt

func (node *Node) FileExt() string

FileExt returns the file extension

func (*Node) FilePath

func (node *Node) FilePath() string

FilePath returns the path to the node file in the data directory. Note: this is not a reliable method of accessing the file content. Use node.FileReader to access content.

func (*Node) FileReader

func (node *Node) FileReader() (reader file.ReaderAt, err error)

FileReader determines the type of file creates an appropriate file reader. Warning: do not directly attempt to create a file reader. Some node files are not compatiable will direct access.

func (*Node) HasFile

func (node *Node) HasFile() bool

HasFile determines weither the node file has been set

func (*Node) HasIndex

func (node *Node) HasIndex(index string) bool

HasFile determines weither the node has a particular index

func (*Node) HasParent

func (node *Node) HasParent() bool

HasFile determines weither the node linkage has parent

func (*Node) Index

func (node *Node) Index(name string) (idx index.Index, err error)

Index returns the named index from disk or virtualizes it

func (*Node) IndexPath

func (node *Node) IndexPath() string

Path returns the path to the node in the data directory

func (*Node) Mkdir

func (node *Node) Mkdir() (err error)

Mkdir creates node data directory

func (*Node) Path

func (node *Node) Path() string

Path returns the path to the node in the data directory

func (*Node) Rmdir

func (node *Node) Rmdir() (err error)

Rmdir deletes node data directory and content from filesystem

func (*Node) Save

func (node *Node) Save() (err error)

Save updates the version, revision history, last modification time, and then saves the node to data directory and database.

func (*Node) SetAttributes

func (node *Node) SetAttributes(attr FormFile) (err error)

SetAttributes sets attributes from json encoded file and saves node

func (*Node) SetFile

func (node *Node) SetFile(file FormFile) (err error)

SetFile moves the file from the temp upload director to the node data directory, checksums the file, and updates the node file information

func (*Node) SetFileFormat

func (node *Node) SetFileFormat(format string) (err error)

SetFileFormat sets file format and saves node

func (*Node) SetFileFromParts

func (node *Node) SetFileFromParts(p *partsList) (err error)

SetFileFromParts concatinates the file parts into the data directory, checksums the resulting file, and updates the node file information

func (*Node) SetFileFromPath

func (node *Node) SetFileFromPath(path string) (err error)

SetFileFromPath sets the file path, checksums the file, and updates the node file information

func (*Node) SetIndexInfo

func (node *Node) SetIndexInfo(indextype string, idxinfo IdxInfo) (err error)

SetIndexInfo sets index info and saves node

func (*Node) ToJson

func (node *Node) ToJson() (s string, err error)

ToJson marshals the node to json

func (*Node) Update

func (node *Node) Update(params map[string]string, files FormFiles) (err error)

Update handle node modifications. Create is handled by this function as well.

Exclusive conditions: 1) regular upload - files["upload"] is set. 2) partial upload support - params["parts"] is set. 3) virtual file node - params["type"] & params["source"] are set. 4) set from local path - params["path"] is set.

All condition allow setting of attributes.

Additionally if parts has been set and there is a file in files that matches this set in the node.

func (*Node) UpdateDataTags

func (node *Node) UpdateDataTags(types string) (err error)

UpdateLinkages updates the node data tags

func (*Node) UpdateLinkages

func (node *Node) UpdateLinkages(ltype string, ids string, operation string) (err error)

UpdateLinkages updates the node linkage

func (*Node) UpdateVersion

func (node *Node) UpdateVersion() (err error)

UpdateVersion updates the version of a node. The version is made up of md5 checksums of three sections of the object. For uniqueness these concatenated with the node id and checksumed to make the node version.

type Nodes

type Nodes []*Node

Node array type

func LoadNodes

func LoadNodes(ids []string) (n Nodes, err error)

func (*Nodes) GetAll

func (n *Nodes) GetAll(q bson.M) (err error)

func (*Nodes) GetPaginated

func (n *Nodes) GetPaginated(q bson.M, limit int, offset int) (count int, err error)

Directories

Path Synopsis
Package acl implements node acls modification and checking
Package acl implements node acls modification and checking
Package contains Node File struct and MultiReaderAt implementation
Package contains Node File struct and MultiReaderAt implementation
format/fasta
Package to read and write FASTA format files
Package to read and write FASTA format files
format/fastq
Package to read and write FASTQ format files
Package to read and write FASTQ format files
format/multi
Package to read and auto-detect format of fasta & fastq files
Package to read and auto-detect format of fasta & fastq files
format/sam
Package to read and write SAM format files
Package to read and write SAM format files
format/seq
Package contains interfaces for fasta & fastq & and multi packages
Package contains interfaces for fasta & fastq & and multi packages
index
Package index contains indexers: bai, chunkrecord, record, size
Package index contains indexers: bai, chunkrecord, record, size

Jump to

Keyboard shortcuts

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