weedharvester

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

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

Go to latest
Published: Mar 17, 2017 License: MIT Imports: 10 Imported by: 0

README

Build Status

Weedharvester

An client API for SeaweedFS

Getting Started

First Start SeaweedFS. You will need to make an entry in your /etc/hosts with docker and the ip adress of your docker container.

This lib was tested for SeaweedFS version 0.70 linux There is no option to set replication within the lib but you can always set the default replication of seaweedFS.

To start SeaweedFS use

make start-seaweed

To check if everything is working correctly run tests with

go test

If your using a different url for master and filer just hand the base url in at testing.

go test --master http://docker:9333 --filer http://docker:8888

Client

client := NewClient("http://masterurl.com")

fid, err := client.Create(reader)
reader := client.Read(fid)

Filer

filer := NewFiler("http://filerurl.com")

err := filer.Create(reader, filename, path)
reader := filer.Read(filename, path)

Documentation

Index

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
}

Client represents a SeaweedFS client

func NewClient

func NewClient(url string) Client

NewClient creates a new client. The given url has to be the address of the master server

func (*Client) Create

func (c *Client) Create(content io.Reader) (string, error)

Create creates a file for the given content within the SeaweedFS

func (*Client) Delete

func (c *Client) Delete()

Delete deletes the file with the given fileId

func (*Client) Read

func (c *Client) Read(fileID string) (io.Reader, error)

Read reads file with a given fileId

type Directory

type Directory struct {
	Directory      string         `json:"path"`
	Files          []file         `json:"Files"`
	Subdirectories []subdirectory `json:"Subdirectories"`
}

Directory represents a directory mapped from the seaweed filer

type Filer

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

Filer represents a filer for SeaweedFS

func NewFiler

func NewFiler(url string) Filer

NewFiler creates a new Filer with the given url as the host address

func (*Filer) Create

func (f *Filer) Create(content io.Reader, filename string, path string) error

Create creates a new file with the given content name and under the given path

func (*Filer) Delete

func (f *Filer) Delete(filename string, path string) error

Delete deletes the file under the given path

func (*Filer) DeleteFilesUntil

func (f *Filer) DeleteFilesUntil(path string, lastFileName string) error

DeleteFilesUntil deletes all file under the given path until the given filename

func (*Filer) Ping

func (f *Filer) Ping() error

Ping checks wether the filer with the given url can be reached or not

func (*Filer) Read

func (f *Filer) Read(filename string, path string) (io.Reader, error)

func (*Filer) ReadDirectory

func (f *Filer) ReadDirectory(path string, lastFileName string) (*Directory, error)

ReadDirectory returns all files contained in a given directory

Jump to

Keyboard shortcuts

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