Documentation ¶
Index ¶
- Variables
- func NewLimitedWriter(w io.Writer, l int64) *limitedWriter
- type Filesystem
- func (fs *Filesystem) Collect(name string, r io.Reader) (int64, error)
- func (fs *Filesystem) Create(name string) (Record, error)
- func (fs *Filesystem) Init() error
- func (fs *Filesystem) Open(name string) (Record, error)
- func (fs *Filesystem) Partition(number int64) (Store, error)
- func (fs *Filesystem) Place(name string, w io.Writer) (int64, error)
- func (fs *Filesystem) Remove(name string) error
- func (fs *Filesystem) Stat(name string) (os.FileInfo, error)
- type Null
- func (nl *Null) Collect(_ string, r io.Reader) (int64, error)
- func (nl *Null) Create(_ string) (Record, error)
- func (nl *Null) Init() error
- func (nl *Null) Open(_ string) (Record, error)
- func (nl *Null) Partition(_ int64) (Store, error)
- func (nl *Null) Place(_ string, _ io.Writer) (int64, error)
- func (nl *Null) Remove(_ string) error
- func (nl *Null) Stat(_ string) (os.FileInfo, error)
- type Record
- type Store
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func NewLimitedWriter ¶
NewLimitedWriter wraps the given io.Writer, and applies a limit of l to the number of bytes that can be written to it.
Types ¶
type Filesystem ¶
type Filesystem struct {
// contains filtered or unexported fields
}
Filesystem provides an implementation of the Store interface for the operating system's native filesystem. This will allow the storing of the Records in a given directory of the filesystem with any given limit.
func NewFilesystem ¶
func NewFilesystem(dir string) *Filesystem
NewFilesystem returns a new Filesystem store using the given directory as the location to store Records. This will not put any limit on the size of Records that can be stored.
func NewFilesystemWithLimit ¶
func NewFilesystemWithLimit(dir string, l int64) *Filesystem
NewFilesystemWithLimit returns a new Filesystem store using the given directory as the location to store Records. This will put a limit on the size of the Records that can be stored. If the given limit is 0, then no limit is set.
func (*Filesystem) Collect ¶
Collect reads the contents of the given io.Reader stream, and stores it in a file with the given name. If the Limit for the filesystem is set to 0, then no limit is placed on the number of bytes read from the stream.
func (*Filesystem) Create ¶
func (fs *Filesystem) Create(name string) (Record, error)
Create will create a new file on the filesystem in the configured directory, and return a Record for that file.
func (*Filesystem) Init ¶
func (fs *Filesystem) Init() error
Init checks to see if the location in the filesystem is a directory and can be accessed.
func (*Filesystem) Open ¶
func (fs *Filesystem) Open(name string) (Record, error)
Open will open an existing file on the filesystem in the configured directory, and return a Record for that file.
func (*Filesystem) Partition ¶
func (fs *Filesystem) Partition(number int64) (Store, error)
Partition will create a new directory in the current Filesystem with the given number and returns it as a new Filesystem Store.
func (*Filesystem) Place ¶
Place writes the contents of the file for the given name into the given io.Writer. If the Limit for the filesystem is set to 0, then no limit is placed on the number of bytes written to the stream.
func (*Filesystem) Remove ¶
func (fs *Filesystem) Remove(name string) error
Remove will remove an existing file on the filesystem in the configured directory.
type Null ¶
type Null struct {
// contains filtered or unexported fields
}
Null provides an implementation of the Store interface for working with zero value Records of data. This is typically used for testing if you don't particularly care about what happens to the data being stored. This is the only implementation that won't return an error for the Place, Stat, Init, Create, Open, or Remove methods.
Any reads that are performed on a Record returned from a Null Store will zero out the given byte slice.
func (*Null) Create ¶
Create returns a new null Record that will write everything to ioutil.Discard.
type Record ¶
Record represents an arbitrary record of data that can be held in a Store. A Record can be used as an io.Writer, io.Reader, io.Seeker, and io.Closer.
io.Writer - A Record should operate as a normal implementation of io.Writer where it writes len(p) number of bytes into the underlying data source. If a Record has a limit on the number of bytes that can be written to it, then the Write method should return ErrWriteLimit when that limit is reached or exceeded. Any subsequent writes to a closed Record should return ErrRecordClosed.
io.Reader - A Record should operate as a normal implementation of io.Reader where it reads len(p) number of bytes into p from the underlying data source. If a subsequent read is made to a closed Record, then Read should return ErrRecordClosed.
io.Seeker - A Record should operate as a normal implementation of io.Seeker where it goes to the specified offset based off the specified whence. If a subsequent seek is made to a closed Record, then Seek should return ErrRecordClosed.
io.Closer - When a Record is closed this should prevent subsequent reads, writes, and seeks from happening. Any subsequent calls to Close on a closed Record should return ErrRecordClosed.
type Store ¶
type Store interface { runner.Collector runner.Placer // Init initializes the Store for creating, retrieving, and removing // Records of data. Init() error // Partition retrieves a partition in the current Store and returns it. If // the given partition does not exist, then one should be created and then // returned. Partition(int64) (Store, error) // Create creates a new Record in the store with the given name. If a Record // of any given name already exists then ErrRecordExists should be returned. Create(string) (Record, error) // Open returns an existing Record from the Store with the given name. If // Record does not exist, then ErrRecordNotFound should be returned. Open(string) (Record, error) // Remove removes an existing Record from the Store with the given name. If // the Record does not exist, then ErrRecordNotFound should be returned. Remove(string) error }
Store represents an arbitrary store of data. Each object within the Store is represented via the Record interface. Each store should also implement the runner.Collector and runner.Placer interfaces.