# README
codex-db
Codex-db provides the database packages needed for the codex project.
Summary
Codex-db provides the database packages needed for the codex project.
Table of Contents
Code of Conduct
This project and everyone participating in it are governed by the XMiDT Code Of Conduct. By participating, you agree to this Code.
Install
This repo is a library of packages. There is no installation.
Cassandra DB Setup
CREATE KEYSPACE IF NOT EXISTS devices;
CREATE TABLE devices.events (device_id varchar,
record_type INT,
birthdate BIGINT,
deathdate BIGINT,
data BLOB,
nonce BLOB,
alg VARCHAR,
kid VARCHAR,
row_id TIMEUUID,
PRIMARY KEY (device_id, birthdate, record_type))
WITH CLUSTERING ORDER BY (birthdate DESC, record_type ASC)
AND default_time_to_live = 2768400
AND transactions = {'enabled': 'false'};
CREATE INDEX search_by_record_type ON devices.events
(device_id, record_type, birthdate)
WITH CLUSTERING ORDER BY (record_type ASC, birthdate DESC)
AND default_time_to_live = 2768400
AND transactions = {'enabled': 'false', 'consistency_level':'user_enforced'};
CREATE INDEX search_by_row_id ON devices.events
(device_id, row_id)
WITH CLUSTERING ORDER BY (row_id DESC)
AND default_time_to_live = 2768400
AND transactions = {'enabled': 'false', 'consistency_level':'user_enforced'};
CREATE TABLE devices.blacklist (device_id varchar PRIMARY KEY, reason varchar);
Contributing
Refer to CONTRIBUTING.md.
# Packages
package batchDeleter provides a wrapper around the db.Pruner to provide a way to get expired records at a given interval and delete them at a separate given interval.
package batchInserter provides a wrapper around the db.Inserter to provide a way to group records together before inserting, in order to decrease database requests needed for inserting.
No description provided by the author
package cassandra provides a way to connect to a cassandra database to keep track of device events.
No description provided by the author
package postgresql provides a way to connect to a postgresql database to keep track of device events.
Package dbretry contains structs that implement various db interfaces as well as consume them.
# Functions
ParseEventType returns the enum when given a string.
# Constants
No description provided by the author
default event type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
event type for online and offline events.
TypeLabel is for labeling metrics; if there is a single metric for successful queries, the typeLabel and corresponding type can be used when incrementing the metric.
# Structs
Record is the struct used to insert an event into the database.
RecordToDelete is the information needed to get out of the database in order to call the DeleteRecord function.
# Interfaces
Inserter is something that can insert records into the database.
Pruner is something that can get a list of expired records and delete them.
RecordGetter is something that can get records, including only getting records of a certain type.
# Type aliases
EventType is an enum for specifying the type of event being stored.