Documentation
¶
Index ¶
- Variables
- type Engine
- func NewEngine(tableBuilder func() hashTable, partitionsNumber int, logger *zerolog.Logger, ...) (*Engine, error)
- func NewEngineWithKeyIndex(tableBuilder func() hashTable, partitionsNumber int, logger *zerolog.Logger, ...) (*Engine, error)
- func NewEngineWithWALApplyWorkers(tableBuilder func() hashTable, partitionsNumber int, logger *zerolog.Logger, ...) (*Engine, error)
- func NewEngineWithWALApplyWorkersAndKeyIndex(tableBuilder func() hashTable, partitionsNumber int, logger *zerolog.Logger, ...) (*Engine, error)
- func (e *Engine) Clean(ctx context.Context)
- func (e *Engine) Del(txCtx database.TxContext, key database.BatchKey) bool
- func (e *Engine) FlushDB()
- func (e *Engine) Get(key database.BatchKey) (database.ValueType, bool)
- func (e *Engine) Incr(txCtx database.TxContext, key database.BatchKey, beforeApply func() error) (database.ValueType, error)
- func (e *Engine) IncrBy(txCtx database.TxContext, key database.BatchKey, delta database.ValueType, ...) (database.ValueType, error)
- func (e *Engine) MDel(txCtx database.TxContext, keys []database.BatchKey) []bool
- func (e *Engine) QuotaAcquire(txCtx database.TxContext, request database.QuotaAcquireRequest, ...) (database.QuotaAcquireResult, error)
- func (e *Engine) QuotaDelete(txCtx database.TxContext, name string, beforeApply func() error) (bool, error)
- func (e *Engine) QuotaInfo(now database.TxTime, name string) database.QuotaInfo
- func (e *Engine) QuotaRelease(txCtx database.TxContext, name, clientID string, beforeApply func() error) (database.QuotaReleaseResult, error)
- func (e *Engine) QuotaSet(txCtx database.TxContext, request database.QuotaSetRequest, ...) (bool, error)
- func (e *Engine) RLimitFixedWindow(txCtx database.TxContext, key database.BatchKey, limit database.ValueType, ...) (database.RateLimitResult, error)
- func (e *Engine) RLimitSlidingWindow(txCtx database.TxContext, key database.BatchKey, limit database.ValueType, ...) (database.RateLimitResult, error)
- func (e *Engine) RLimitTokenBucket(txCtx database.TxContext, key database.BatchKey, capacity database.ValueType, ...) (database.RateLimitResult, error)
- func (e *Engine) RestoreDumpElem(_ context.Context, elem database.DumpElem) error
- func (e *Engine) Scan(prefix, cursor string, count uint32) (database.ScanResult, error)
- func (e *Engine) SetAppliedTx(tx database.Tx)
- func (e *Engine) SetLimitEventPublisher(publisher func(database.LimitEvent))
- func (e *Engine) SetQuotaEventPublisher(publisher func(database.QuotaEvent))
- func (e *Engine) Snapshot(ctx context.Context, dumpTx database.Tx) (database.DumpSnapshot, error)
- func (e *Engine) SnapshotApplied(ctx context.Context) (database.DumpSnapshot, database.Tx, error)
- func (e *Engine) Stats() database.EngineStats
- type FqElem
- func (e *FqElem) DumpValue(dumpTx database.Tx) (database.ValueType, database.TxTime, database.Tx)
- func (e *FqElem) ExpiredWithDelta(now database.TxTime) bool
- func (e *FqElem) Incr(txCtx database.TxContext, beforeApply func() error) (database.ValueType, error)
- func (e *FqElem) IncrBy(txCtx database.TxContext, delta database.ValueType, beforeApply func() error) (database.ValueType, error)
- func (e *FqElem) RLimitFixedWindow(txCtx database.TxContext, limit database.ValueType, beforeApply func() error) (database.RateLimitResult, error)
- func (e *FqElem) Value() database.ValueType
- type HashTable
- func (s *HashTable) AddSlidingWindowEvent(txCtx database.TxContext, key database.BatchKey)
- func (s *HashTable) AddTokenBucketEvent(txCtx database.TxContext, key database.BatchKey, capacity database.ValueType, ...)
- func (s *HashTable) Clean(ctx context.Context)
- func (s *HashTable) CompactIndex(ctx context.Context, maxDeletes int, budget time.Duration) bool
- func (s *HashTable) Del(key database.BatchKey) bool
- func (s *HashTable) FlushDB()
- func (s *HashTable) Get(key database.BatchKey) (database.ValueType, bool)
- func (s *HashTable) Incr(txCtx database.TxContext, key database.BatchKey, beforeApply func() error) (database.ValueType, error)
- func (s *HashTable) IncrBy(txCtx database.TxContext, key database.BatchKey, delta database.ValueType, ...) (database.ValueType, error)
- func (s *HashTable) QuotaAcquire(txCtx database.TxContext, request database.QuotaAcquireRequest, ...) (database.QuotaAcquireResult, error)
- func (s *HashTable) QuotaDelete(txCtx database.TxContext, name string, beforeApply func() error) (bool, error)
- func (s *HashTable) QuotaInfo(now database.TxTime, name string) database.QuotaInfo
- func (s *HashTable) QuotaRelease(txCtx database.TxContext, name, clientID string, beforeApply func() error) (database.QuotaReleaseResult, error)
- func (s *HashTable) QuotaSet(txCtx database.TxContext, request database.QuotaSetRequest, ...) (bool, error)
- func (s *HashTable) RLimitFixedWindow(txCtx database.TxContext, key database.BatchKey, limit database.ValueType, ...) (database.RateLimitResult, error)
- func (s *HashTable) RLimitSlidingWindow(txCtx database.TxContext, key database.BatchKey, limit database.ValueType, ...) (database.RateLimitResult, error)
- func (s *HashTable) RLimitTokenBucket(txCtx database.TxContext, key database.BatchKey, capacity database.ValueType, ...) (database.RateLimitResult, error)
- func (s *HashTable) RestoreDumpElem(elem database.DumpElem)
- func (s *HashTable) Scan(prefix string, after hashTableKey, count uint32) []database.BatchKey
- func (s *HashTable) Snapshot(ctx context.Context, dumpTx database.Tx) []database.DumpElem
- func (s *HashTable) Stats() database.PartitionStats
- type QuotaElem
- func (e *QuotaElem) Acquire(txCtx database.TxContext, request database.QuotaAcquireRequest, ...) (database.QuotaAcquireResult, error)
- func (e *QuotaElem) AllocationCount() int
- func (e *QuotaElem) CanDelete(now database.TxTime) bool
- func (e *QuotaElem) Clean(now database.TxTime) bool
- func (e *QuotaElem) Clients() uint32
- func (e *QuotaElem) Info(now database.TxTime) database.QuotaInfo
- func (e *QuotaElem) Limit() database.ValueType
- func (e *QuotaElem) Ownership() database.QuotaOwnership
- func (e *QuotaElem) Policy() database.QuotaPolicy
- func (e *QuotaElem) Release(txCtx database.TxContext, clientID string, beforeApply func() error) (database.QuotaReleaseResult, error)
- func (e *QuotaElem) RestoreAllocation(elem database.DumpElem)
- func (e *QuotaElem) RestoreConfig(elem database.DumpElem)
- func (e *QuotaElem) SetConfig(txCtx database.TxContext, request database.QuotaSetRequest, ...) (bool, error)
- type SlidingWindowElem
- func (e *SlidingWindowElem) AddEvent(txCtx database.TxContext)
- func (e *SlidingWindowElem) AppendDump(dst []database.DumpElem, key hashTableKey, dumpTx database.Tx) []database.DumpElem
- func (e *SlidingWindowElem) Clean(now database.TxTime) bool
- func (e *SlidingWindowElem) RLimit(txCtx database.TxContext, limit database.ValueType, beforeApply func() error) (database.RateLimitResult, error)
- func (e *SlidingWindowElem) RestoreBucket(elem database.DumpElem)
- type TokenBucketElem
- func (e *TokenBucketElem) AddEvent(txCtx database.TxContext, capacity database.ValueType, ...)
- func (e *TokenBucketElem) DumpValue(dumpTx database.Tx) (database.ValueType, database.TxTime, database.Tx)
- func (e *TokenBucketElem) RLimit(txCtx database.TxContext, capacity database.ValueType, ...) (database.RateLimitResult, error)
- func (e *TokenBucketElem) Restore(elem database.DumpElem)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidArgument = errors.New("invalid argument") ErrInvalidHashTablePartition = errors.New("hash table partition is invalid") ErrInvalidWALData = errors.New("invalid WAL log data") )
View Source
var HashTableBuilder = func() hashTable { return NewHashTable() }
View Source
var IndexedHashTableBuilder = func() hashTable { return NewIndexedHashTable() }
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func NewEngineWithKeyIndex ¶ added in v0.6.0
func NewEngineWithWALApplyWorkers ¶ added in v0.3.8
func NewEngineWithWALApplyWorkersAndKeyIndex ¶ added in v0.6.0
func (*Engine) QuotaAcquire ¶ added in v0.3.9
func (e *Engine) QuotaAcquire( txCtx database.TxContext, request database.QuotaAcquireRequest, beforeApply func() error, ) (database.QuotaAcquireResult, error)
func (*Engine) QuotaDelete ¶ added in v0.3.9
func (*Engine) QuotaRelease ¶ added in v0.3.9
func (*Engine) RLimitFixedWindow ¶
func (e *Engine) RLimitFixedWindow( txCtx database.TxContext, key database.BatchKey, limit database.ValueType, beforeApply func() error, ) (database.RateLimitResult, error)
RLimitFixedWindow ...
func (*Engine) RLimitSlidingWindow ¶
func (e *Engine) RLimitSlidingWindow( txCtx database.TxContext, key database.BatchKey, limit database.ValueType, beforeApply func() error, ) (database.RateLimitResult, error)
RLimitSlidingWindow ...
func (*Engine) RLimitTokenBucket ¶
func (e *Engine) RLimitTokenBucket( txCtx database.TxContext, key database.BatchKey, capacity database.ValueType, refillAmount database.ValueType, beforeApply func() error, ) (database.RateLimitResult, error)
RLimitTokenBucket ...
func (*Engine) RestoreDumpElem ¶
func (*Engine) SetAppliedTx ¶ added in v0.10.1
func (*Engine) SetLimitEventPublisher ¶ added in v0.3.10
func (e *Engine) SetLimitEventPublisher(publisher func(database.LimitEvent))
func (*Engine) SetQuotaEventPublisher ¶ added in v0.3.10
func (e *Engine) SetQuotaEventPublisher(publisher func(database.QuotaEvent))
func (*Engine) SnapshotApplied ¶ added in v0.10.1
func (*Engine) Stats ¶ added in v0.7.0
func (e *Engine) Stats() database.EngineStats
type FqElem ¶
type FqElem struct {
// contains filtered or unexported fields
}
func (*FqElem) ExpiredWithDelta ¶ added in v0.3.7
func (*FqElem) RLimitFixedWindow ¶
type HashTable ¶
type HashTable struct {
// contains filtered or unexported fields
}
func NewHashTable ¶
func NewHashTable() *HashTable
func NewIndexedHashTable ¶ added in v0.6.0
func NewIndexedHashTable() *HashTable
func (*HashTable) AddSlidingWindowEvent ¶
func (*HashTable) AddTokenBucketEvent ¶
func (*HashTable) CompactIndex ¶ added in v0.6.0
func (*HashTable) QuotaAcquire ¶ added in v0.3.9
func (s *HashTable) QuotaAcquire( txCtx database.TxContext, request database.QuotaAcquireRequest, beforeApply func() error, ) (database.QuotaAcquireResult, error)
func (*HashTable) QuotaDelete ¶ added in v0.3.9
func (*HashTable) QuotaRelease ¶ added in v0.3.9
func (*HashTable) RLimitFixedWindow ¶
func (*HashTable) RLimitSlidingWindow ¶
func (*HashTable) RLimitTokenBucket ¶
func (*HashTable) RestoreDumpElem ¶
func (*HashTable) Stats ¶ added in v0.7.0
func (s *HashTable) Stats() database.PartitionStats
type QuotaElem ¶ added in v0.3.9
type QuotaElem struct {
// contains filtered or unexported fields
}
func NewQuotaElem ¶ added in v0.3.9
func NewQuotaElem(limit database.ValueType, ownership database.QuotaOwnership) *QuotaElem
func (*QuotaElem) Acquire ¶ added in v0.3.9
func (e *QuotaElem) Acquire( txCtx database.TxContext, request database.QuotaAcquireRequest, beforeApply func() error, ) (database.QuotaAcquireResult, error)
func (*QuotaElem) AllocationCount ¶ added in v0.7.0
func (*QuotaElem) Ownership ¶ added in v0.3.11
func (e *QuotaElem) Ownership() database.QuotaOwnership
func (*QuotaElem) Policy ¶ added in v0.4.0
func (e *QuotaElem) Policy() database.QuotaPolicy
func (*QuotaElem) RestoreAllocation ¶ added in v0.3.9
func (*QuotaElem) RestoreConfig ¶ added in v0.3.11
type SlidingWindowElem ¶
type SlidingWindowElem struct {
// contains filtered or unexported fields
}
func NewSlidingWindowElem ¶
func NewSlidingWindowElem(window uint32) *SlidingWindowElem
func (*SlidingWindowElem) AddEvent ¶
func (e *SlidingWindowElem) AddEvent(txCtx database.TxContext)
func (*SlidingWindowElem) AppendDump ¶ added in v0.10.1
func (*SlidingWindowElem) RLimit ¶
func (e *SlidingWindowElem) RLimit( txCtx database.TxContext, limit database.ValueType, beforeApply func() error, ) (database.RateLimitResult, error)
func (*SlidingWindowElem) RestoreBucket ¶
func (e *SlidingWindowElem) RestoreBucket(elem database.DumpElem)
type TokenBucketElem ¶
type TokenBucketElem struct {
// contains filtered or unexported fields
}
func NewTokenBucketElem ¶
func NewTokenBucketElem(refillWindow uint32) *TokenBucketElem
func (*TokenBucketElem) Restore ¶
func (e *TokenBucketElem) Restore(elem database.DumpElem)
Click to show internal directories.
Click to hide internal directories.