Documentation ¶
Index ¶
- Constants
- func GetIndexKeysForEvent(ev *event.T, ser *serial.T) (keyz [][]byte)
- func GetTagKeyElements(tagValue string, CA *createdat.T, ser *serial.T) (prf index.P, elems []keys.Element, err error)
- func GetTagKeyPrefix(tagValue string) (key []byte, err error)
- func NewLogger(logLevel int, label string) (l *logger)
- func PrepareQueries(f *filter.T) (qs []query, ext *filter.T, since uint64, err error)
- type B
- type Ctx
- type E
- type N
- type Results
- type S
- type T
- func (r *T) Close() (err E)
- func (r *T) CountEvents(c Ctx, f *filter.T) (count N, err E)
- func (r *T) DeleteEvent(c Ctx, eid *eventid.T) (err E)
- func (r *T) Init(path S) (err E)
- func (r *T) Nuke() (err E)
- func (r *T) Path() S
- func (r *T) QueryEvents(c Ctx, f *filter.T) (evs []*event.T, err E)
- func (r *T) SaveEvent(c Ctx, ev *event.T) (err E)
- func (r *T) Serial() (ser uint64, err error)
- func (r *T) SerialBytes() (ser []byte, err error)
- func (r *T) SerialKey() (idx []byte, ser *serial.T)
Constants ¶
const Version = 1
Variables ¶
This section is empty.
Functions ¶
func GetIndexKeysForEvent ¶
GetIndexKeysForEvent generates all the index keys required to filter for events. evtSerial should be the output of Serial() which gets a unique, monotonic counter value for each new event.
func GetTagKeyElements ¶
func GetTagKeyPrefix ¶
GetTagKeyPrefix returns tag index prefixes based on the initial field of a tag.
There is 3 types of index tag keys:
- TagAddr: [ 8 ][ 2b Kind ][ 8b Pubkey ][ address/URL ][ 8b Serial ]
- Tag32: [ 7 ][ 8b Pubkey ][ 8b Serial ]
- Tag: [ 6 ][ address/URL ][ 8b Serial ]
This function produces the initial bytes without the index.
Types ¶
type B ¶
type B = []byte
func GetCounterKey ¶
GetCounterKey returns the proper counter key for a given event ID.
type T ¶
type T struct { Ctx context.T WG *sync.WaitGroup // DBSizeLimit is the number of bytes we want to keep the data store from exceeding. DBSizeLimit int // DBLowWater is the percentage of DBSizeLimit a GC run will reduce the used storage down // to. DBLowWater int // DBHighWater is the trigger point at which a GC run should start if exceeded. DBHighWater int // GCFrequency is the frequency of checks of the current utilisation. GCFrequency time.Duration HasL2 bool BlockCacheSize int InitLogLevel int Logger *logger // DB is the badger db enveloper *badger.DB // Threads is how many CPU threads we dedicate to concurrent actions, flatten and GC mark Threads int // MaxLimit is a default limit that applies to a query without a limit, to avoid sending out // too many events to a client from a malformed or excessively broad filter. MaxLimit int // ActuallyDelete sets whether we actually delete or rewrite deleted entries with a modified // deleted prefix value (8th bit set) ActuallyDelete bool // contains filtered or unexported fields }
func GetBackend ¶
func GetBackend(Ctx context.T, WG *sync.WaitGroup, hasL2 bool, blockCacheSize, logLevel, maxLimit int, params ...int) (b *T)
GetBackend returns a reasonably configured badger.Backend.
The variadic params correspond to DBSizeLimit, DBLowWater, DBHighWater and GCFrequency as an integer multiplier of number of seconds.
Note that the cancel function for the context needs to be managed by the caller.
func (*T) SerialBytes ¶
SerialBytes returns a new serial value, used to store an event record with a conflict-free unique code (it is a monotonic, atomic, ascending counter).