Documentation ¶
Index ¶
- Constants
- Variables
- type ConnectionPoolOptions
- type DBKey
- type DBOption
- type DBStore
- func (d *DBStore) Count() (int, error)
- func (d *DBStore) GetAll() ([]StoredMessage, error)
- func (d *DBStore) GetStoredMessage(row *sql.Rows) (StoredMessage, error)
- func (d *DBStore) MostRecentTimestamp() (int64, error)
- func (d *DBStore) Put(env *protocol.Envelope) error
- func (d *DBStore) Query(query *pb.HistoryQuery) (*pb.Index, []StoredMessage, error)
- func (d *DBStore) Start(ctx context.Context, timesource timesource.Timesource) error
- func (d *DBStore) Stop()
- type Hash
- type MessageProvider
- type StoredMessage
Constants ¶
const ( TimestampLength = 8 HashLength = 32 DigestLength = HashLength PubsubTopicLength = HashLength DBKeyLength = TimestampLength + PubsubTopicLength + DigestLength )
const WALMode = "wal"
WALMode for sqlite.
Variables ¶
var ( // ErrInvalidByteSize is returned when DBKey can't be created // from a byte slice because it has invalid length. ErrInvalidByteSize = errors.New("byte slice has invalid length") )
var ErrInvalidCursor = errors.New("invalid cursor")
Functions ¶
This section is empty.
Types ¶
type ConnectionPoolOptions ¶
type DBKey ¶
type DBKey struct {
// contains filtered or unexported fields
}
DBKey key to be stored in a db.
type DBOption ¶
DBOption is an optional setting that can be used to configure the DBStore
func DefaultOptions ¶
func DefaultOptions() []DBOption
func WithDriver ¶
func WithDriver(driverName string, datasourceName string, connectionPoolOptions ...ConnectionPoolOptions) DBOption
WithDriver is a DBOption that will open a *sql.DB connection
func WithMigrations ¶ added in v0.4.0
WithMigrations is a DBOption used to determine if migrations should be executed, and what driver to use
type DBStore ¶
type DBStore struct { MessageProvider // contains filtered or unexported fields }
DBStore is a MessageProvider that has a *sql.DB connection
func NewDBStore ¶
Creates a new DB store using the db specified via options. It will create a messages table if it does not exist and clean up records according to the retention policy used
func (*DBStore) GetAll ¶
func (d *DBStore) GetAll() ([]StoredMessage, error)
GetAll returns all the stored WakuMessages
func (*DBStore) GetStoredMessage ¶
func (d *DBStore) GetStoredMessage(row *sql.Rows) (StoredMessage, error)
GetStoredMessage is a helper function used to convert a `*sql.Rows` into a `StoredMessage`
func (*DBStore) MostRecentTimestamp ¶
MostRecentTimestamp returns an unix timestamp with the most recent senderTimestamp in the message table
func (*DBStore) Query ¶
func (d *DBStore) Query(query *pb.HistoryQuery) (*pb.Index, []StoredMessage, error)
Query retrieves messages from the DB
func (*DBStore) Start ¶
func (d *DBStore) Start(ctx context.Context, timesource timesource.Timesource) error
type Hash ¶
type Hash [HashLength]byte
type MessageProvider ¶
type MessageProvider interface { GetAll() ([]StoredMessage, error) Put(env *protocol.Envelope) error Query(query *pb.HistoryQuery) ([]StoredMessage, error) MostRecentTimestamp() (int64, error) Start(ctx context.Context, timesource timesource.Timesource) error Stop() }
type StoredMessage ¶
type StoredMessage struct { ID []byte PubsubTopic string ReceiverTime int64 Message *wpb.WakuMessage }