Documentation
¶
Index ¶
- func FormatBytes(b int64) string
- type AuditStore
- type Backup
- type BackupStore
- func (s *BackupStore) CleanOld(ctx context.Context, maxAge time.Duration) (int, error)
- func (s *BackupStore) Create(ctx context.Context) (Backup, error)
- func (s *BackupStore) Delete(ctx context.Context, filename string) error
- func (s *BackupStore) EncryptionEnabled() bool
- func (s *BackupStore) GetPath(filename string) string
- func (s *BackupStore) List(ctx context.Context) ([]Backup, error)
- func (s *BackupStore) Restore(ctx context.Context, filename string) error
- type GeoblockCacheStore
- type InstanceStore
- func (s *InstanceStore) Count(ctx context.Context) (int, error)
- func (s *InstanceStore) Create(ctx context.Context, inst *model.Instance) error
- func (s *InstanceStore) Delete(ctx context.Context, port int) error
- func (s *InstanceStore) EnsureDefaultInstance(ctx context.Context, proxyPort, metricsPort int) error
- func (s *InstanceStore) GetByPort(ctx context.Context, port int) (*model.Instance, error)
- func (s *InstanceStore) List(ctx context.Context) ([]model.Instance, error)
- type Manifest
- type QuotaAlertStore
- type SchedulerStore
- func (s *SchedulerStore) CleanOldHistory(ctx context.Context, maxAge time.Duration) error
- func (s *SchedulerStore) DeleteOverride(ctx context.Context, taskName string) error
- func (s *SchedulerStore) GetLatestHistory(ctx context.Context, taskName string) (*scheduler.ExecutionRecord, error)
- func (s *SchedulerStore) GetOverride(ctx context.Context, taskName string) (*scheduler.TaskOverride, error)
- func (s *SchedulerStore) GetOverrides(ctx context.Context) ([]scheduler.TaskOverride, error)
- func (s *SchedulerStore) InsertHistory(ctx context.Context, rec *scheduler.ExecutionRecord) error
- func (s *SchedulerStore) ListHistory(ctx context.Context, limit, offset int) ([]scheduler.ExecutionRecord, error)
- func (s *SchedulerStore) ListHistoryByTask(ctx context.Context, taskName string, limit, offset int) ([]scheduler.ExecutionRecord, error)
- func (s *SchedulerStore) UpsertOverride(ctx context.Context, o *scheduler.TaskOverride) error
- type SecretStore
- func (s *SecretStore) Archive(ctx context.Context, label string) error
- func (s *SecretStore) BulkExtendExpiry(ctx context.Context, labels []string, expiresAt string, reenable bool) (int, error)
- func (s *SecretStore) BulkRotateKeys(ctx context.Context, labels []string, keys map[string]string) (int, error)
- func (s *SecretStore) BulkSetLimits(ctx context.Context, labels []string, maxConns, maxIPs int, quotaBytes int64, ...) (int, error)
- func (s *SecretStore) BulkToggleEnabled(ctx context.Context, labels []string, enable bool) (int, error)
- func (s *SecretStore) CloneSecret(ctx context.Context, srcLabel, newLabel, newKey string) (*model.Secret, error)
- func (s *SecretStore) Count(ctx context.Context) (int, error)
- func (s *SecretStore) CountEnabled(ctx context.Context) (int, error)
- func (s *SecretStore) CountEnabledByLabels(ctx context.Context, labels []string) (int, error)
- func (s *SecretStore) Create(ctx context.Context, sec *model.Secret) error
- func (s *SecretStore) Delete(ctx context.Context, label string) error
- func (s *SecretStore) DisableExpired(ctx context.Context) (int, error)
- func (s *SecretStore) ExtendExpiry(ctx context.Context, label, expiresAt string, reenable bool) error
- func (s *SecretStore) GetByLabel(ctx context.Context, label string) (*model.Secret, error)
- func (s *SecretStore) LabelsByTag(ctx context.Context, tag string) ([]string, error)
- func (s *SecretStore) List(ctx context.Context) ([]model.Secret, error)
- func (s *SecretStore) ListAllTags(ctx context.Context) ([]string, error)
- func (s *SecretStore) ListByTag(ctx context.Context, tag string) ([]model.Secret, error)
- func (s *SecretStore) ListEnabledLabels(ctx context.Context) ([]string, error)
- func (s *SecretStore) RenameLabel(ctx context.Context, oldLabel, newLabel string) error
- func (s *SecretStore) ResetAllTraffic(ctx context.Context) error
- func (s *SecretStore) ResetTraffic(ctx context.Context, label string) error
- func (s *SecretStore) Search(ctx context.Context, query string) ([]model.Secret, error)
- func (s *SecretStore) Top(ctx context.Context, limit int) ([]model.Secret, error)
- func (s *SecretStore) Unarchive(ctx context.Context, label string) error
- func (s *SecretStore) Update(ctx context.Context, sec *model.Secret) error
- func (s *SecretStore) UpdateTags(ctx context.Context, label, tags string) error
- func (s *SecretStore) UpdateTraffic(ctx context.Context, label string, deltaIn, deltaOut int64) error
- type SettingsStore
- func (s *SettingsStore) Get(ctx context.Context, key string) (string, error)
- func (s *SettingsStore) GetAuthPasswordHash(ctx context.Context) (string, error)
- func (s *SettingsStore) GetJWTSecret(ctx context.Context) (string, error)
- func (s *SettingsStore) Load(ctx context.Context) (*model.Settings, error)
- func (s *SettingsStore) Save(ctx context.Context, updates map[string]string) error
- func (s *SettingsStore) SetAuthPasswordHash(ctx context.Context, hash string) error
- type SlaveStore
- func (s *SlaveStore) Create(ctx context.Context, sl *model.Slave) error
- func (s *SlaveStore) Delete(ctx context.Context, host string) error
- func (s *SlaveStore) GetByHost(ctx context.Context, host string) (*model.Slave, error)
- func (s *SlaveStore) List(ctx context.Context) ([]model.Slave, error)
- func (s *SlaveStore) UpdateStatus(ctx context.Context, host, status string, lastSync int64) error
- type TemplateStore
- func (s *TemplateStore) Create(ctx context.Context, t *model.SecretTemplate) error
- func (s *TemplateStore) Delete(ctx context.Context, name string) error
- func (s *TemplateStore) GetByName(ctx context.Context, name string) (*model.SecretTemplate, error)
- func (s *TemplateStore) List(ctx context.Context) ([]model.SecretTemplate, error)
- type TokenBlocklistStore
- type TrafficStore
- func (s *TrafficStore) CleanOldHistory(ctx context.Context, maxAge time.Duration) error
- func (s *TrafficStore) FlushTraffic(ctx context.Context, global model.TrafficSnapshot, ...) error
- func (s *TrafficStore) GetAggregatedHistory(ctx context.Context, start, end int64, label string, groupSeconds int64) ([]model.TrafficHistoryRecord, error)
- func (s *TrafficStore) GetAllUserSnapshots(ctx context.Context) (map[string][2]int64, error)
- func (s *TrafficStore) GetGlobal(ctx context.Context) (*model.TrafficSnapshot, error)
- func (s *TrafficStore) GetHistory(ctx context.Context, start, end int64, label string) ([]model.TrafficHistoryRecord, error)
- func (s *TrafficStore) GetUserSnapshot(ctx context.Context, label string) (snapIn, snapOut int64, err error)
- func (s *TrafficStore) GetUserTraffic(ctx context.Context, label string) (*model.UserTraffic, error)
- func (s *TrafficStore) InsertHistoryBatch(ctx context.Context, ts int64, globalIn, globalOut int64, ...) error
- func (s *TrafficStore) ListUserTraffic(ctx context.Context) ([]model.UserTraffic, error)
- func (s *TrafficStore) ResetGlobal(ctx context.Context) error
- func (s *TrafficStore) UpdateGlobal(ctx context.Context, deltaIn, deltaOut, snapIn, snapOut int64) error
- func (s *TrafficStore) UpdateUserTraffic(ctx context.Context, label string, deltaIn, deltaOut, snapIn, snapOut int64) error
- type UpstreamStore
- func (s *UpstreamStore) ClearHealth(ctx context.Context, name string) error
- func (s *UpstreamStore) Create(ctx context.Context, u *model.Upstream) error
- func (s *UpstreamStore) Delete(ctx context.Context, name string) error
- func (s *UpstreamStore) GetByName(ctx context.Context, name string) (*model.Upstream, error)
- func (s *UpstreamStore) List(ctx context.Context) ([]model.Upstream, error)
- func (s *UpstreamStore) ListEnabled(ctx context.Context) ([]model.Upstream, error)
- func (s *UpstreamStore) Update(ctx context.Context, name string, u *model.Upstream) error
- func (s *UpstreamStore) UpdateEnabled(ctx context.Context, name string, enabled bool) error
- func (s *UpstreamStore) UpdateHealth(ctx context.Context, name string, ok bool, latencyMs int64, errMsg string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes formats bytes into human-readable string.
Types ¶
type AuditStore ¶ added in v0.0.10
type AuditStore struct {
// contains filtered or unexported fields
}
AuditStore handles audit log persistence.
func NewAuditStore ¶ added in v0.0.10
func NewAuditStore(db *sql.DB) *AuditStore
NewAuditStore creates a new AuditStore.
func (*AuditStore) CleanOld ¶ added in v0.0.10
CleanOld removes audit entries older than the given duration.
func (*AuditStore) Insert ¶ added in v0.0.10
func (s *AuditStore) Insert(ctx context.Context, user, action, detail string) error
Insert adds a new audit entry.
func (*AuditStore) List ¶ added in v0.0.10
func (s *AuditStore) List(ctx context.Context, limit, offset int) ([]model.AuditEntry, error)
List returns audit entries ordered by timestamp descending, with pagination.
type Backup ¶
type Backup struct {
Filename string `json:"filename"`
Size int64 `json:"size"`
CreatedAt string `json:"created_at"`
Checksum string `json:"checksum,omitempty"`
Encrypted bool `json:"encrypted"`
}
Backup represents a backup file record.
type BackupStore ¶
type BackupStore struct {
// contains filtered or unexported fields
}
BackupStore handles backup management (listing, creation, deletion). It works with the filesystem in the configured backups directory.
func NewBackupStore ¶
func NewBackupStore(baseDir string, encryptionKey ...[]byte) *BackupStore
NewBackupStore creates a new BackupStore. encryptionKey is optional (nil = no encryption).
func (*BackupStore) CleanOld ¶ added in v0.0.10
CleanOld removes backup files older than maxAge. Returns the number of deleted files.
func (*BackupStore) Create ¶
func (s *BackupStore) Create(ctx context.Context) (Backup, error)
Create generates a new backup of the core application data.
func (*BackupStore) Delete ¶
func (s *BackupStore) Delete(ctx context.Context, filename string) error
Delete removes a backup file.
func (*BackupStore) EncryptionEnabled ¶ added in v0.0.10
func (s *BackupStore) EncryptionEnabled() bool
EncryptionEnabled reports whether backup encryption is configured.
func (*BackupStore) GetPath ¶
func (s *BackupStore) GetPath(filename string) string
GetPath returns the full path to a backup file.
type GeoblockCacheStore ¶
type GeoblockCacheStore struct {
// contains filtered or unexported fields
}
GeoblockCacheStore handles geo-block CIDR cache tracking.
func NewGeoblockCacheStore ¶
func NewGeoblockCacheStore(db *sql.DB) *GeoblockCacheStore
NewGeoblockCacheStore creates a new GeoblockCacheStore.
type InstanceStore ¶
type InstanceStore struct {
// contains filtered or unexported fields
}
InstanceStore handles instance persistence.
func NewInstanceStore ¶
func NewInstanceStore(db *sql.DB) *InstanceStore
NewInstanceStore creates a new InstanceStore.
func (*InstanceStore) Count ¶ added in v0.0.2
func (s *InstanceStore) Count(ctx context.Context) (int, error)
Count returns the total number of instances.
func (*InstanceStore) Delete ¶
func (s *InstanceStore) Delete(ctx context.Context, port int) error
Delete removes an instance by port.
func (*InstanceStore) EnsureDefaultInstance ¶ added in v0.0.2
func (s *InstanceStore) EnsureDefaultInstance(ctx context.Context, proxyPort, metricsPort int) error
EnsureDefaultInstance checks if instances table is empty and seeds it from settings.
type Manifest ¶ added in v0.0.10
type Manifest struct {
FormatVersion int `json:"format_version"`
AppVersion string `json:"app_version"`
AppCommit string `json:"app_commit"`
SchemaVersion int `json:"schema_version"`
CreatedAt string `json:"created_at"`
Encryption string `json:"encryption"` // "aes-gcm" or "none"
Tables []string `json:"tables,omitempty"`
}
Manifest represents the backup manifest metadata.
type QuotaAlertStore ¶
type QuotaAlertStore struct {
// contains filtered or unexported fields
}
QuotaAlertStore handles quota alert deduplication.
func NewQuotaAlertStore ¶
func NewQuotaAlertStore(db *sql.DB) *QuotaAlertStore
NewQuotaAlertStore creates a new QuotaAlertStore.
func (*QuotaAlertStore) ClearForLabel ¶
func (s *QuotaAlertStore) ClearForLabel(ctx context.Context, label string) error
ClearForLabel removes quota alerts when traffic is reset.
func (*QuotaAlertStore) MarkAlerted ¶
MarkAlerted records that a quota alert was sent.
func (*QuotaAlertStore) WasAlerted ¶
WasAlerted checks if a quota alert was already sent for this label+percent combo.
type SchedulerStore ¶ added in v0.0.10
type SchedulerStore struct {
// contains filtered or unexported fields
}
SchedulerStore handles scheduler persistence.
func NewSchedulerStore ¶ added in v0.0.10
func NewSchedulerStore(db *sql.DB) *SchedulerStore
NewSchedulerStore creates a new SchedulerStore.
func (*SchedulerStore) CleanOldHistory ¶ added in v0.0.10
CleanOldHistory removes execution records older than maxAge.
func (*SchedulerStore) DeleteOverride ¶ added in v0.0.10
func (s *SchedulerStore) DeleteOverride(ctx context.Context, taskName string) error
DeleteOverride removes a task override (revert to default).
func (*SchedulerStore) GetLatestHistory ¶ added in v0.0.10
func (s *SchedulerStore) GetLatestHistory(ctx context.Context, taskName string) (*scheduler.ExecutionRecord, error)
GetLatestHistory returns the most recent execution record for a task.
func (*SchedulerStore) GetOverride ¶ added in v0.0.10
func (s *SchedulerStore) GetOverride(ctx context.Context, taskName string) (*scheduler.TaskOverride, error)
GetOverride returns a single task override.
func (*SchedulerStore) GetOverrides ¶ added in v0.0.10
func (s *SchedulerStore) GetOverrides(ctx context.Context) ([]scheduler.TaskOverride, error)
GetOverrides returns all task overrides.
func (*SchedulerStore) InsertHistory ¶ added in v0.0.10
func (s *SchedulerStore) InsertHistory(ctx context.Context, rec *scheduler.ExecutionRecord) error
InsertHistory persists a task execution record.
func (*SchedulerStore) ListHistory ¶ added in v0.0.10
func (s *SchedulerStore) ListHistory(ctx context.Context, limit, offset int) ([]scheduler.ExecutionRecord, error)
ListHistory returns recent execution history for all tasks.
func (*SchedulerStore) ListHistoryByTask ¶ added in v0.0.10
func (s *SchedulerStore) ListHistoryByTask(ctx context.Context, taskName string, limit, offset int) ([]scheduler.ExecutionRecord, error)
ListHistoryByTask returns recent execution history for a specific task.
func (*SchedulerStore) UpsertOverride ¶ added in v0.0.10
func (s *SchedulerStore) UpsertOverride(ctx context.Context, o *scheduler.TaskOverride) error
UpsertOverride inserts or updates a task override.
type SecretStore ¶
type SecretStore struct {
// contains filtered or unexported fields
}
SecretStore handles secret persistence in SQLite.
func NewSecretStore ¶
func NewSecretStore(db *sql.DB) *SecretStore
NewSecretStore creates a new SecretStore.
func (*SecretStore) Archive ¶ added in v0.0.10
func (s *SecretStore) Archive(ctx context.Context, label string) error
Archive sets archived_at on a secret, effectively hiding it.
func (*SecretStore) BulkExtendExpiry ¶ added in v0.0.10
func (s *SecretStore) BulkExtendExpiry(ctx context.Context, labels []string, expiresAt string, reenable bool) (int, error)
BulkExtendExpiry extends expiry for multiple labels by setting a new date.
func (*SecretStore) BulkRotateKeys ¶ added in v0.0.10
func (s *SecretStore) BulkRotateKeys(ctx context.Context, labels []string, keys map[string]string) (int, error)
BulkRotateKeys rotates keys for multiple labels.
func (*SecretStore) BulkSetLimits ¶ added in v0.0.10
func (s *SecretStore) BulkSetLimits(ctx context.Context, labels []string, maxConns, maxIPs int, quotaBytes int64, expiresAt string) (int, error)
BulkSetLimits sets the same limits for multiple secrets by labels.
func (*SecretStore) BulkToggleEnabled ¶ added in v0.0.10
func (s *SecretStore) BulkToggleEnabled(ctx context.Context, labels []string, enable bool) (int, error)
BulkToggleEnabled enables or disables multiple secrets by labels.
func (*SecretStore) CloneSecret ¶ added in v0.0.10
func (s *SecretStore) CloneSecret(ctx context.Context, srcLabel, newLabel, newKey string) (*model.Secret, error)
CloneSecret creates a copy of an existing secret with a new label.
func (*SecretStore) Count ¶
func (s *SecretStore) Count(ctx context.Context) (int, error)
Count returns total number of secrets.
func (*SecretStore) CountEnabled ¶
func (s *SecretStore) CountEnabled(ctx context.Context) (int, error)
CountEnabled returns the count of enabled secrets.
func (*SecretStore) CountEnabledByLabels ¶ added in v0.0.10
CountEnabledByLabels returns the count of enabled secrets among the given labels.
func (*SecretStore) Delete ¶
func (s *SecretStore) Delete(ctx context.Context, label string) error
Delete removes a secret by label.
func (*SecretStore) DisableExpired ¶ added in v0.0.10
func (s *SecretStore) DisableExpired(ctx context.Context) (int, error)
DisableExpired disables all secrets whose expiry is in the past. Returns the number of secrets disabled. Never disables the last enabled secret.
func (*SecretStore) ExtendExpiry ¶ added in v0.0.10
func (s *SecretStore) ExtendExpiry(ctx context.Context, label, expiresAt string, reenable bool) error
ExtendExpiry sets a new expiry date for a secret, optionally re-enabling it.
func (*SecretStore) GetByLabel ¶
GetByLabel returns a single secret by label.
func (*SecretStore) LabelsByTag ¶ added in v0.0.10
LabelsByTag returns labels of secrets that have the given tag.
func (*SecretStore) ListAllTags ¶ added in v0.0.10
func (s *SecretStore) ListAllTags(ctx context.Context) ([]string, error)
ListAllTags returns all unique tags across all secrets.
func (*SecretStore) ListByTag ¶ added in v0.0.10
ListByTag returns secrets that contain the given tag.
func (*SecretStore) ListEnabledLabels ¶
func (s *SecretStore) ListEnabledLabels(ctx context.Context) ([]string, error)
ListEnabledLabels returns labels of all enabled secrets.
func (*SecretStore) RenameLabel ¶ added in v0.0.10
func (s *SecretStore) RenameLabel(ctx context.Context, oldLabel, newLabel string) error
RenameLabel changes the label of a secret and its traffic row.
func (*SecretStore) ResetAllTraffic ¶
func (s *SecretStore) ResetAllTraffic(ctx context.Context) error
ResetAllTraffic clears traffic for all users.
func (*SecretStore) ResetTraffic ¶
func (s *SecretStore) ResetTraffic(ctx context.Context, label string) error
ResetTraffic clears traffic for a specific user.
func (*SecretStore) Search ¶ added in v0.0.10
Search returns secrets matching a text query in label or notes.
func (*SecretStore) Unarchive ¶ added in v0.0.10
func (s *SecretStore) Unarchive(ctx context.Context, label string) error
Unarchive clears archived_at on a secret.
func (*SecretStore) UpdateTags ¶ added in v0.0.10
func (s *SecretStore) UpdateTags(ctx context.Context, label, tags string) error
UpdateTags sets the tags string for a secret.
func (*SecretStore) UpdateTraffic ¶
func (s *SecretStore) UpdateTraffic(ctx context.Context, label string, deltaIn, deltaOut int64) error
UpdateTraffic increments the traffic counter for a user.
type SettingsStore ¶
type SettingsStore struct {
// contains filtered or unexported fields
}
SettingsStore handles settings persistence.
func NewSettingsStore ¶
func NewSettingsStore(db *sql.DB) *SettingsStore
NewSettingsStore creates a new SettingsStore.
func (*SettingsStore) GetAuthPasswordHash ¶
func (s *SettingsStore) GetAuthPasswordHash(ctx context.Context) (string, error)
GetAuthPasswordHash returns the stored bcrypt password hash.
func (*SettingsStore) GetJWTSecret ¶
func (s *SettingsStore) GetJWTSecret(ctx context.Context) (string, error)
GetJWTSecret returns the JWT signing secret, generating one if empty.
func (*SettingsStore) SetAuthPasswordHash ¶
func (s *SettingsStore) SetAuthPasswordHash(ctx context.Context, hash string) error
SetAuthPasswordHash stores the bcrypt password hash.
type SlaveStore ¶
type SlaveStore struct {
// contains filtered or unexported fields
}
SlaveStore handles replication slave persistence.
func NewSlaveStore ¶
func NewSlaveStore(db *sql.DB) *SlaveStore
NewSlaveStore creates a new SlaveStore.
func (*SlaveStore) Delete ¶
func (s *SlaveStore) Delete(ctx context.Context, host string) error
Delete removes a slave by host.
func (*SlaveStore) UpdateStatus ¶
UpdateStatus updates a slave's sync status.
type TemplateStore ¶ added in v0.0.10
type TemplateStore struct {
// contains filtered or unexported fields
}
TemplateStore handles secret template persistence.
func NewTemplateStore ¶ added in v0.0.10
func NewTemplateStore(db *sql.DB) *TemplateStore
NewTemplateStore creates a new TemplateStore.
func (*TemplateStore) Create ¶ added in v0.0.10
func (s *TemplateStore) Create(ctx context.Context, t *model.SecretTemplate) error
Create inserts a new template.
func (*TemplateStore) Delete ¶ added in v0.0.10
func (s *TemplateStore) Delete(ctx context.Context, name string) error
Delete removes a template by name.
func (*TemplateStore) GetByName ¶ added in v0.0.10
func (s *TemplateStore) GetByName(ctx context.Context, name string) (*model.SecretTemplate, error)
GetByName returns a template by name.
func (*TemplateStore) List ¶ added in v0.0.10
func (s *TemplateStore) List(ctx context.Context) ([]model.SecretTemplate, error)
List returns all templates.
type TokenBlocklistStore ¶
type TokenBlocklistStore struct {
// contains filtered or unexported fields
}
TokenBlocklistStore handles JWT token revocation.
func NewTokenBlocklistStore ¶
func NewTokenBlocklistStore(db *sql.DB) *TokenBlocklistStore
NewTokenBlocklistStore creates a new TokenBlocklistStore.
type TrafficStore ¶
type TrafficStore struct {
// contains filtered or unexported fields
}
TrafficStore handles cumulative traffic persistence.
func NewTrafficStore ¶
func NewTrafficStore(db *sql.DB) *TrafficStore
NewTrafficStore creates a new TrafficStore.
func (*TrafficStore) CleanOldHistory ¶ added in v0.0.10
CleanOldHistory deletes traffic history records older than maxAge.
func (*TrafficStore) FlushTraffic ¶
func (s *TrafficStore) FlushTraffic(ctx context.Context, global model.TrafficSnapshot, users map[string]model.TrafficSnapshot) error
FlushTraffic persists all traffic deltas in a single transaction.
func (*TrafficStore) GetAggregatedHistory ¶ added in v0.0.10
func (s *TrafficStore) GetAggregatedHistory(ctx context.Context, start, end int64, label string, groupSeconds int64) ([]model.TrafficHistoryRecord, error)
GetAggregatedHistory returns traffic history aggregated by hour or day.
func (*TrafficStore) GetAllUserSnapshots ¶ added in v0.0.4
GetAllUserSnapshots returns all user snapshots in a single query.
func (*TrafficStore) GetGlobal ¶
func (s *TrafficStore) GetGlobal(ctx context.Context) (*model.TrafficSnapshot, error)
GetGlobal returns cumulative global traffic.
func (*TrafficStore) GetHistory ¶ added in v0.0.10
func (s *TrafficStore) GetHistory(ctx context.Context, start, end int64, label string) ([]model.TrafficHistoryRecord, error)
GetHistory returns traffic history records for the given time range and label.
func (*TrafficStore) GetUserSnapshot ¶
func (s *TrafficStore) GetUserSnapshot(ctx context.Context, label string) (snapIn, snapOut int64, err error)
GetUserSnapshot returns the raw Prometheus snapshot for a user.
func (*TrafficStore) GetUserTraffic ¶
func (s *TrafficStore) GetUserTraffic(ctx context.Context, label string) (*model.UserTraffic, error)
GetUserTraffic returns traffic for a specific user.
func (*TrafficStore) InsertHistoryBatch ¶ added in v0.0.10
func (s *TrafficStore) InsertHistoryBatch(ctx context.Context, ts int64, globalIn, globalOut int64, users map[string][2]int64) error
InsertHistoryBatch persists traffic deltas as history records in a single transaction.
func (*TrafficStore) ListUserTraffic ¶
func (s *TrafficStore) ListUserTraffic(ctx context.Context) ([]model.UserTraffic, error)
ListUserTraffic returns all per-user traffic stats.
func (*TrafficStore) ResetGlobal ¶
func (s *TrafficStore) ResetGlobal(ctx context.Context) error
ResetGlobal clears global traffic counters.
func (*TrafficStore) UpdateGlobal ¶
func (s *TrafficStore) UpdateGlobal(ctx context.Context, deltaIn, deltaOut, snapIn, snapOut int64) error
UpdateGlobal adds deltas to global traffic and updates the snapshot.
func (*TrafficStore) UpdateUserTraffic ¶
func (s *TrafficStore) UpdateUserTraffic(ctx context.Context, label string, deltaIn, deltaOut, snapIn, snapOut int64) error
UpdateUserTraffic adds deltas to a user's traffic and updates the snapshot.
type UpstreamStore ¶
type UpstreamStore struct {
// contains filtered or unexported fields
}
UpstreamStore handles upstream persistence.
func NewUpstreamStore ¶
func NewUpstreamStore(db *sql.DB) *UpstreamStore
NewUpstreamStore creates a new UpstreamStore.
func (*UpstreamStore) ClearHealth ¶ added in v0.0.10
func (s *UpstreamStore) ClearHealth(ctx context.Context, name string) error
ClearHealth resets all health-related fields to their default values.
func (*UpstreamStore) Delete ¶
func (s *UpstreamStore) Delete(ctx context.Context, name string) error
Delete removes an upstream by name.
func (*UpstreamStore) ListEnabled ¶ added in v0.0.10
ListEnabled returns only enabled upstreams.
func (*UpstreamStore) Update ¶ added in v0.0.7
Update modifies an existing upstream identified by name.
func (*UpstreamStore) UpdateEnabled ¶
UpdateEnabled toggles an upstream's enabled state.
func (*UpstreamStore) UpdateHealth ¶ added in v0.0.10
func (s *UpstreamStore) UpdateHealth(ctx context.Context, name string, ok bool, latencyMs int64, errMsg string) error
UpdateHealth updates health status fields for an upstream.