bolt

package
v0.0.0-...-78a2729 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AutoLockDuration is the duration of the automatic lock of the auto executions,
	// it can be multiplied by the attempt number
	AutoLockDuration = 60 * time.Minute
	// LockDuration is the duration of the lock of the scheduler's runs
	LockDuration = 30 * time.Minute
)
View Source
const ReminderDelay = 7 * 24 * time.Hour

ReminderDelay is the delay between sending reminders to the same host

Variables

This section is empty.

Functions

This section is empty.

Types

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo is a wrapper around bbolt.DB

func NewRepo

func NewRepo(db *bbolt.DB, log *zerolog.Logger) (*Repo, error)

NewRepo creates a new repo

func (*Repo) AnyInProgress

func (r *Repo) AnyInProgress() bool

AnyInProgress checks if there are any locks

func (*Repo) AppendRecurrings

func (r *Repo) AppendRecurrings(recurrings []*models.Recurring) error

AppendRecurrings inserts new recurring schedules, only if not exists already

func (*Repo) AppendSchedules

func (r *Repo) AppendSchedules(schedules []*models.Schedule) ([]string, error)

AppendSchedules to the database, only if homeserver doesn't have any

func (Repo) CreateSchedulesFromRecurring

func (r Repo) CreateSchedulesFromRecurring(adminRoomID id.RoomID) error

CreateSchedulesFromRecurring creates schedules from recurring schedules.

func (*Repo) DisableRecurring

func (r *Repo) DisableRecurring(host string) error

DisableRecurring removes recurrings and schedules

func (*Repo) GetAllHosts

func (r *Repo) GetAllHosts() ([]string, error)

GetHosts returns ALL hosts from the database

func (*Repo) GetAllRecurrings

func (r *Repo) GetAllRecurrings() ([]*models.Recurring, error)

GetAllRecurrings from the database

func (*Repo) GetAllSchedules

func (r *Repo) GetAllSchedules() ([]*models.Schedule, error)

GetAllSchedules from the database

func (*Repo) GetContacts

func (r *Repo) GetContacts(host string) (*models.Contacts, error)

GetContacts returns the contacts for the given host.

func (*Repo) GetRandomRecurringTime

func (r *Repo) GetRandomRecurringTime() string

GetRandomRecurringTime generates random valid TimeFormatRecurring string

func (*Repo) GetRecurrings

func (r *Repo) GetRecurrings(host string) ([]*models.Recurring, error)

GetRecurrings from the database

func (*Repo) GetRuns

func (r *Repo) GetRuns(host string) ([]*models.Run, error)

GetRuns from the database

func (*Repo) GetSchedules

func (r *Repo) GetSchedules(host string) ([]*models.Schedule, error)

GetSchedules from the database

func (*Repo) GetStats

func (r *Repo) GetStats() (*models.Stats, error)

GetStats from the database

func (*Repo) IsAutoLocked

func (r *Repo) IsAutoLocked(host string) bool

IsAutoLocked checks if the host is locked for the automatic execution

func (*Repo) IsLocked

func (r *Repo) IsLocked(host string) bool

IsLocked checks if the host is locked

func (*Repo) IsReminded

func (r *Repo) IsReminded(host string) bool

IsReminded checks if the host has been reminded in the last ReminderDelay

func (*Repo) Lock

func (r *Repo) Lock(host string) error

Lock locks the host for the duration of an execution

func (*Repo) PopInvites

func (r *Repo) PopInvites(max int) ([]*models.Invite, error)

PopInvites from the database

func (*Repo) PopNotifications

func (r *Repo) PopNotifications(max int) ([]*models.Notification, error)

PopNotifications from the database

func (*Repo) PopSchedules

func (r *Repo) PopSchedules(max int) ([]*models.Schedule, error)

PopSchedules pops up to max schedules that are ready for execution.

func (*Repo) PurgeHost

func (r *Repo) PurgeHost(host string) error

PurgeHost removes all data associated with a host

func (*Repo) ReleaseAutoLock

func (r *Repo) ReleaseAutoLock(host string)

ReleaseAutoLock releases the lock of the host for the automatic execution

func (*Repo) RemoveRuns

func (r *Repo) RemoveRuns(max []byte) error

RemoveRuns removes runs from the database

func (*Repo) RemoveSchedules

func (r *Repo) RemoveSchedules(host string, fromRecurring bool) error

RemoveSchedules removes all schedules for a given homeserver.

func (*Repo) SetContacts

func (r *Repo) SetContacts(host string, contacts *models.Contacts) error

SetContacts sets the contacts for the given host.

func (*Repo) SetReminded

func (r *Repo) SetReminded(host string) error

SetReminded sets the reminder for the host

func (*Repo) Stop

func (r *Repo) Stop()

Stop closes the database

func (*Repo) Unlock

func (r *Repo) Unlock(host string)

Unlock releases the lock

func (*Repo) UpdateAutoLocks

func (r *Repo) UpdateAutoLocks(hosts []string)

UpdateAutoLocks updates the locks of the hosts for the automatic execution

func (*Repo) UpsertInvite

func (r *Repo) UpsertInvite(inv *models.Invite) error

UpsertInvite adds or updates the invite in the database.

func (*Repo) UpsertNotification

func (r *Repo) UpsertNotification(n *models.Notification, differentID ...string) error

UpsertNotification inserts or updates a notification in the database.

func (*Repo) UpsertRecurring

func (r *Repo) UpsertRecurring(s *models.Recurring) error

UpsertRecurring inserts or updates recurring schedule

func (*Repo) UpsertRun

func (r *Repo) UpsertRun(run *models.Run) error

UpsertRun adds a run to the database or updates it if it already exists

func (*Repo) UpsertSchedule

func (r *Repo) UpsertSchedule(s *models.Schedule) error

UpsertSchedule inserts or updates a schedule.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL