Documentation ¶
Index ¶
- Constants
- func GetCounterKey(ev *eventid.T, ser []byte) (key []byte)
- func GetIndexKeysForEvent(ev *event.T, evtSerial []byte) (keyz [][]byte)
- func GetTagKeyElements(tagValue string) (prf index.P, elems []keys.Element)
- func GetTagKeyPrefix(tagValue string) (key []byte, err error)
- type AccessEvent
- type Backend
- func (b *Backend) Close()
- func (b *Backend) CountEvents(c context.T, f *filter.T) (count int, err error)
- func (b *Backend) DeleteEvent(c context.T, ev *event.T) error
- func (b *Backend) GCRun() (err error)
- func (b *Backend) GarbageCollector()
- func (b *Backend) IncrementAccesses(txMx *sync.Mutex, acc []AccessEvent) (err error)
- func (b *Backend) Init() error
- func (b *Backend) QueryEvents(c context.T, f *filter.T) (ch event.C, err error)
- func (b *Backend) SaveEvent(c context.T, ev *event.T) (err error)
- func (b *Backend) Serial() (ser uint64, err error)
- func (b *Backend) SerialBytes() (ser []byte, err error)
- func (b *Backend) SerialKey() (idx []byte, ser []byte)
- func (b *Backend) Wipe() (err error)
- type CountItem
- type CountItems
- type Results
Constants ¶
const ( // Megabyte is the standard 1 million byte units. Megabyte = 1000 * 1000 // SerialLen is the length of serial values used for conflict resistant // keys. SerialLen = 8 // TimestampLen is the standard 64 bit, 8 byte unix timestamp TimestampLen = 8 // IDPrefixLen is the length of the prefix trimmed out of a 256 bit SHA256 // hash that is the "id" field of an event. IDPrefixLen = 8 // PubkeyPrefixLen is the length of the prefix trimmed out of a public key // field of an event used in index keys. PubkeyPrefixLen = 8 // KindLen is the length of bytes to store a kind.T - 2 bytes/16 bits KindLen = 2 // PrefixLen is the length of the database key prefixes for each type of // record. It is 1, but this makes it unambiguous what it means. PrefixLen = 1 )
Variables ¶
This section is empty.
Functions ¶
func GetCounterKey ¶ added in v1.1.11
GetCounterKey returns the proper counter key for a given event ID.
func GetIndexKeysForEvent ¶ added in v1.1.21
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 ¶ added in v1.1.21
func GetTagKeyPrefix ¶ added in v1.1.21
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 AccessEvent ¶ added in v1.1.21
func (AccessEvent) String ¶ added in v1.1.21
func (a AccessEvent) String() (s string)
type Backend ¶
type Backend struct { Path string // MaxLimit is the largest a single event JSON can be, in bytes. MaxLimit int // DBSizeLimit is the number of Mb 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 *badger.DB Ctx context.T WG *sync.WaitGroup // contains filtered or unexported fields }
func (*Backend) CountEvents ¶
func (*Backend) GarbageCollector ¶ added in v1.1.13
func (b *Backend) GarbageCollector()
func (*Backend) IncrementAccesses ¶ added in v1.1.12
func (b *Backend) IncrementAccesses(txMx *sync.Mutex, acc []AccessEvent) (err error)
IncrementAccesses takes a list of event IDs of events that were accessed in a query and updates their access counter records.
func (*Backend) QueryEvents ¶
func (*Backend) SerialBytes ¶ added in v1.1.21
type CountItems ¶ added in v1.1.13
type CountItems []CountItem
func (CountItems) Len ¶ added in v1.1.13
func (c CountItems) Len() int
func (CountItems) Less ¶ added in v1.1.13
func (c CountItems) Less(i, j int) bool
func (CountItems) Swap ¶ added in v1.1.13
func (c CountItems) Swap(i, j int)
func (CountItems) Total ¶ added in v1.1.13
func (c CountItems) Total() (total int)