alluxio

package module
v0.0.0-...-d8c9fa5 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2017 License: Apache-2.0, BSD-2-Clause, EPL-1.0, + 1 more Imports: 11 Imported by: 0

README

Go Library for the Alluxio File System API

To get started, fetch the repository into your Go workspace using go get -d github.com/Alluxio/alluxio-go.

Your Go applications can then interact with Alluxio as follows:

package main

import (
        "fmt"
	"log"

	alluxio "github.com/Alluxio/alluxio-go"
	"github.com/Alluxio/alluxio-go/option"
)


func main() {
	fs := alluxio.NewClient(<proxy-host>, <proxy-port>, <timeout>)
	ok, err := fs.Exists("/test_path", &option.Exists{})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(ok)
}

For a list of all supported API calls, see https://github.com/Alluxio/alluxio-go/blob/master/paths.go.

Documentation

Overview

Package alluxio provides the Alluxio file system client.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}
Example (Download)
fs := NewClient("localhost", 39999, time.Minute)
id, err := fs.OpenFile("/test_file", &option.OpenFile{})
if err != nil {
	log.Fatal(err)
}
r, err := fs.Read(id)
if err != nil {
	log.Fatal(err)
}
defer r.Close()
defer fs.Close(id)
if _, err := io.Copy(ioutil.Discard, r); err != nil {
	log.Fatal(err)
}
Output:

Example (Exists)
fs := NewClient("localhost", 39999, time.Minute)
ok, err := fs.Exists("/test_path", &option.Exists{})
if err != nil {
	log.Fatal(err)
}
fmt.Println(ok)
Output:

Example (ListStatus)
fs := NewClient("localhost", 39999, time.Minute)
fileInfos, err := fs.ListStatus("/test_path", &option.ListStatus{})
if err != nil {
	log.Fatal(err)
}
for _, fileInfo := range fileInfos {
	fmt.Println(fileInfo.Name)
}
Output:

Example (Upload)
fs := NewClient("localhost", 39999, time.Minute)
id, err := fs.CreateFile("/test_file", &option.CreateFile{})
if err != nil {
	log.Fatal(err)
}
n, err := fs.Write(id, bytes.NewBuffer(make([]byte, 1024)))
if err != nil {
	log.Fatal(err)
}
defer fs.Close(id)
fmt.Println(n)
Output:

func NewClient

func NewClient(host string, port int, timeout time.Duration) *Client

NewClient is the Alluxio file system client factory.

func (*Client) Close

func (client *Client) Close(id int) error

Close closes a stream.

func (*Client) CreateDirectory

func (client *Client) CreateDirectory(path string, options *option.CreateDirectory) error

CreateDirectory creates a directory.

func (*Client) CreateFile

func (client *Client) CreateFile(path string, options *option.CreateFile) (int, error)

CreateFile creates a file, returning a stream id.

func (*Client) Delete

func (client *Client) Delete(path string, options *option.Delete) error

Delete deletes a path.

func (*Client) Exists

func (client *Client) Exists(path string, options *option.Exists) (bool, error)

Exists checks whether a path exists.

func (*Client) Free

func (client *Client) Free(path string, options *option.Free) error

Free frees a path.

func (*Client) GetStatus

func (client *Client) GetStatus(path string, options *option.GetStatus) (*wire.FileInfo, error)

GetStatus gets a path status.

func (*Client) ListStatus

func (client *Client) ListStatus(path string, options *option.ListStatus) (wire.FileInfos, error)

ListStatus lists path statuses.

func (*Client) Mount

func (client *Client) Mount(path, src string, options *option.Mount) error

Mount mounts a UFS source to a path.

func (*Client) OpenFile

func (client *Client) OpenFile(path string, options *option.OpenFile) (int, error)

OpenFile opens a file, returning a stream id.

func (*Client) Read

func (client *Client) Read(id int) (io.ReadCloser, error)

Read reads from a stream.

func (*Client) Rename

func (client *Client) Rename(path, dst string, options *option.Rename) error

Rename renames a path.

func (*Client) SetAttribute

func (client *Client) SetAttribute(path string, options *option.SetAttribute) error

SetAttribute sets path attributes.

func (*Client) Unmount

func (client *Client) Unmount(path string, options *option.Unmount) error

Unmount unmounts a path.

func (*Client) Write

func (client *Client) Write(id int, input io.Reader) (int, error)

Write writes to a stream.

Directories

Path Synopsis
Package option contains types for method options.
Package option contains types for method options.
Package optiontest contains utilities for testing method options.
Package optiontest contains utilities for testing method options.
Package wire contains Alluxio file system wire types.
Package wire contains Alluxio file system wire types.
Package wiretest contains utilites for testing Alluxio file system wire types.
Package wiretest contains utilites for testing Alluxio file system wire types.

Jump to

Keyboard shortcuts

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