go-gfal2: github.com/cern-it-sdc-id/go-gfal2 Index | Files

package gfal2

import "github.com/cern-it-sdc-id/go-gfal2"

Index

Package Files

cfuncs.go config.go directory.go file.go gerror.go gfal2.go logger.go metadata.go staging.go transfer.go

Constants

const (
    LogLevelError    = C.G_LOG_LEVEL_ERROR
    LogLevelCritical = C.G_LOG_LEVEL_CRITICAL
    LogLevelWarning  = C.G_LOG_LEVEL_WARNING
    LogLevelMessage  = C.G_LOG_LEVEL_MESSAGE
    LogLevelInfo     = C.G_LOG_LEVEL_INFO
    LogLevelDebug    = C.G_LOG_LEVEL_DEBUG
)

Log levels.

const (
    EventSource      = 0
    EventDestination = 1
    EventNone        = 2
)

Side constants.

const (
    ChecksumNone   = 0x00
    ChecksumSource = 0x01
    ChecksumTarget = 0x02
    ChecksumBoth   = (ChecksumSource | ChecksumTarget)
)

Checksum type constants

func GetLogLevel Uses

func GetLogLevel() int

GetLogLevel returns the logging level.

func SetLogHandler Uses

func SetLogHandler(handler LogListener)

SetLogHandler sets a callback rather than printing to stdout.

func SetLogLevel Uses

func SetLogLevel(level int)

SetLogLevel set the logging level.

func Version Uses

func Version() string

Version returns the underlying gfal2 version.

type Context Uses

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

Context is a handle to a gfal2 instantiation.

func NewContext Uses

func NewContext() (*Context, GError)

NewContext creates a new gfal2 context.

func (Context) AbortFiles Uses

func (context Context) AbortFiles(urls []string, token string) []GError

AbortFiles aborts a set of files that are queued for staging.

func (Context) Access Uses

func (context Context) Access(url string, mode int) GError

Access checks if the user has permission for the given file. For mode, check the values of F_OK, R_OK, W_OK and X_OK.

func (Context) AddClientInfo Uses

func (context Context) AddClientInfo(key string, value string) GError

AddClientInfo adds additional client info to be sent to the remote server. For instance, using HTTP this will be sent as part of the headers.

func (Context) BringOnline Uses

func (context Context) BringOnline(url string, pintime int, timeout int, async bool) (string, GError)

BringOnline performs a bring online operation. Return the token, or nil and an error. If async is false, this method will block until the file is brought online. If async if true, this method return immediately, and the caller should use BringOnlinePoll to check for the termination.

func (Context) BringOnlineList Uses

func (context Context) BringOnlineList(urls []string, pintime int, timeout int, async bool) (string, []GError)

BringOnlineList request the staging of a list of files. See BringOnline for the meaning of the parameters. Return the token *and* a list of errors, one per url. The error will be nil if the file is online, or EAGAIN is queued. Other error codes are definite errors.

func (Context) BringOnlinePoll Uses

func (context Context) BringOnlinePoll(url string, token string) GError

BringOnlinePoll checks the status of a bring online operation. The token was returned by BringOnline.

func (Context) BringOnlinePollList Uses

func (context Context) BringOnlinePollList(urls []string, token string) []GError

BringOnlinePollList polls a list of files. See BringOnlinePoll.

func (Context) Cancel Uses

func (context Context) Cancel() int

Cancel running operations, if any. Return the number of cancelled operations.

func (Context) Checksum Uses

func (context Context) Checksum(url string, chktype string, offset uint64, length uint64) (string, GError)

Checksum returns the checksum of a url. chktype is the algorithm to use (md5, adler32, sha1...). Support depends on the underlying protocol and storage. The checksum can be calculated with an offset and length. If both are 0, then the checksum is for the whole file.

func (Context) Chmod Uses

func (context Context) Chmod(url string, mode os.FileMode) GError

Chmod changes the mode of a file.

