Documentation ¶
Index ¶
- func Debug(context, msg string)
- func Fatal(context, msg string, err error)
- func Info(context, action string)
- func ParseLevel(level string, defaultLevel zerolog.Level) zerolog.Level
- func ResponseHandler(w http.ResponseWriter, r *http.Request, data []byte)
- type Batch
- func (b *Batch) Abort()
- func (b *Batch) Commit() error
- func (b *Batch) Delete(id, topic []byte) error
- func (b *Batch) DeleteEntry(e *Entry) error
- func (b *Batch) Put(topic, payload []byte) error
- func (b *Batch) PutEntry(e *Entry) error
- func (b *Batch) SetOptions(opts ...Options)
- func (b *Batch) Write() error
- type DB
- func (db *DB) Batch(fn func(*Batch, <-chan struct{}) error) error
- func (db *DB) Close() error
- func (db *DB) Count() uint64
- func (db *DB) Delete(id, topic []byte) error
- func (db *DB) DeleteEntry(e *Entry) error
- func (db *DB) FileSize() (int64, error)
- func (db *DB) Get(q *Query) (items [][]byte, err error)
- func (db *DB) HandleVarz(w http.ResponseWriter, r *http.Request)
- func (db *DB) NewContract() (uint32, error)
- func (db *DB) NewID() []byte
- func (db *DB) Put(topic, payload []byte) error
- func (db *DB) PutEntry(e *Entry) error
- func (db *DB) Sync() error
- func (db *DB) Varz() (*Varz, error)
- type Entry
- type Filter
- type Meter
- type Options
- func WithBackgroundKeyExpiry() Options
- func WithBatchContract(contract uint32) Options
- func WithBatchEncryption() Options
- func WithBatchWriteInterval(dur time.Duration) Options
- func WithBufferSize(size int64) Options
- func WithDefaultBatchOptions() Options
- func WithDefaultFlags() Options
- func WithDefaultOptions() Options
- func WithDefaultQueryLimit(limit int) Options
- func WithDefaultQueryOptions() Options
- func WithEncryption() Options
- func WithEncryptionKey(key []byte) Options
- func WithFreeBlockSize(size int64) Options
- func WithMaxQueryLimit(limit int) Options
- func WithMaxSyncDuration(dur time.Duration, interval int) Options
- func WithMemdbSize(size int64) Options
- func WithMutable() Options
- type Query
- type Varz
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(context, msg string)
Debug logs the debug message with tag if it is turned on.
func ParseLevel ¶
ParseLevel parses a string which represents a log level and returns a zerolog.Level.
func ResponseHandler ¶
func ResponseHandler(w http.ResponseWriter, r *http.Request, data []byte)
ResponseHandler handles responses for monitoring routes.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch is a write batch.
func (*Batch) Abort ¶
func (b *Batch) Abort()
Abort abort is a batch cleanup operation on batch complete.
func (*Batch) Commit ¶
Commit commits changes to the DB. In batch operation commit is managed and client is not allowed to call Commit. On Commit complete batch operation signal to the caller if the batch is fully committed to DB.
func (*Batch) Delete ¶
Delete appends delete entry to batch for given key. It is safe to modify the contents of the argument after Delete returns but not before.
func (*Batch) DeleteEntry ¶
DeleteEntry appends entry for deletion to a batch for given key. It is safe to modify the contents of the argument after Delete returns but not before.
func (*Batch) Put ¶
Put adds entry to batch for given topic->key/value. Client must provide Topic to the BatchOptions. It is safe to modify the contents of the argument after Put returns but not before.
func (*Batch) PutEntry ¶
PutEntry appends entries to a bacth for given topic->key/value pair. It is safe to modify the contents of the argument after Put returns but not before.
func (*Batch) SetOptions ¶
SetOptions sets batch options.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents the message storage for topic->keys-values. All DB methods are safe for concurrent use by multiple goroutines.
func (*DB) Batch ¶
Batch executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is written. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the write is returned from the Batch() method.
Attempting to manually commit or rollback within the function will cause a panic.
func (*DB) Delete ¶
Delete sets entry for deletion. It is safe to modify the contents of the argument after Delete returns but not before.
func (*DB) DeleteEntry ¶
DeleteEntry deletes an entry from DB. you must provide an ID to delete an entry. It is safe to modify the contents of the argument after Delete returns but not before.
func (*DB) HandleVarz ¶
func (db *DB) HandleVarz(w http.ResponseWriter, r *http.Request)
HandleVarz will process HTTP requests for unitdb stats information.
func (*DB) NewContract ¶
NewContract generates a new Contract.
func (*DB) Put ¶
Put puts entry into DB. It uses default Contract to put entry into DB. It is safe to modify the contents of the argument after Put returns but not before.
func (*DB) PutEntry ¶
PutEntry puts entry into the DB, if Contract is not specified then it uses master Contract. It is safe to modify the contents of the argument after PutEntry returns but not before.
type Entry ¶
type Entry struct { ID []byte // The ID of the message. Topic []byte // The topic of the message. Payload []byte // The payload of the message. ExpiresAt uint32 // The time expiry of the message. Contract uint32 // The contract is used to as salt to hash topic parts and also used as prefix in the message ID. Encryption bool // contains filtered or unexported fields }
Entry entry is a message entry structure.
func (*Entry) WithContract ¶ added in v0.1.1
WithContract sets contract on entry.
func (*Entry) WithEncryption ¶ added in v0.1.1
WithEncryption sets encryption on entry.
func (*Entry) WithPayload ¶ added in v0.1.1
WithPayload sets payload to put entry into DB.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter filter is bloom filter generator.
type Meter ¶
type Meter struct { Metrics metrics.Metrics TimeSeries metrics.TimeSeries Gets metrics.Counter Puts metrics.Counter Leases metrics.Counter Syncs metrics.Counter Recovers metrics.Counter Aborts metrics.Counter Dels metrics.Counter InMsgs metrics.Counter OutMsgs metrics.Counter InBytes metrics.Counter OutBytes metrics.Counter }
Meter meter provides various db statistics.
func (*Meter) UnregisterAll ¶
func (m *Meter) UnregisterAll()
UnregisterAll unregister all metrics from meter.
type Options ¶
type Options interface {
// contains filtered or unexported methods
}
Options it contains configurable options and flags for DB.
func WithBackgroundKeyExpiry ¶ added in v0.1.1
func WithBackgroundKeyExpiry() Options
WithBackgroundKeyExpiry sets background key expiry for DB.
func WithBatchContract ¶ added in v0.1.1
WithBatchContract sets contract for batch operation.
func WithBatchEncryption ¶ added in v0.1.1
func WithBatchEncryption() Options
WithBatchEncryption sets encryption on batch operation.
func WithBatchWriteInterval ¶ added in v0.1.1
WithBatchWriteInterval sets batch write interval to partial write large batch.
func WithBufferSize ¶ added in v0.1.1
WithBufferSize sets Size of buffer to use for pooling.
func WithDefaultBatchOptions ¶ added in v0.1.1
func WithDefaultBatchOptions() Options
WithDefaultBatchOptions will set some default values for Batch operation.
contract: MasterContract encryption: False
func WithDefaultFlags ¶ added in v0.1.1
func WithDefaultFlags() Options
WithDefaultFlags will open DB with some default values.
immutable: True encryption: False backgroundKeyExpiry: False
func WithDefaultOptions ¶ added in v0.1.1
func WithDefaultOptions() Options
WithDefaultOptions will open DB with some default values.
func WithDefaultQueryLimit ¶ added in v0.1.1
WithDefaultQueryLimit limits maximum number of records to fetch if the DB Get or DB Iterator method does not specify a limit.
func WithDefaultQueryOptions ¶ added in v0.1.1
func WithDefaultQueryOptions() Options
WithDefaultQueryOptions will set some default values for Query operation.
defaultQueryLimit: 1000 maxQueryLimit: 100000
func WithEncryption ¶ added in v0.1.1
func WithEncryption() Options
WithEncryption sets encryption on DB.
func WithEncryptionKey ¶ added in v0.1.1
WithEncryptionKey sets encryption key to use for data encryption.
func WithFreeBlockSize ¶ added in v0.1.1
WithFreeBlockSize sets minimum freeblocks size before free blocks are allocated and reused.
func WithMaxQueryLimit ¶ added in v0.1.1
WithMaxQueryLimit limits maximum number of records to fetch if the DB Get or DB Iterator method does not specify a limit or specify a limit larger than MaxQueryResults.
func WithMaxSyncDuration ¶ added in v0.1.1
WithMaxSyncDuration sets the amount of time between background fsync() calls.
func WithMemdbSize ¶ added in v0.1.1
WithMemdbSize sets Size of blockcache.
func WithMutable ¶ added in v0.1.1
func WithMutable() Options
WithMutable sets Immutable flag to false.
type Query ¶
type Query struct { Topic []byte // The topic of the message. Contract uint32 // The contract is used as prefix in the message ID. Limit int // The maximum number of elements to return. // contains filtered or unexported fields }
Query represents a topic to query and optional contract information.
func (*Query) WithContract ¶ added in v0.1.1
WithContract sets contract on query.
type Varz ¶
type Varz struct { Start time.Time `json:"start"` Now time.Time `json:"now"` Uptime string `json:"uptime"` Seq int64 `json:"seq"` Count int64 `json:"count"` Gets int64 `json:"gets"` Puts int64 `json:"puts"` Leases int64 `json:"leases"` Syncs int64 `json:"syncs"` Recovers int64 `json:"recovers"` Aborts int64 `json:"aborts"` Dels int64 `json:"Dels"` InMsgs int64 `json:"in_msgs"` OutMsgs int64 `json:"out_msgs"` InBytes int64 `json:"in_bytes"` OutBytes int64 `json:"out_bytes"` HMean float64 `json:"hmean"` // Event duration harmonic mean. P50 float64 `json:"p50"` // Event duration nth percentiles. P75 float64 `json:"p75"` P95 float64 `json:"p95"` P99 float64 `json:"p99"` P999 float64 `json:"p999"` Long5p float64 `json:"long_5p"` // Average of the longest 5% event durations. Short5p float64 `json:"short_5p"` // Average of the shortest 5% event durations. Max float64 `json:"max"` // Highest event duration. Min float64 `json:"min"` // Lowest event duration. StdDev float64 `json:"stddev"` // Standard deviation. }
Varz outputs unitdb stats on the monitoring port at /varz.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package hash provides a minimal-memory AnchorHash consistent-hash implementation for Go.
|
Package hash provides a minimal-memory AnchorHash consistent-hash implementation for Go. |
internal/pkg/hash
Package ringhash implementats a consistent ring hash: https://en.wikipedia.org/wiki/Consistent_hashing
|
Package ringhash implementats a consistent ring hash: https://en.wikipedia.org/wiki/Consistent_hashing |
internal/pkg/stats
Package Meter yields summarized data describing a series of timed events.
|
Package Meter yields summarized data describing a series of timed events. |
proto
Package __schema is a generated protocol buffer package.
|
Package __schema is a generated protocol buffer package. |