Documentation
¶
Overview ¶
The transactor package contains the APIs for writing facts to storage.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrCanceled = errors.New("transactor: canceled") ErrNoID = errors.New("transactor: could not create tx id") ErrCommitConflict = errors.New("transactor: commit conflict") ErrReceiveTimeout = errors.New("transactor: receive timeout") ErrNoDomain = errors.New("transactor: no fact domain") ErrCouldNotRoute = errors.New("transactor: could not route") )
var DefaultOptions = Options{ ReceiveWait: time.Minute, BufferSize: 1000, AllowDuplicates: false, }
DefaultOptions hold the default options for a transaction.
var ErrCommitted = errors.New("transactor: segment already committed")
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { ID uint64 StartTime time.Time EndTime time.Time Duration time.Duration Domains []*Stats Bytes int Count int }
Info holds information about a transaction.
type Options ¶
type Options struct { // Default domain for unbounded facts. If this is ommitted and a fact // does not specify a domain, an error will occur. DefaultDomain string // Duration of time wait to receive facts before timing out the transaction. ReceiveWait time.Duration // Defines the buffer size of the channel that receives facts for processing. // Increasing this may increase throughput at the expense of memory. BufferSize int // If true, a zeroed fact time will be set to the transaction start time. This // is useful for facts that are considered "new in the world". SetDefaultTime bool // If true, duplicates will facts will be written to storage. AllowDuplicates bool }
Options are used to supply default values as well as alter the behavior of a running transaction.
type Pipeline ¶
type Pipeline struct { Domain string // contains filtered or unexported fields }
A Pipeline does the actual work of processing and writing facts to storage.
func (*Pipeline) Commit ¶
Commit takes a storage transaction and writes any headers or indexes to make the transacted facts visible. A storage transaction is passed in to enable the writes to occur atomically which ensures consistency of the transacted facts.
func (*Pipeline) Init ¶
func (p *Pipeline) Init(tx *Transaction) error
Init initializes the pipeline for the transaction.
type Segment ¶
type Segment struct { // Embed DAL segment for simpler access. dal.Segment Engine storage.Engine // contains filtered or unexported fields }
Segment represents a transacted set of facts. Segments are broken up into fixed-sized blocks to facilitate flushing the data to disk during a long-running transaction. Each segment maintains the basis
func NewSegment ¶
NewSegment initializes a new segment for writing.
func (*Segment) Abort ¶
Abort aborts the segment and attempts to delete all data that has been written to storage.
type Stats ¶
type Stats struct { Domain string // Total number of blocks. Blocks int // Total of number bytes. Bytes int // Total number of facts. Count int }
Stats contains information about a pipeline.
type Transaction ¶
type Transaction struct { // Unique ID for the transaction. ID uint64 // The start and end time of transaction. StartTime time.Time EndTime time.Time // Error during the transaction and commit error. Error error CommitError error Engine storage.Engine // contains filtered or unexported fields }
Transaction is the entrypoint for transacting facts.
func New ¶
func New(engine storage.Engine, options Options) (*Transaction, error)
New initializes and returns a transaction for passed storage engine. The options are used to change the behavior of the transaction itself.
func (*Transaction) Commit ¶
func (tx *Transaction) Commit() error
Commit commits the transaction. All head of all affected logs will be atomically updated to make the transacted data visible to clients.
func (*Transaction) Info ¶
func (tx *Transaction) Info() *Info
Stats returns the stats of the transaction which aggregates them from the pipelines.