func (Context) ClearClientInfo Uses

func (context Context) ClearClientInfo() GError

ClearClientInfo clears the additional client info.

func (Context) Close Uses

func (context Context) Close()

Close destroys the gfal2 context.

func (Context) Create Uses

func (context Context) Create(url string) (*File, GError)

Create is a shortcut for creating and open to write a file.

func (Context) GetClientInfoString Uses

func (context Context) GetClientInfoString() (repr string)

GetClientInfoString returns the additional client info as key1:value1;key2:value2;...

func (Context) GetOptBoolean Uses

func (context Context) GetOptBoolean(group string, key string) bool

GetOptBoolean gets the value of group:key as a boolean.

func (Context) GetOptInteger Uses

func (context Context) GetOptInteger(group string, key string) int

GetOptInteger gets the value of group:key as an integer.

func (Context) GetOptString Uses

func (context Context) GetOptString(group string, key string) string

GetOptString gets the value of group:key as a string.

func (Context) GetOptStringList Uses

func (context Context) GetOptStringList(group string, key string) []string

GetOptStringList gets the value of group:key as a string list.

func (Context) GetPluginNames Uses

func (context Context) GetPluginNames() ([]string, GError)

GetPluginNames returns a list with the names and version of the loaded plugins.

func (Context) GetUserAgent Uses

func (context Context) GetUserAgent() (agent string, version string)

GetUserAgent returns the configured user agent.

func (Context) Getxattr Uses

func (context Context) Getxattr(url string, name string) (string, GError)

Getxattr returns an extended attribute of a file.

func (Context) Listxattr Uses

func (context Context) Listxattr(url string) ([]string, GError)

Listxattr returns the list of extended attributes of a file.

func (Context) LoadOptsFromFile Uses

func (context Context) LoadOptsFromFile(path string) GError

LoadOptsFromFile loads configuration parameters from a file. It overwrites existing conflicting values, but keeps those that aren't superseded.

func (Context) Lstat Uses

func (context Context) Lstat(url string) (Stat, GError)

Lstat stats a file, but if url is a symlink, stat it rather than the target.

func (Context) Mkdir Uses

func (context Context) Mkdir(url string, mode os.FileMode) GError

Mkdir creates a directory. Do not create intermediate parents.

func (Context) MkdirAll Uses

func (context Context) MkdirAll(url string, mode os.FileMode) GError

MkdirAll creates a directory and intermediate parents if required.

func (Context) NewTransferHandler Uses

func (context Context) NewTransferHandler() (*TransferHandler, GError)

NewTransferHandler creates a new TransferParameters struct.

func (Context) Open Uses

func (context Context) Open(url string) (*File, GError)

Open a file in read only mode.

func (Context) OpenFile Uses

func (context Context) OpenFile(url string, flag int, perm os.FileMode) (*File, GError)

OpenFile opens a file allowing to specify if want to read, write, create, etc. flag is a combination of os.RD_ONLY, os.WR_ONLY, etc.) perm must be set to the posix permissions desired if the file is to be created.

func (Context) Opendir Uses

func (context Context) Opendir(url string) (*Dir, GError)

Opendir opens a directory.

func (context Context) Readlink(url string) (string, GError)

Readlink returns the target of a symbolic link.

func (Context) ReleaseFile Uses

func (context Context) ReleaseFile(url string, token string) GError

ReleaseFile releases a file, so the storage can remove it from disk. The token was returned by BringOnline.

func (Context) ReleaseFileList Uses

func (context Context) ReleaseFileList(urls []string, token string) []GError

ReleaseFileList releases a list of files.

func (Context) Remove Uses

func (context Context) Remove(url string) GError

Remove deletes a file or directory.

func (Context) RemoveClientInfo Uses

func (context Context) RemoveClientInfo(key string) GError

RemoveClientInfo removes additional client info that was previously set with AddClientInfo.

func (Context) Rename Uses

func (context Context) Rename(oldName string, newName string) GError

