Documentation ¶
Index ¶
- Constants
- Variables
- func Register(name string, factory DataStoreFactory)
- func Tomorrow(t time.Time) time.Time
- func Ulogme7amTime(t time.Time) int64
- func Yesterday(t time.Time) time.Time
- type DataStore
- type DataStoreFactory
- type FileDataStore
- func (ds *FileDataStore) CheckAuth(key string) (int, error)
- func (ds *FileDataStore) CreateBlog(uid int, date time.Time, message string)
- func (ds *FileDataStore) CreateNote(uid int, date time.Time, message string)
- func (ds *FileDataStore) ExportEventsByDate(tm time.Time) *gologme.EventLog
- func (ds *FileDataStore) ExportWindowLogsByRange(t0 int64, t1 int64) []*gologme.SEvent
- func (ds *FileDataStore) FindUserNameByID(id int) (string, error)
- func (ds *FileDataStore) LogToDb(uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs)
- func (ds *FileDataStore) MaxDate() int
- func (ds *FileDataStore) MinDate() int
- func (ds *FileDataStore) Name() string
- func (ds *FileDataStore) SetupDb()
- type PostgreSQLDataStore
- func (ds *PostgreSQLDataStore) CheckAuth(key string) (int, error)
- func (ds *PostgreSQLDataStore) CreateBlog(uid int, date time.Time, message string)
- func (ds *PostgreSQLDataStore) CreateBlogNote(uid int, date time.Time, message string, noteType int)
- func (ds *PostgreSQLDataStore) CreateNote(uid int, date time.Time, message string)
- func (ds *PostgreSQLDataStore) ExportEventsByDate(tm time.Time) *gologme.EventLog
- func (ds *PostgreSQLDataStore) ExportWindowLogsByRange(t0 int64, t1 int64) []*gologme.SEvent
- func (ds *PostgreSQLDataStore) FindUserNameByID(id int) (string, error)
- func (ds *PostgreSQLDataStore) LogToDb(uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs)
- func (ds *PostgreSQLDataStore) MaxDate() int
- func (ds *PostgreSQLDataStore) MinDate() int
- func (ds *PostgreSQLDataStore) Name() string
- func (ds *PostgreSQLDataStore) SetupDb()
- type SqliteSQLDataStore
- func (ds *SqliteSQLDataStore) CheckAuth(key string) (int, error)
- func (ds *SqliteSQLDataStore) CreateBlog(uid int, date time.Time, message string)
- func (ds *SqliteSQLDataStore) CreateBlogNote(uid int, date time.Time, message string, noteType int)
- func (ds *SqliteSQLDataStore) CreateNote(uid int, date time.Time, message string)
- func (ds *SqliteSQLDataStore) ExportEventsByDate(tm time.Time) *gologme.EventLog
- func (ds *SqliteSQLDataStore) ExportWindowLogsByRange(t0 int64, t1 int64) []*gologme.SEvent
- func (ds *SqliteSQLDataStore) FindUserNameByID(id int) (string, error)
- func (ds *SqliteSQLDataStore) LogToDb(uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs)
- func (ds *SqliteSQLDataStore) MaxDate() int
- func (ds *SqliteSQLDataStore) MinDate() int
- func (ds *SqliteSQLDataStore) Name() string
- func (ds *SqliteSQLDataStore) SetupDb()
Constants ¶
const DB_SCHEMA string = `` /* 870-byte string literal not displayed */
Variables ¶
var ErrFailedToConnect = errors.New("Could not connect to database")
ErrFailedToConnect produced when cannot connect
var ErrUserNotFound = errors.New("User not found")
ErrUserNotFound produced when a user cannot be found
Functions ¶
func Ulogme7amTime ¶
Types ¶
type DataStore ¶
type DataStore interface { LogToDb( uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs, ) CreateNote( uid int, date time.Time, message string, ) CreateBlog( uid int, date time.Time, message string, ) CheckAuth( key string, ) (int, error) Name() string FindUserNameByID(id int) (string, error) SetupDb() ExportWindowLogsByRange(t0, t1 int64) []*gologme.SEvent ExportEventsByDate(tm time.Time) *gologme.EventLog MinDate() int MaxDate() int }
DataStore interface definition, all DBs must implement this
func CreateDataStore ¶
CreateDataStore creates a new database connection
func NewFileDataStore ¶
NewFileDataStore builds a new sqlite3 DS
func NewPostgreSQLDataStore ¶
NewPostgreSQLDataStore builds a new PG DS
type DataStoreFactory ¶
DataStoreFactory config
type FileDataStore ¶
type FileDataStore struct { DSN string KeyFreqs *os.File Windows *os.File Blog *os.File Notes *os.File }
FileDataStore struct
func (*FileDataStore) CheckAuth ¶
func (ds *FileDataStore) CheckAuth(key string) (int, error)
CheckAuth of the key, returning -1 or the user's ID
func (*FileDataStore) CreateBlog ¶
func (ds *FileDataStore) CreateBlog(uid int, date time.Time, message string)
func (*FileDataStore) CreateNote ¶
func (ds *FileDataStore) CreateNote(uid int, date time.Time, message string)
func (*FileDataStore) ExportEventsByDate ¶
func (ds *FileDataStore) ExportEventsByDate(tm time.Time) *gologme.EventLog
ExportEventsByDate extracts events for a given day
func (*FileDataStore) ExportWindowLogsByRange ¶
func (ds *FileDataStore) ExportWindowLogsByRange(t0 int64, t1 int64) []*gologme.SEvent
func (*FileDataStore) FindUserNameByID ¶
func (ds *FileDataStore) FindUserNameByID(id int) (string, error)
FindUserNameByID returns a username for a given ID
func (*FileDataStore) LogToDb ¶
func (ds *FileDataStore) LogToDb(uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs)
LogToDb logs a set of windowLogs and keyLogs to the DB
func (*FileDataStore) MaxDate ¶
func (ds *FileDataStore) MaxDate() int
MaxDate returns latest log entry
func (*FileDataStore) MinDate ¶
func (ds *FileDataStore) MinDate() int
MinDate returns first log entry
func (*FileDataStore) SetupDb ¶
func (ds *FileDataStore) SetupDb()
SetupDb runs any migrations needed
type PostgreSQLDataStore ¶
PostgreSQLDataStore struct
func (*PostgreSQLDataStore) CheckAuth ¶
func (ds *PostgreSQLDataStore) CheckAuth(key string) (int, error)
CheckAuth of the key, returning -1 or the user's ID
func (*PostgreSQLDataStore) CreateBlog ¶
func (ds *PostgreSQLDataStore) CreateBlog(uid int, date time.Time, message string)
func (*PostgreSQLDataStore) CreateBlogNote ¶
func (*PostgreSQLDataStore) CreateNote ¶
func (ds *PostgreSQLDataStore) CreateNote(uid int, date time.Time, message string)
func (*PostgreSQLDataStore) ExportEventsByDate ¶
func (ds *PostgreSQLDataStore) ExportEventsByDate(tm time.Time) *gologme.EventLog
ExportEventsByDate extracts events for a given day
func (*PostgreSQLDataStore) ExportWindowLogsByRange ¶
func (ds *PostgreSQLDataStore) ExportWindowLogsByRange(t0 int64, t1 int64) []*gologme.SEvent
func (*PostgreSQLDataStore) FindUserNameByID ¶
func (ds *PostgreSQLDataStore) FindUserNameByID(id int) (string, error)
FindUserNameByID returns a username for a given ID
func (*PostgreSQLDataStore) LogToDb ¶
func (ds *PostgreSQLDataStore) LogToDb(uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs)
LogToDb logs a set of windowLogs and keyLogs to the DB
func (*PostgreSQLDataStore) MaxDate ¶
func (ds *PostgreSQLDataStore) MaxDate() int
MaxDate returns latest log entry
func (*PostgreSQLDataStore) MinDate ¶
func (ds *PostgreSQLDataStore) MinDate() int
MinDate returns first log entry
func (*PostgreSQLDataStore) Name ¶
func (ds *PostgreSQLDataStore) Name() string
Name of the DS implementatino
func (*PostgreSQLDataStore) SetupDb ¶
func (ds *PostgreSQLDataStore) SetupDb()
SetupDb runs any migrations needed
type SqliteSQLDataStore ¶
SqliteSQLDataStore struct
func (*SqliteSQLDataStore) CheckAuth ¶
func (ds *SqliteSQLDataStore) CheckAuth(key string) (int, error)
CheckAuth of the key, returning -1 or the user's ID
func (*SqliteSQLDataStore) CreateBlog ¶
func (ds *SqliteSQLDataStore) CreateBlog(uid int, date time.Time, message string)
func (*SqliteSQLDataStore) CreateBlogNote ¶
func (*SqliteSQLDataStore) CreateNote ¶
func (ds *SqliteSQLDataStore) CreateNote(uid int, date time.Time, message string)
func (*SqliteSQLDataStore) ExportEventsByDate ¶
func (ds *SqliteSQLDataStore) ExportEventsByDate(tm time.Time) *gologme.EventLog
ExportEventsByDate extracts events for a given day
func (*SqliteSQLDataStore) ExportWindowLogsByRange ¶
func (ds *SqliteSQLDataStore) ExportWindowLogsByRange(t0 int64, t1 int64) []*gologme.SEvent
func (*SqliteSQLDataStore) FindUserNameByID ¶
func (ds *SqliteSQLDataStore) FindUserNameByID(id int) (string, error)
FindUserNameByID returns a username for a given ID
func (*SqliteSQLDataStore) LogToDb ¶
func (ds *SqliteSQLDataStore) LogToDb(uid int, windowlogs []*gologme.WindowLogs, keylogs []*gologme.KeyLogs)
LogToDb logs a set of windowLogs and keyLogs to the DB
func (*SqliteSQLDataStore) MaxDate ¶
func (ds *SqliteSQLDataStore) MaxDate() int
MaxDate returns latest log entry
func (*SqliteSQLDataStore) MinDate ¶
func (ds *SqliteSQLDataStore) MinDate() int
MinDate returns first log entry
func (*SqliteSQLDataStore) Name ¶
func (ds *SqliteSQLDataStore) Name() string
Name of the DS implementatino
func (*SqliteSQLDataStore) SetupDb ¶
func (ds *SqliteSQLDataStore) SetupDb()
SetupDb runs any migrations needed