Documentation ¶
Overview ¶
Go client for cbfs
Most storage operations are simple HTTP PUT, GET or DELETE operations. Convenience operations are provided for easier access.
Index ¶
- Variables
- type BlobInfo
- type Client
- func (c *Client) Blobs(totalConcurrency, destinationConcurrency int, cb FetchCallback, oids ...string) error
- func (c Client) Get(path string) (io.ReadCloser, error)
- func (c Client) GetBlobInfos(oids ...string) (map[string]BlobInfo, error)
- func (c Client) GetConfig() (rv cbfsconfig.CBFSConfig, err error)
- func (c Client) List(ustr string) (ListResult, error)
- func (c Client) ListDepth(ustr string, depth int) (ListResult, error)
- func (c Client) ListOrEmpty(ustr string) (ListResult, error)
- func (c *Client) Nodes() (map[string]StorageNode, error)
- func (c Client) OpenFile(path string) (*FileHandle, error)
- func (c Client) Put(srcname, dest string, r io.Reader, opts PutOptions) error
- func (c *Client) RandomNode() (string, StorageNode, error)
- func (c Client) Rm(fn string) error
- func (c Client) SetConfigParam(key, val string) error
- func (c Client) URLFor(fn string) string
- type Dir
- type FetchCallback
- type FileHandle
- func (f *FileHandle) Close() error
- func (*FileHandle) IsDir() bool
- func (f *FileHandle) Meta() FileMeta
- func (f *FileHandle) ModTime() time.Time
- func (*FileHandle) Mode() os.FileMode
- func (f *FileHandle) Name() string
- func (f *FileHandle) Nodes() map[string]time.Time
- func (f *FileHandle) Read(b []byte) (int, error)
- func (f *FileHandle) ReadAt(p []byte, off int64) (n int, err error)
- func (f *FileHandle) Seek(offset int64, whence int) (ret int64, err error)
- func (f *FileHandle) Size() int64
- func (*FileHandle) Sys() interface{}
- func (f *FileHandle) WriteTo(w io.Writer) (int64, error)
- type FileMeta
- type ListResult
- type PrevMeta
- type PutOptions
- type StorageNode
Constants ¶
This section is empty.
Variables ¶
var Missing = errors.New("file missing")
When a file is missing.
Functions ¶
This section is empty.
Types ¶
type BlobInfo ¶
type BlobInfo struct { // Map of node name -> last time the object was validated Nodes map[string]time.Time }
Blob info as returned from GetBlobInfos
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A cbfs client.
func (*Client) Blobs ¶
func (c *Client) Blobs(totalConcurrency, destinationConcurrency int, cb FetchCallback, oids ...string) error
Fetch many blobs in bulk.
func (Client) Get ¶
func (c Client) Get(path string) (io.ReadCloser, error)
Grab a file.
This ensures the request is coming directly from a node that already has the blob vs. proxying.
func (Client) GetBlobInfos ¶
Find out what nodes contain the given blobs.
func (Client) ListDepth ¶
func (c Client) ListDepth(ustr string, depth int) (ListResult, error)
List the contents below the given location.
func (Client) ListOrEmpty ¶
func (c Client) ListOrEmpty(ustr string) (ListResult, error)
Same as List, but return an empty result on 404.
func (*Client) Nodes ¶
func (c *Client) Nodes() (map[string]StorageNode, error)
Get the information about the nodes in a cluster.
func (Client) OpenFile ¶
func (c Client) OpenFile(path string) (*FileHandle, error)
Get a reference to the file at the given path.
func (Client) Put ¶
Put some content in CBFS.
The sourcename is optional and is used for content type detection (if not specified in options).
The dest filename is the name that the file will have in cbfs.
The io.Reader is the source of content.
Options are optional.
func (*Client) RandomNode ¶
func (c *Client) RandomNode() (string, StorageNode, error)
func (Client) SetConfigParam ¶
Set a configuration parameter by name.
type Dir ¶
type Dir struct { Descendants int // Number of descendants. Largest int64 // Size of largest file. Size int64 // Total size of all files. Smallest int64 // Size of smallest file. }
Represents a directory as returned from a List operation.
type FileHandle ¶
type FileHandle struct {
// contains filtered or unexported fields
}
File info
func (*FileHandle) Close ¶
func (f *FileHandle) Close() error
func (*FileHandle) ModTime ¶
func (f *FileHandle) ModTime() time.Time
Last modification time of this file
func (*FileHandle) Name ¶
func (f *FileHandle) Name() string
func (*FileHandle) Nodes ¶
func (f *FileHandle) Nodes() map[string]time.Time
The nodes containing the files and the last time it was scrubed.
func (*FileHandle) ReadAt ¶
func (f *FileHandle) ReadAt(p []byte, off int64) (n int, err error)
Implement io.ReaderAt
type FileMeta ¶
type FileMeta struct { Headers http.Header `json:"headers"` // Headers OID string `json:"oid"` // Hash Length int64 `json:"length"` // Length // User-supplied JSON Userdata *json.RawMessage `json:"userdata,omitempty"` // Last modified time Modified time.Time `json:"modified"` // Recorded previous versions Previous []PrevMeta `json:"older"` // Current revision number Revno int `json:"revno"` }
Current file meta.
type ListResult ¶
type ListResult struct { Dirs map[string]Dir // Immediate directories Files map[string]FileMeta // Immediate files }
Results from a list operation.
type PrevMeta ¶
type PrevMeta struct { Headers http.Header `json:"headers"` // Headers OID string `json:"oid"` // Hash Length float64 `json:"length"` // Length Modified time.Time `json:"modified"` // Modified date Revno int `json:"revno"` // Revision number }
Meta information from a previous revision of a file.
type PutOptions ¶
type PutOptions struct { // If true, do a fast, unsafe store Unsafe bool // Expiration time Expiration int // Hash to verify ("" for no verification) Hash string // Content type (detected if not specified) ContentType string // Optional reader transform (e.g. for encryption) ContentTransform func(r io.Reader) io.Reader // contains filtered or unexported fields }
Options for storing data.
func (*PutOptions) SetKeepRevs ¶
func (p *PutOptions) SetKeepRevs(to int)
Specify the number of revs to keep of this object.
type StorageNode ¶
type StorageNode struct { Addr string AddrRaw string `json:"addr_raw"` Started time.Time `json:"starttime"` HBTime time.Time `json:"hbtime"` BindAddr string FrameBind string HBAgeStr string `json:"hbage_str"` Used int64 Free int64 Size int64 UptimeStr string `json:"uptime_str"` Version string }
Representation of a storage node.
func (StorageNode) BlobURL ¶
func (a StorageNode) BlobURL(h string) string
func (StorageNode) URLFor ¶
func (a StorageNode) URLFor(h string) string