Rename a file. Source and destination must be on the same endpoint.

func (Context) SetOptBoolean Uses

func (context Context) SetOptBoolean(group string, key string, value bool) GError

SetOptBoolean sets a boolean parameter under group:key.

func (Context) SetOptInteger Uses

func (context Context) SetOptInteger(group string, key string, value int) GError

SetOptInteger sets an integer parameter under group:key.

func (Context) SetOptString Uses

func (context Context) SetOptString(group string, key string, value string) GError

SetOptString sets a string parameter under group:key.

func (Context) SetOptStringList Uses

func (context Context) SetOptStringList(group string, key string, values []string) GError

SetOptStringList sets a string list parameter under group:key.

func (Context) SetUserAgent Uses

func (context Context) SetUserAgent(agent string, version string) GError

SetUserAgent sets the user agent. Not all protocols implement this.

func (Context) Setxattr Uses

func (context Context) Setxattr(url string, name string, value string, flags int) GError

Setxattr sets an extended attribute of a file. If flags is 1 (create), fail if the attribute already exists. If 2 (replace), fail if the attribute does not exist. If 0, the attribute will be set either way.

func (Context) Stat Uses

func (context Context) Stat(url string) (Stat, GError)

Stat a file.

func (context Context) Symlink(source string, target string) GError

Symlink creates a symlink.

type Dir Uses

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

Dir contains information about a directory entry.

func (Dir) Close Uses

func (dir Dir) Close() GError

Close the directory and frees the associated memory.

func (Dir) Readdir Uses

func (dir Dir) Readdir() (Stat, GError)

Readdir reads a single entry from the directory. For the last entry, it returns nil, nil

type DirEntry Uses

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

DirEntry models a directory entry.

func (DirEntry) AccessTime Uses

func (entry DirEntry) AccessTime() time.Time

AccessTime returns the access time of the file.

func (DirEntry) ChangeTime Uses

func (entry DirEntry) ChangeTime() time.Time

ChangeTime returns the modification time of the file.

func (DirEntry) Gid Uses

func (entry DirEntry) Gid() int

Gid returns the group id.

func (DirEntry) IsDir Uses

func (entry DirEntry) IsDir() bool

IsDir returns true if the file is a directory.

func (DirEntry) ModTime Uses

func (entry DirEntry) ModTime() time.Time

ModTime returns the modification time of the file.

func (DirEntry) Mode Uses

func (entry DirEntry) Mode() os.FileMode

Mode returns the permission bits for the file.

func (DirEntry) Name Uses

func (entry DirEntry) Name() string

Name returns the file name/

func (entry DirEntry) Nlink() int

Nlink returns the number of hard links, or files in a directory.

func (DirEntry) Size Uses

func (entry DirEntry) Size() int64

Size returns the file size.

func (DirEntry) Sys Uses

func (entry DirEntry) Sys() interface{}

Sys returns the internal representation.

func (DirEntry) Uid Uses

func (entry DirEntry) Uid() int

Uid returns the owner's user id.

type Event Uses

type Event struct {
    Side        int
    Timestamp   uint64
    Stage       string
    Domain      string
    Description string
}

Event stores the data passed to the event listener.

type EventListener Uses

type EventListener interface {
    NotifyEvent(event Event)
}

EventListener must be implemented by callbacks that want to be notified by events triggered inside gfal2.

type File Uses

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

File contains the required data to operate on a file.

func (File) Close Uses

func (fd File) Close() GError

Close a file and frees the associated memory.

func (File) Flush Uses

func (fd File) Flush() GError

Flush the Gfal2File.

func (File) Read Uses

func (fd File) Read(b []byte) (int, GError)

Read reads up to len(b) bytes from the Gfal2File. It returns the number of bytes read and an error, if any. EOF is signaled by a zero count. On error the count is negative.

func (File) Seek Uses

func (fd File) Seek(offset int64, whence int) (int64, GError)

