system

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GormStore

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

func (*GormStore) GetSettings

func (s *GormStore) GetSettings() (*Settings, error)

func (*GormStore) SaveSettings

func (s *GormStore) SaveSettings(settings *Settings) error

type Service

type Service interface {
	GetSettings() (*Settings, error)
	SaveSettings(settings *Settings) error
	// Pauses the system for a configured duration
	Pause() error
	// Will immediately revoke the pause timer
	Resume() error
	IsHalted() (bool, error)
}

func NewService

func NewService(store Store, opts ...ServiceOption) Service

type ServiceImpl added in v0.10.0

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

func (*ServiceImpl) GetSettings added in v0.10.0

func (svc *ServiceImpl) GetSettings() (*Settings, error)

func (*ServiceImpl) IsHalted added in v0.10.0

func (svc *ServiceImpl) IsHalted() (bool, error)

func (*ServiceImpl) Pause added in v0.10.0

func (svc *ServiceImpl) Pause() error

func (*ServiceImpl) Resume added in v0.10.0

func (svc *ServiceImpl) Resume() error

func (*ServiceImpl) SaveSettings added in v0.10.0

func (svc *ServiceImpl) SaveSettings(settings *Settings) error

type ServiceOption

type ServiceOption func(*ServiceImpl)

func WithPauseDuration

func WithPauseDuration(duration time.Duration) ServiceOption

type Settings

type Settings struct {
	gorm.Model
	MaintenanceMode bool         `gorm:"column:maintenance_mode;default:false"`
	PausedSince     sql.NullTime `gorm:"column:paused_since"`
}

func (*Settings) FromJSON

func (s *Settings) FromJSON(j SettingsJSON)

Update fields according to JSON version

func (*Settings) IsMaintenanceMode

func (s *Settings) IsMaintenanceMode() bool

func (*Settings) IsPaused

func (s *Settings) IsPaused(pauseDuration time.Duration) bool

func (*Settings) String

func (s *Settings) String() string

func (Settings) TableName

func (Settings) TableName() string

func (*Settings) ToJSON

func (s *Settings) ToJSON() SettingsJSON

Convert to JSON version

type SettingsJSON

type SettingsJSON struct {
	MaintenanceMode bool `json:"maintenanceMode"`
}

type Store

type Store interface {
	GetSettings() (*Settings, error)
	SaveSettings(*Settings) error
}

func NewGormStore

func NewGormStore(db *gorm.DB) Store

Jump to

Keyboard shortcuts

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