2021-11-02 21:08:21 +03:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2021-12-07 19:45:15 +03:00
|
|
|
"errors"
|
2021-11-02 21:08:21 +03:00
|
|
|
_ "github.com/mattn/go-sqlite3" // SQLite driver
|
2021-11-03 04:09:49 +03:00
|
|
|
"time"
|
2021-11-02 21:08:21 +03:00
|
|
|
)
|
|
|
|
|
2021-12-07 19:45:15 +03:00
|
|
|
var (
|
|
|
|
errUnexpectedMessageType = errors.New("unexpected message type")
|
|
|
|
)
|
|
|
|
|
|
|
|
// cache implements a cache for messages of type "message" events,
|
|
|
|
// i.e. message structs with the Event messageEvent.
|
2021-11-03 04:09:49 +03:00
|
|
|
type cache interface {
|
|
|
|
AddMessage(m *message) error
|
2022-02-26 23:57:10 +03:00
|
|
|
Messages(topic string, since sinceMarker, scheduled bool) ([]*message, error)
|
2021-12-10 19:31:42 +03:00
|
|
|
MessagesDue() ([]*message, error)
|
2021-11-03 04:09:49 +03:00
|
|
|
MessageCount(topic string) (int, error)
|
|
|
|
Topics() (map[string]*topic, error)
|
2021-12-09 06:57:31 +03:00
|
|
|
Prune(olderThan time.Time) error
|
2021-12-10 19:31:42 +03:00
|
|
|
MarkPublished(m *message) error
|
2022-01-07 16:49:28 +03:00
|
|
|
AttachmentsSize(owner string) (int64, error)
|
2022-01-07 17:15:33 +03:00
|
|
|
AttachmentsExpired() ([]string, error)
|
2021-11-02 21:08:21 +03:00
|
|
|
}
|