Seek changes the cursor position in the Gfal2File. whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (File) Write Uses

func (fd File) Write(b []byte) (int, GError)

Write len(b) bytes from b into the Gfal2File. It returns the number of bytes written and an error, if any. On error the count is negative.

type GError Uses

type GError interface {
    // Domain of the error. For instance, the plugin that triggered it.
    Domain() string
    // Error code. Values can be the same as those for errno.
    Code() syscall.Errno
    // Error description.
    Error() string
}

GError contains error information coming from gfal2.

type LogListener Uses

type LogListener interface {
    Log(domain string, level int, msg string)
}

LogListener is the interface to be implemented by the log handlers.

type Marker Uses

type Marker struct {
    AvgThroughput     uint64
    InstantThroughput uint64
    BytesTransferred  uint64
    ElapsedTime       uint64
}

Marker stores the data passed to the monitor listener.

type MonitorListener Uses

type MonitorListener interface {
    NotifyPerformanceMarker(marker Marker)
}

MonitorListener must be implemented by callbacks that want to be notified by the transfer progress.

type Stat Uses

type Stat interface {
    Name() string       // base name of the file
    Size() int64        // length in bytes for regular files; system-dependent for others
    Mode() os.FileMode  // file mode bits
    ModTime() time.Time // modification time
    IsDir() bool        // abbreviation for Mode().IsDir()
    Sys() interface{}   // underlying data source (can return nil)

    Nlink() int // number of files in a directory/number of hard links
    Uid() int   // owner id
    Gid() int   // group id

    AccessTime() time.Time // access time
    ChangeTime() time.Time // modification time
}

Stat is a superset of os.FileInfo

type StatAndName Uses

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

StatAndName is a join of C stat and file name Implements gfal2.Stat and, therefore os.FileInfo

func (StatAndName) AccessTime Uses

func (stat StatAndName) AccessTime() time.Time

AccessTime returns the access time of the file.

func (StatAndName) ChangeTime Uses

func (stat StatAndName) ChangeTime() time.Time

ChangeTime returns the modification time of the file.

func (StatAndName) Gid Uses

func (stat StatAndName) Gid() int

Gid returns the group id.

func (StatAndName) IsDir Uses

func (stat StatAndName) IsDir() bool

IsDir returns true if the file is a directory.

func (StatAndName) ModTime Uses

func (stat StatAndName) ModTime() time.Time

ModTime returns the modification time of the file.

func (StatAndName) Mode Uses

func (stat StatAndName) Mode() os.FileMode

Mode returns the permission bits.

func (StatAndName) Name Uses

func (stat StatAndName) Name() string

Name returns the file name.

func (stat StatAndName) Nlink() int

Nlink returns the number of links that point to this file.

func (StatAndName) Size Uses

func (stat StatAndName) Size() int64

Size returns the file size.

func (StatAndName) Sys Uses

func (stat StatAndName) Sys() interface{}

Sys returns the internal representation.

func (StatAndName) Uid Uses

func (stat StatAndName) Uid() int

Uid returns the user id that owns the file.

type TransferHandler Uses

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

TransferHandler holds the data required to run the transfers.

func (TransferHandler) AddEventCallback Uses

func (params TransferHandler) AddEventCallback(listener EventListener) GError

AddEventCallback adds a function to be called when there are events triggered by the plugins.

func (TransferHandler) AddMonitorCallback Uses

func (params TransferHandler) AddMonitorCallback(listener MonitorListener) GError

AddMonitorCallback adds a function to be called with the performance markers data.

func (TransferHandler) Close Uses

func (params TransferHandler) Close() GError

Close destroys the TransferParameters.

func (TransferHandler) Copy Uses

func (params TransferHandler) Copy() (*TransferHandler, GError)

Copy the TransferParameters struct.

func (TransferHandler) CopyFile Uses

func (params TransferHandler) CopyFile(source string, destination string) GError

