Documentation ¶
Index ¶
- Constants
- Variables
- func JHashFromName(jname string) uint64
- type ChnksController
- type Controller
- type ControllerVisitorF
- type Iterator
- type JIterator
- func (it *JIterator) Close() error
- func (it *JIterator) CurrentPos() records.IteratorPos
- func (it *JIterator) Get(ctx context.Context) (records.Record, error)
- func (it *JIterator) Next(ctx context.Context)
- func (it *JIterator) Pos() Pos
- func (it *JIterator) Release()
- func (it *JIterator) SetBackward(bkwrd bool)
- func (it *JIterator) SetPos(pos Pos)
- func (it *JIterator) String() string
- type Journal
- type OnChunkDeleteF
- type Pos
Constants ¶
View Source
const JOURNAL_NAME_REGEX = ".+"
Variables ¶
View Source
var NameRegExp *regexp.Regexp
Functions ¶
func JHashFromName ¶
JidFromName returns a journal id (jid) by its name
Types ¶
type ChnksController ¶
type ChnksController interface { // JournalName returns the jounal name it controls JournalName() string // GetChunkForWrite returns chunk for write operaion, the call could // be cancelled via ctx. The excludeCid could contain the chunk.Id which should // not be returned. Providing excludeCid the client indicates that it already // tries to write to the chunk and the operation was not successful, so it should not // be repeated. // ctx == nil is acceptable GetChunkForWrite(ctx context.Context, excludeCid chunk.Id) (chunk.Chunk, error) // Chunks returns a sorted list of chunks. ctx can cancel the call. ctx // could be nil. Chunks(ctx context.Context) (chunk.Chunks, error) // WaitForNewData waits till new data appears in the journal, or the // ctx is closed. Will return an error if any. or indicates the new // data is added to the journal WaitForNewData(ctx context.Context, pos Pos) error // DeleteChunk marks the journal's chunk with Id <= lastCid as deleted. The cdf will be called as soon as a chunk // will be marked as deleted. The DeleteChunk doesn't delete the chunk data physically, but it gets the chunk out from // the service loop. The callback function could either delete the data or archive it. // The function returns number of chunks makred as deleted or an error, if any DeleteChunks(ctx context.Context, lastCid chunk.Id, cdf OnChunkDeleteF) (int, error) // LocalFolder returns the folder on the FS where all the chunks are stored LocalFolder() string }
ChnksController allows to create and access to the journal's chunks, it is used by the journal.journal implementation.
type Controller ¶
type Controller interface { // Visit iterate over all known journals and it calls the cv for every journal found. Iteration is // stopped when all journals are visited or cv returns false Visit(ctx context.Context, cv ControllerVisitorF) // GetOrCreate creates new, or gives an access to existing journal GetOrCreate(ctx context.Context, jname string) (Journal, error) // Delete removes the internal record, but doesn't touch the journal data. // an error could be returned if there are alive chunks registered. The journal could be // re-created following up calls by GetOrCreate Delete(ctx context.Context, jname string) error }
Controller provides an access to known journals
Clients should use the interface for accessing to journals and their states
type ControllerVisitorF ¶
ControllerVisitor is a func which will be called by Visit() function (see Controller). It must return false if the process should be stopped
type Iterator ¶
type Iterator interface { io.Closer records.Iterator Pos() Pos // SetPos allows to change the JIterator position SetPos(pos Pos) }
Iterator interface provides a journal JIterator
type JIterator ¶
type JIterator struct {
// contains filtered or unexported fields
}
func NewJIterator ¶
func (*JIterator) CurrentPos ¶
func (it *JIterator) CurrentPos() records.IteratorPos
func (*JIterator) SetBackward ¶
type Journal ¶
type Journal interface { // Name returns the journal name Name() string // Write - writes records received from the JIterator to the journal. // It returns number of records written, next record write position and an error if any Write(ctx context.Context, rit records.Iterator) (int, Pos, error) // Size returns the summarized chunks' size Size() uint64 // Count returns number of records in the journal Count() uint64 // Sync could be called after a write to sync the written data with the // storage to be sure the read will be able to read the new added // data Sync() // ChnksController returns ChnksController for the journal Chunks() ChnksController }
Journal interface describes a journal
type OnChunkDeleteF ¶
OnChunkDeleteF is callback function provided to ChnksController.DeleteChunk. It will be invoked as soon as the chunk is marked as deleted.
Click to show internal directories.
Click to hide internal directories.