gluster

package module
v0.0.0-...-06fe134 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 7 Imported by: 4

README

go-billy-gluster GoDoc Build Status codecov.io

This package provides a basic go-billy driver to access gluster volumes. It uses libgfapi so it's not needed to mount the volume locally.

So far, following actions are implemented:

  • Create
  • Open
  • OpenFile
  • Stat
  • Rename
  • Remove
  • Readdir
  • MkdirAll

For more information head to the documentation

Installation

This package requires native libgfapi library that is contained in the development client packages of gluster.

  • Arch / Manjaro:
pacman -S glusterfs
  • Ubuntu / Debian:
apt-get install glusterfs-common
  • CentOS / RHEL:
yum install glusterfs-api

After installing the dependency you can install the library with go get:

go get gopkg.in/src-d/go-billy-gluster.v0

Example of utilization

package main

import (
	"fmt"

	"gopkg.in/src-d/go-billy-gluster.v0"
)

func main() {
	fs, err := gluster.New("server", "volume")
	if err != nil {
		panic(fmt.Sprintf("cannot connect to gluster volume %s", err))
	}

	f, err := fs.Create("filename.ext")
	if err != nil {
		panic(fmt.Sprintf("cannot create file %s", err))
	}

	_, err = f.Write([]byte("text"))
	if err != nil {
		panic(fmt.Sprintf("cannot write to file %s", err))
	}

	err = f.Close()
	if err != nil {
		panic(fmt.Sprintf("cannot close file %s", err))
	}

	err = fs.Close()
	if err != nil {
		panic(fmt.Sprintf("cannot disconnect from volume %s", err))
	}
}

Contribute

Contributions are more than welcome, if you are interested please take a look to our Contributing Guidelines.

Code of Conduct

All activities under source{d} projects are governed by the source{d} code of conduct.

License

Apache License Version 2.0, see LICENSE.

Documentation

Index

Constants

View Source
const (
	// ErrReadOnly returned when file is read only.
	ErrReadOnly = "cannot write in %s, the file is read only"
	// ErrWriteOnly returned when file is write only.
	ErrWriteOnly = "cannot read from %s, the file is write only"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS manages the filesystem of a gluster volume. It implements billy.Basic.

func New

func New(host, volume string) (*FS, error)

New creates a new FS connecting it to the specified host and volume.

func (*FS) Capabilities

func (g *FS) Capabilities() billy.Capability

Capabilities implements billy.Capable interface.

func (*FS) Close

func (g *FS) Close() error

Close unmounts the gluster volume associated to the FS.

func (*FS) Create

func (g *FS) Create(filename string) (billy.File, error)

Create implements billy.Basic interface.

func (*FS) Join

func (g *FS) Join(elem ...string) string

Join implements billy.Basic interface.

func (*FS) MkdirAll

func (g *FS) MkdirAll(filename string, perm os.FileMode) error

MkdirAll implements billy.Dir interface.

func (*FS) Open

func (g *FS) Open(filename string) (billy.File, error)

Open implements billy.Basic interface.

func (*FS) OpenFile

func (g *FS) OpenFile(
	filename string,
	flag int,
	perm os.FileMode,
) (billy.File, error)

OpenFile implements billy.Basic interface.

func (*FS) ReadDir

func (g *FS) ReadDir(path string) ([]os.FileInfo, error)

ReadDir implements billy.Dir interface.

func (*FS) Remove

func (g *FS) Remove(filename string) error

Remove implements billy.Basic interface.

func (*FS) Rename

func (g *FS) Rename(oldpath string, newpath string) error

Rename implements billy.Basic interface.

func (*FS) Stat

func (g *FS) Stat(filename string) (os.FileInfo, error)

Stat implements billy.Basic interface.

type File

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

File holds a gluster file descriptor.

func NewFile

func NewFile(name string, g *gfapi.File, flags int) *File

NewFile creates a new wrapped gluster file descriptor.

func (*File) Close

func (f *File) Close() error

Close implements billy.File interface.

func (*File) Lock

func (f *File) Lock() error

Lock implements billy.File interface. It is a no-op as it is not supported by gluster library.

func (*File) Name

func (f *File) Name() string

Name implements billy.File interface.

func (*File) Read

func (f *File) Read(p []byte) (int, error)

Read implements billy.File interface.

func (*File) ReadAt

func (f *File) ReadAt(p []byte, off int64) (int, error)

ReadAt implements billy.File interface.

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (int64, error)

Seek implements billy.File interface.

func (*File) Truncate

func (f *File) Truncate(size int64) error

Truncate implements billy.File interface.

func (*File) Unlock

func (f *File) Unlock() error

Unlock implements billy.File interface. It is a no-op as it is not supported by gluster library.

func (*File) Write

func (f *File) Write(p []byte) (int, error)

Write implements billy.File interface.

Jump to

Keyboard shortcuts

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