CopyFile copies the source file into destination. If the protocol supports it, it will be a third party copy. If the protocol does not support third party copies, then the data will be streamed via the local node.

func (TransferHandler) GetChecksum Uses

func (params TransferHandler) GetChecksum() (int, string, string)

GetChecksum returns the configured checksum type and value.

func (TransferHandler) GetChecksumMode Uses

func (params TransferHandler) GetChecksumMode() (int, GError)

GetChecksumMode returns the checksum mode to be used.

func (TransferHandler) GetCreateParentDir Uses

func (params TransferHandler) GetCreateParentDir() bool

GetCreateParentDir returns the value of the CreateParentDir flag.

func (TransferHandler) GetDestinationSpaceToken Uses

func (params TransferHandler) GetDestinationSpaceToken() string

GetDestinationSpaceToken returns the destination space token.

func (TransferHandler) GetNoStreams Uses

func (params TransferHandler) GetNoStreams() int

GetNoStreams returns the configured number of streams to be used for the transfer.

func (TransferHandler) GetOverwrite Uses

func (params TransferHandler) GetOverwrite() bool

GetOverwrite returns the value of the Overwrite flag.

func (TransferHandler) GetSourceSpaceToken Uses

func (params TransferHandler) GetSourceSpaceToken() string

GetSourceSpaceToken returns the source space token.

func (TransferHandler) GetStrictCopy Uses

func (params TransferHandler) GetStrictCopy() bool

GetStrictCopy returns the value of the StrictCopy flag.

func (TransferHandler) GetTCPBuffersize Uses

func (params TransferHandler) GetTCPBuffersize() int

GetTCPBuffersize returns the configured TCP buffer size.

func (TransferHandler) GetTimeout Uses

func (params TransferHandler) GetTimeout() int

GetTimeout returns the maximum time acceptable for the file transfer.

func (TransferHandler) SetChecksum Uses

func (params TransferHandler) SetChecksum(mode int, chktype string, chkvalue string) GError

SetChecksum sets a custom checksum type and value. If chkvalue is *not* empty, the source file will be validated prior to the transfer.

func (TransferHandler) SetCreateParentDir Uses

func (params TransferHandler) SetCreateParentDir(create bool) GError

SetCreateParentDir sets if the parent directory should be created or not if it doesn't exist.

func (TransferHandler) SetDestinationSpaceToken Uses

func (params TransferHandler) SetDestinationSpaceToken(token string) GError

SetDestinationSpaceToken sets the destination space token. Note that not all protocols implement this.

func (TransferHandler) SetNoStreams Uses

func (params TransferHandler) SetNoStreams(nostreams int) GError

SetNoStreams sets the maximum number of parallels connexion to use for the file transfer. Note that not all protocols implement this.

func (TransferHandler) SetOverwrite Uses

func (params TransferHandler) SetOverwrite(overwrite bool) GError

SetOverwrite sets if the destination file should be overwritten if it exists. If false, if the destination file exists, the transfer will fail.

func (TransferHandler) SetSourceSpacetoken Uses

func (params TransferHandler) SetSourceSpacetoken(token string) GError

SetSourceSpacetoken sets source space token. Note that not all protocols implement this.

func (TransferHandler) SetStrictCopy Uses

func (params TransferHandler) SetStrictCopy(strict bool) GError

SetStrictCopy sets if the transfer should do additional validation steps(true) or not. For instance, parent directory creation, checking the destination exists, checksum/size validation...

func (TransferHandler) SetTCPBuffersize Uses

func (params TransferHandler) SetTCPBuffersize(size int) GError

SetTCPBuffersize sets the TCP buffer size. 0 for system default. Note that not all protocols implement this.

func (TransferHandler) SetTimeout Uses

func (params TransferHandler) SetTimeout(timeout int) GError

SetTimeout sets the maximum time acceptable for the file transfer.

Package gfal2 imports 8 packages (graph). Updated 2017-03-10. Refresh now. Tools for package owners.