Early functionality modules
0. tests for event replay Tests are now included for the event replay features. This includes many fixes on top of the last commit as well as some tweaks to config module values. 1. activity module An activity module is created to track the useractive events and provide a counter for them. It also encapsulates logic to discard old useractive events. 2. web module A web module is created. This module serves a static webpage showing runtime information. Currently it only shows a snapshot of the user activity data. It is my intention that it eventually also shows an audit log, known users and channels, uptime, and more. Future work will also be needed in order to use HTML templating so that it doesn't look so... basic. Live updates to the information may also be desired. Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
parent
2515d396a0
commit
e7d229c217
8 changed files with 353 additions and 45 deletions
|
|
@ -263,6 +263,11 @@ func NewDocumentBuffer(
|
|||
* If cache is full oldest document is written to backing writer.
|
||||
*/
|
||||
func (b *DocBuf) Push(doc string) error {
|
||||
if b.cacheSize == 0 {
|
||||
b.writeToBackingStore(doc)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(b.cache) >= b.cacheSize {
|
||||
if err := b.demote(); err != nil {
|
||||
return err
|
||||
|
|
@ -280,6 +285,14 @@ func (b *DocBuf) Push(doc string) error {
|
|||
* out of the backing ReaderWriter.
|
||||
*/
|
||||
func (b *DocBuf) Pop() (string, error) {
|
||||
if b.cacheSize == 0 {
|
||||
d, e := b.readDocumentsFromDisk(1, true, false)
|
||||
if len(d) > 0 {
|
||||
return d[0], e
|
||||
}
|
||||
return "", e
|
||||
}
|
||||
|
||||
if len(b.cache) < 1 {
|
||||
if err := b.promote(true); err != nil {
|
||||
return "", err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue