Documentation ¶
Overview ¶
Package gorods is a Golang binding for the iRods C API (iRods client library). GoRods uses cgo to call iRods client functions.
Index ¶
- Constants
- type Collection
- func (col *Collection) All() []IRodsObj
- func (col *Collection) Attribute(attr string) *Meta
- func (col *Collection) Both() (DataObjs, Collections)
- func (col *Collection) Cd(path string) *Collection
- func (col *Collection) Close() *Collection
- func (col *Collection) Collections() Collections
- func (col *Collection) CreateDataObj(opts DataObjOptions) *DataObj
- func (col *Collection) DataObjs() DataObjs
- func (col *Collection) Exists(path string) bool
- func (col *Collection) Find(path string) IRodsObj
- func (col *Collection) Get(path string) *DataObj
- func (col *Collection) Meta() MetaCollection
- func (col *Collection) Open() *Collection
- func (col *Collection) Put(localFile string) *DataObj
- func (col *Collection) ReadCollection()
- func (col *Collection) Refresh()
- func (obj *Collection) String() string
- func (col *Collection) Type() int
- type Collections
- type Connection
- type ConnectionOptions
- type DataObj
- func (obj *DataObj) Attribute(attrName string) *Meta
- func (obj *DataObj) Chksum() string
- func (obj *DataObj) Close() *DataObj
- func (obj *DataObj) CopyTo(iRodsCollection interface{}) *DataObj
- func (obj *DataObj) Delete()
- func (obj *DataObj) DownloadTo(localPath string) *DataObj
- func (obj *DataObj) LSeek(offset int64) *DataObj
- func (obj *DataObj) Meta() MetaCollection
- func (obj *DataObj) MoveTo(iRodsCollection interface{}) *DataObj
- func (obj *DataObj) MoveToResource(destinationResource string) *DataObj
- func (obj *DataObj) Open()
- func (obj *DataObj) Read() []byte
- func (obj *DataObj) ReadBytes(pos int64, length int) []byte
- func (obj *DataObj) ReadChunk(size int64, callback func([]byte)) *DataObj
- func (obj *DataObj) Rename(newFileName string) *DataObj
- func (obj *DataObj) ReplSettings(resource map[string]interface{}) *DataObj
- func (obj *DataObj) Replicate(targetResource string) *DataObj
- func (obj *DataObj) Stat() map[string]interface{}
- func (obj *DataObj) String() string
- func (obj *DataObj) Type() int
- func (obj *DataObj) Unlink()
- func (obj *DataObj) Verify(md5Checksum string) bool
- func (obj *DataObj) Write(data []byte) *DataObj
- func (obj *DataObj) WriteBytes(data []byte) *DataObj
- type DataObjOptions
- type DataObjs
- type GoRodsError
- type IRodsObj
- type Meta
- type MetaCollection
- Bugs
Constants ¶
const ( System = iota UserDefined )
System and UserDefined constants are used when calling gorods.New(ConnectionOptions{ Environment: ... }) When System is specified, the options stored in ~/.irods/.irodsEnv will be used. When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password should be set regardless.
const ( DataObjType = iota CollectionType ResourceType ResourceGroupType UserType )
Used when calling Type() on different gorods objects
const ( Info = iota Warn Fatal )
Log level constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection struct { Path string Name string DataObjects []IRodsObj MetaCol MetaCollection Con *Connection Col *Collection Recursive bool ObjType int // contains filtered or unexported fields }
Collection structs contain information about single collections in an iRods zone.
func (*Collection) All ¶
func (col *Collection) All() []IRodsObj
Returns generic interface slice containing both data objects and collections combined
func (*Collection) Attribute ¶
func (col *Collection) Attribute(attr string) *Meta
Attribute gets specific metadata AVU triple for Collection
func (*Collection) Both ¶
func (col *Collection) Both() (DataObjs, Collections)
Both returns two slices, the first for DataObjs and the second for Collections
func (*Collection) Cd ¶
func (col *Collection) Cd(path string) *Collection
Cd is a shortcut for calling collection.Collections().Find(path). It effectively returns (or changes to) the sub collection you specify collection-relatively or absolutely.
func (*Collection) Close ¶
func (col *Collection) Close() *Collection
Close closes the Collection connection and resets the handle
func (*Collection) Collections ¶
func (col *Collection) Collections() Collections
Collections returns only the collections contained within the collection
func (*Collection) CreateDataObj ¶
func (col *Collection) CreateDataObj(opts DataObjOptions) *DataObj
CreateDataObj creates a data object within the collection using the options specified
func (*Collection) DataObjs ¶
func (col *Collection) DataObjs() DataObjs
DataObjs returns only the data objects contained within the collection
func (*Collection) Exists ¶
func (col *Collection) Exists(path string) bool
Exists returns true of false depending on whether the DataObj or Collection is found
func (*Collection) Find ¶
func (col *Collection) Find(path string) IRodsObj
Find returns either a DataObject or Collection using the collection-relative or absolute path specified.
func (*Collection) Get ¶
func (col *Collection) Get(path string) *DataObj
Get is a shortcut for calling collection.DataObjs().Find(path). It effectively returns the DataObj you specify collection-relatively or absolutely.
func (*Collection) Meta ¶
func (col *Collection) Meta() MetaCollection
Meta returns collection of all metadata AVU triples for Collection
func (*Collection) Open ¶
func (col *Collection) Open() *Collection
Open connects to iRods and sets the handle for Collection. Usually called by Collection.init()
func (*Collection) Put ¶
func (col *Collection) Put(localFile string) *DataObj
Put adds a local file to the remote iRods collection
func (*Collection) ReadCollection ¶
func (col *Collection) ReadCollection()
ReadCollection reads data (overwrites) into col.DataObjects field.
func (*Collection) Refresh ¶
func (col *Collection) Refresh()
Refresh is an alias of ReadCollection()
func (*Collection) String ¶
func (obj *Collection) String() string
String shows the contents of the collection.
D = DataObj
C = Collection
Sample output:
Collection: /tempZone/home/admin/gorods D: build.sh C: bin C: pkg C: src
type Collections ¶
type Collections []*Collection
Collections is a slice of Collection structs
func (Collections) Exists ¶
func (colls Collections) Exists(path string) bool
Exists checks to see if a collection exists in the slice and returns true or false
func (Collections) Find ¶
func (colls Collections) Find(path string) *Collection
Find gets a collection from the slice and returns nil if one is not found. Both the collection name or full path can be used as input.
func (Collections) FindRecursive ¶
func (colls Collections) FindRecursive(path string) *Collection
FindRecursive acts just like Find, but also searches sub collections recursively. If the collection was not explicitly loaded recursively, only the first level of sub collections will be searched.
type Connection ¶
type Connection struct { Connected bool Options *ConnectionOptions OpenedCollections Collections // contains filtered or unexported fields }
func New ¶
func New(opts ConnectionOptions) (*Connection, error)
New creates a connection to an iRods iCAT server. System and UserDefined constants are used in ConnectionOptions{ Environment: ... }). When System is specified, the options stored in ~/.irods/.irodsEnv will be used. When UserDefined is specified you must also pass Host, Port, Username, and Zone. Password should be set regardless.
func (*Connection) Collection ¶
func (con *Connection) Collection(startPath string, recursive bool) (collection *Collection, err error)
Collection initializes and returns an existing iRods collection using the specified path
func (*Connection) Disconnect ¶
func (con *Connection) Disconnect()
Disconnect closes connection to iRods iCAT server
func (*Connection) String ¶
func (obj *Connection) String() string
String provides connection status and options provided during initialization (gorods.New)
type ConnectionOptions ¶
type ConnectionOptions struct { Environment int Host string Port int Zone string Username string Password string }
ConnectionOptions are used when creating iRods iCAT server connections see gorods.New() docs for more info.
type DataObj ¶
type DataObj struct { Path string Name string Size int64 Offset int64 ObjType int MetaCol MetaCollection // Con field is a pointer to the Connection used to fetch the data object Con *Connection // Col field is a pointer to the Collection containing the data object Col *Collection // contains filtered or unexported fields }
DataObj structs contain information about single data objects in an iRods zone.
func CreateDataObj ¶
func CreateDataObj(opts DataObjOptions, coll *Collection) *DataObj
CreateDataObj creates and adds a data object to the specified collection using provided options. Returns the newly created data object.
func (*DataObj) Attribute ¶
Attribute returns a single Meta triple struct found by the attributes name
func (*DataObj) CopyTo ¶
CopyTo copies the data object to the specified collection. Supports Collection struct or string as input. Also refreshes the destination collection automatically to maintain correct state. Returns self (source DataObj).
func (*DataObj) Delete ¶
func (obj *DataObj) Delete()
Delete deletes the data object from the iRods server with a force flag
func (*DataObj) DownloadTo ¶
DownloadTo downloads and writes the entire data object to the provided path. Don't use this with large files unless you have RAM to spare, use ReadChunk() instead. Returns self (DataObj).
func (*DataObj) LSeek ¶
LSeek sets the read/write offset pointer of a data object, returns self (DataObj)
func (*DataObj) Meta ¶
func (obj *DataObj) Meta() MetaCollection
Meta returns collection of Meta AVU triple structs of the data object
func (*DataObj) MoveTo ¶
MoveTo moves the data object to the specified collection. Supports Collection struct or string as input. Also refreshes the source and destination collections automatically to maintain correct state. Returns self (DataObj).
func (*DataObj) MoveToResource ¶
NEED TO IMPLEMENT
func (*DataObj) Open ¶
func (obj *DataObj) Open()
Open opens a connection to iRods and sets the data object handle
func (*DataObj) Read ¶
Read reads the entire data object into memory and returns a []byte slice. Don't use this for large files.
func (*DataObj) ReadBytes ¶
ReadBytes reads bytes from a data object at the specified position and length, returns []byte slice.
func (*DataObj) ReadChunk ¶
ReadChunk reads the entire data object in chunks (size of chunk specified by size parameter), passing the data into a callback function for each chunk. Use this to read/write large files.
func (*DataObj) Rename ¶
Rename is equivalent to the Linux mv command except that the data object must stay within the current collection (directory), returns self (DataObj).
func (*DataObj) ReplSettings ¶
NEED TO IMPLEMENT
func (*DataObj) Stat ¶
Stat returns a map (key/value pairs) of the system meta information. The following keys can be used with the map:
"objSize"
"dataMode"
"dataId"
"chksum"
"ownerName"
"ownerZone"
"createTime"
"modifyTime"
func (*DataObj) Unlink ¶
func (obj *DataObj) Unlink()
Unlink deletes the data object from the iRods server, no force flag is used
func (*DataObj) Verify ¶
Verify returns true or false depending on whether the checksum md5 string matches
func (*DataObj) Write ¶
Write writes the data to the data object, starting from the beginning. Returns self (DataObj).
func (*DataObj) WriteBytes ¶
WriteBytes writes to the data object wherever the object's offset pointer is currently set to. It advances the pointer to the end of the written data for supporting subsequent writes. Be sure to call obj.LSeek(0) before hand if you wish to write from the beginning. Returns self (DataObj).
type DataObjOptions ¶
DataObjOptions is used for passing options to the CreateDataObj function
type DataObjs ¶
type DataObjs []*DataObj
DataObjs is a slice of DataObj structs
type GoRodsError ¶
GoRodsError stores information about errors
func (*GoRodsError) Error ¶
func (err *GoRodsError) Error() string
Error returns error string, alias of String(). Sample output:
2016-04-22 10:02:30.802355258 -0400 EDT: Fatal - iRods Connect Failed: rcConnect failed
func (*GoRodsError) String ¶
func (err *GoRodsError) String() string
String returns error string. Sample output:
2016-04-22 10:02:30.802355258 -0400 EDT: Fatal - iRods Connect Failed: rcConnect failed
type IRodsObj ¶
type IRodsObj interface {
Type() int
}
IRodsObj is a generic interface used to detect the object type
type Meta ¶
Meta structs contain information about a single iRods metadata attribute-value-units (AVU) triple
type MetaCollection ¶
type MetaCollection []*Meta
MetaCollection is a collection of metadata AVU triples for a single data object
func (MetaCollection) Get ¶
func (metas MetaCollection) Get(attr string) *Meta
Get finds a single Meta struct by it's Attribute field. Similar to Attribute() function of other types.
func (MetaCollection) String ¶
func (metas MetaCollection) String() string
String shows the contents of the meta collection.
Sample output:
Attr1: Val (unit: ) Attr2: Yes (unit: bool)
Notes ¶
Bugs ¶
iRods C API code outputs errors messages, need to implement connect wrapper (gorods_connect_env) from a lower level to suppress this output https://github.com/irods/irods/blob/master/iRODS/lib/core/src/rcConnect.cpp#L109