performer

package
v0.0.0-...-e9cb272 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

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

CLI uses the CLI interface for site interactions. Don't initialize directly, use NewCLI()

func NewCLI

func NewCLI(wpCLIPath string, wpPath string, fpmURL string, metrics metrics.Manager, logger logger.Logger) *CLI

NewCLI sets up the CLI Performer w/ special initializations.

func (*CLI) GetEvents

func (perf *CLI) GetEvents(site Site) ([]Event, error)

GetEvents returns a list of events for a particular site via CLI.

func (*CLI) GetSites

func (perf *CLI) GetSites(hbInterval time.Duration) (Sites, error)

GetSites fetches a list of sites this instance is responsible for tracking via CLI. Returns an empty instance of Sites on error.

func (*CLI) IsReady

func (perf *CLI) IsReady() bool

func (*CLI) RunEvent

func (perf *CLI) RunEvent(event Event) error

RunEvent runs an event via CLI.

type Event

type Event struct {
	URL       string
	Timestamp int    `json:"timestamp"`
	Action    string `json:"action"`
	Instance  string `json:"instance"`
}

The Event recieved and run from the WP site.

func (Event) LockKey

func (e Event) LockKey() string

func (Event) String

func (e Event) String() string

func (Event) Time

func (e Event) Time() time.Time

type Mock

type Mock struct {
	UseSleeps   bool
	LogCommands bool
	RotateSites bool
	// contains filtered or unexported fields
}

Mock is a fake performer, gives example data back. Useful for testing orchestrator changes.

func (*Mock) GetEvents

func (perf *Mock) GetEvents(site Site) ([]Event, error)

GetEvents returns a mocked list of events.

func (*Mock) GetSites

func (perf *Mock) GetSites(_ time.Duration) (Sites, error)

GetSites fetches a mocked list of sites.

func (*Mock) IsReady

func (perf *Mock) IsReady() bool

func (*Mock) RunEvent

func (perf *Mock) RunEvent(event Event) error

RunEvent mocks the running of an event.

type Performer

type Performer interface {
	IsReady() bool
	GetSites(time.Duration) (Sites, error)
	GetEvents(site Site) ([]Event, error)
	RunEvent(event Event) error
}

Performer is responsible for the real interaction w/ sites. It does the event fetching and running, be that through wp cli, php-fpm, or rest apis.

type Site

type Site struct {
	URL string `json:"url"`
}

A Site in a WP install.

func (*Site) LockKey

func (s *Site) LockKey() string

type Sites

type Sites = map[string]Site

Sites is a map of siteurl => Site

Jump to

Keyboard shortcuts

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