Documentation
¶
Overview ¶
Package storage provides database persistence for pulse data.
Index ¶
- func DB(ctx context.Context) (*sqlx.DB, error)
- func Migrate(ctx context.Context, db *sqlx.DB, schema fs.FS) error
- type DailyHostCount
- type HourlyCount
- type Storage
- func (s *Storage) GetUserDaily(ctx context.Context, userID string) ([]DailyHostCount, error)
- func (s *Storage) GetUserHosts(ctx context.Context, userID string) ([]string, error)
- func (s *Storage) GetUserHourly(ctx context.Context, userID string) ([]HourlyCount, error)
- func (s *Storage) GetUserHourlyAll(ctx context.Context, userID string) ([]DailyHostCount, error)
- func (s *Storage) GetUserHourlyByHost(ctx context.Context, userID string, hostname string) ([]DailyHostCount, error)
- func (s *Storage) ListUserCounts(ctx context.Context) ([]UserCount, error)
- func (s *Storage) Pulse(ctx context.Context, count int64, hostname string) error
- type UserCount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DailyHostCount ¶
type DailyHostCount struct {
Hostname string `db:"hostname" json:"hostname"`
Stamp string `db:"stamp" json:"stamp"`
Count int64 `db:"count" json:"count"`
}
DailyHostCount holds daily keystroke data per host.
type HourlyCount ¶
HourlyCount holds hourly keystroke data.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage provides pulse data persistence.
func NewStorage ¶
NewStorage creates a new storage backed by the given database.
func (*Storage) GetUserDaily ¶
GetUserDaily returns daily keystroke counts per host for a user over the last 30 days.
func (*Storage) GetUserHosts ¶
GetUserHosts returns all hostnames for a user.
func (*Storage) GetUserHourly ¶
GetUserHourly returns hourly keystroke distribution for a user (aggregated across all days).
func (*Storage) GetUserHourlyAll ¶
GetUserHourlyAll returns hourly keystroke counts per host for a user over the last 30 days.
func (*Storage) GetUserHourlyByHost ¶
func (s *Storage) GetUserHourlyByHost(ctx context.Context, userID string, hostname string) ([]DailyHostCount, error)
GetUserHourlyByHost returns hourly keystroke counts per host for a user over the last 48 hours.
func (*Storage) ListUserCounts ¶
ListUserCounts returns the total keystroke count per user for the last 30 days.