m3

package module
v0.0.0-...-4f25a1b Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2015 License: Apache-2.0 Imports: 6 Imported by: 2

README

m3 GoDoc Build Status Coverage Status

A set of file reader/writer middlewares

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsafeOperation = errors.New("unsafe operation")

Functions

func NoSyncOnWrite

func NoSyncOnWrite(file *os.File) io.WriteCloser

NoSyncOnWrite is a non-op write strategy. It does not modify the writes to the file.

func SyncOnWrite

func SyncOnWrite(file *os.File) io.WriteCloser

SyncOnWrite syncs the file to permanent storage after every write. While this can be used to increase durability, performance suffers.

Types

type ReadCombiner

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

func (*ReadCombiner) Close

func (c *ReadCombiner) Close() error

func (*ReadCombiner) Read

func (c *ReadCombiner) Read(data []byte) (int, error)

type Reader

type Reader interface {
	io.ReadCloser

	// Use provides middleware for the internal `io.ReadCloser`
	Use(...ReaderMiddleware)
}

Reader implements `io.ReadCloser` and adds another method for stacking middleware.

func NewFileReader

func NewFileReader(file *os.File) Reader

NewFileReader creates a new Reader from an `os.File` handle. When Close() is called on the Writer the file is also closed assuming all middleware forward the Close request.

func NewReader

func NewReader(r io.ReadCloser) Reader

NewReader creates a Reader from an existing `io.ReadCloser`.

type ReaderMiddleware

type ReaderMiddleware func(io.ReadCloser) io.ReadCloser

ReaderMiddleware wraps an `io.ReadCloser` with additional functionality and returns a new `io.ReadCloser`. These functions are meant to be stack on top of one another for more complex data patterns and abstractions when reading data.

func NewBufferedReader

func NewBufferedReader(size int) ReaderMiddleware

NewBufferedReader creates a ReaderMiddleware based on bufio.Reader.

type WriteCombiner

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

func (*WriteCombiner) Close

func (c *WriteCombiner) Close() error

func (*WriteCombiner) Write

func (c *WriteCombiner) Write(data []byte) (int, error)

type WriteStrategy

type WriteStrategy func(file *os.File) io.WriteCloser

WriteStrategy modifies how writes are made to a file. This function type takes an `os.File` and returns a new `io.WriteCloser`

type Writer

type Writer interface {
	io.WriteCloser

	// Use provides middleware for the internal `io.WriteCloser`
	Use(...WriterMiddleware)
}

Writer implements `io.WriteCloser` and adds another method for stacking middleware.

func NewFileWriter

func NewFileWriter(file *os.File, strategy WriteStrategy) Writer

NewFileWriter creates a new Writer from an `os.File` handle and a WriteStrategy. When Close() is called on the Writer the file is also closed assuming all middleware forward the Close request.

func NewMemMapAppender

func NewMemMapAppender(file *os.File, blockSize int, offset int64) (Writer, error)

func NewWriter

func NewWriter(w io.WriteCloser) Writer

NewWriter creates a Writer from an existing `io.WriteCloser`.

type WriterMiddleware

type WriterMiddleware func(io.WriteCloser) io.WriteCloser

WriterMiddleware wraps an `io.WriteCloser` with additional functionality and returns a new `io.WriteCloser`. These functions are meant to stact on top of one another for more complex data patterns and abstractions when writing data.

func NewBufferedWriter

func NewBufferedWriter(size int) WriterMiddleware

NewBufferedWriter creates a buffered writer with the given buffer size. A `WriterMiddleware` is returned which wraps the given `io.WriteCloser` in a `bufio.Writer`. On Close the buffer is flushed and the Close method is forwarded.

Directories

Path Synopsis
Godeps
_workspace/src/github.com/edsrzf/mmap-go
Package mmap allows mapping files into memory.
Package mmap allows mapping files into memory.
_workspace/src/github.com/stretchr/testify/assert
A set of comprehensive testing tools for use with the normal Go testing system.
A set of comprehensive testing tools for use with the normal Go testing system.

Jump to

Keyboard shortcuts

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