Documentation ¶
Index ¶
- Constants
- func StartAllActiveChores(ctx context.Context) (int, error)
- type Chore
- type ChoreConfig
- type ChoreLog
- type ChoreTemplate
- func (ct *ChoreTemplate) Delete() error
- func (ct *ChoreTemplate) GenerateChoreConfig(inputValues map[string]string) (*ChoreConfig, error)
- func (ct *ChoreTemplate) GenerateTemplateConfigs() error
- func (ct *ChoreTemplate) GetChoreSnapshot(inputs map[string]string) []byte
- func (ct *ChoreTemplate) Save() error
- type ChoreTemplateConfig
- type ConfigInput
- type RegisteredTrigger
Constants ¶
const ErrorLog = "error"
const InfoLog = "info"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Chore ¶
type Chore struct { Name string `json:"name"` Id string `json:"id"` Active bool `json:"active"` Template ChoreTemplate `json:"template"` Config ChoreConfig `json:"choreSettings"` Snapshot []byte `json:"-"` }
A chore is a workflow for Marvin to execute. It consists of a number of triggers with callbacks that specify what should happen when a trigger fires.
func FromTemplate ¶
FromTemplate creates a new Chore based on a template.
func (*Chore) GetLogsUpTo ¶
GetLogsUpTo returns the n latest logs befofe a specific time t.
type ChoreConfig ¶
type ChoreConfig struct { // configurable parameters that are used by the script specify behavior. Inputs map[string]string `json:"inputs"` // The registered triggers, associated with their parameters. Triggers []choreTrigger `json:"triggers"` }
holds configuration data for the chore.
type ChoreTemplate ¶
type ChoreTemplate struct { Name string `json:"name"` Id string `json:"id"` Created time.Time `json:"created"` Script string `json:"script"` Config ChoreTemplateConfig `json:"templateSettings"` }
ChoreTemplate is a template for a chore (how surprising!)
func GetChoreTemplates ¶
func GetChoreTemplates() ([]*ChoreTemplate, error)
GetChoreTemplates gets all chore templates from the database.
func LoadChoreTemplate ¶
func LoadChoreTemplate(id string) (*ChoreTemplate, error)
LoadChoreTemplate loads a single template from the database
func NewChoreTemplate ¶
func NewChoreTemplate(name, script string) (*ChoreTemplate, error)
NewChoreTemplate creates a new chore template with the given name and string. It executes the script to determine which triggers are registered, and which inputs are requested.
func (*ChoreTemplate) Delete ¶
func (ct *ChoreTemplate) Delete() error
Delete removes a chore template from the database.
func (*ChoreTemplate) GenerateChoreConfig ¶
func (ct *ChoreTemplate) GenerateChoreConfig(inputValues map[string]string) (*ChoreConfig, error)
GenerateChoreConfig runs the template's script with the given inputs to generate a chore config.
func (*ChoreTemplate) GenerateTemplateConfigs ¶
func (ct *ChoreTemplate) GenerateTemplateConfigs() error
GenerateTemplateConfig runs the script to generate a ChoreTemplateConfig
func (*ChoreTemplate) GetChoreSnapshot ¶
func (ct *ChoreTemplate) GetChoreSnapshot(inputs map[string]string) []byte
GetChoreSnapshot generates a v8 Snapshot with all triggers in the template registered.
func (*ChoreTemplate) Save ¶
func (ct *ChoreTemplate) Save() error
Save stores a chore template to the database.
type ChoreTemplateConfig ¶
type ChoreTemplateConfig struct { Triggers []RegisteredTrigger `json:"triggers"` Inputs []ConfigInput `json:"inputs"` }
ChoreTemplateConfig holds configuration information about a trigger.
type ConfigInput ¶
ConfigInput describes a parameter that is configurable by the user when creating a chore from a template.
type RegisteredTrigger ¶
type RegisteredTrigger struct { Provider string `json:"provider"` Group string `json:"group"` Action string `json:"action"` }
RegisteredTrigger holds information about a trigger, registered in a template.