This repo contains a client implementation of Distributed File System. It provides a library written in Go with a simple implementation in app.go for means of an example.
-
Setup Go
-
Install Go >=1.3.3
-
Navigate to a directory that will contain your Go directory
-
Create the folder hierarchy
mkdir -p go/{src,bin,pkg}
-
Set this directory to be your GOPATH environment variable from 3.
export GOPATH="Your/go/directory"
-
Export go/bin to your bath PATH
export PATH=$PATH:$GOPATH/bin
-
-
Download the code
go get github.com/conorbrady/dfs-client
import "github.com/conorbrady/dfs-client/dfs"
func Connect(
authServAdd string, // Address for authentication server
dirServAdd string, // Address for directory server
username string, // Username for authentication with the AS
password string, // Password for authentication with the AS
caching bool // Enable file caching
) *DFS // Returns an instance that can be used to open files on the system
func (d* DFS)Open(
filename string // Filename of the file
) (*File, error) // Returns a file or nil and an error
// Implements io.Reader Interface
func (f* File)Read(
p []byte
) (n int, err error)
// Implements io.Writer Interface
func (f* File)Write(
p []byte
) (n int, err error)
Install the code.
go install github.com/conorbrady/dfs-client
Once you have added go/bin to your PATH you can run the code from any directory. Command line options are:
-AS <address>
This must be specified to be the address of an instance of the accompanying
Distributed File System run in -mode AS
-DS <address>
This must be specified to be the address of an instance of the accompanying
Distributed File System run in -mode DS
-caching <0 or 1>
This either enables or disables caching on the system