config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Type              model.ActionType `yaml:"type"`
	HTTPRequestAction `yaml:",inline"`
	CloudPubSubAction `yaml:",inline"`
	CloudTasksAction  `yaml:",inline"`
	Payload           map[string]interface{} `yaml:"payload"`
}

Action is action definition.

type CloudPubSubAction

type CloudPubSubAction struct {
	Topic string `yaml:"topic"`
}

CloudPubSubAction is configuration of Cloud Pub/Sub action.

type CloudTasksAction

type CloudTasksAction struct {
	Location            string `yaml:"location"`
	Queue               string `yaml:"queue"`
	TaskIDPrefix        string `yaml:"task_id_prefix"`
	ServiceAccountEmail string `yaml:"service_account_email"`
}

CloudTasksAction is configuration of Cloud Tasks action.

type Config

type Config struct {
	Version    string                      `yaml:"version"`
	Mode       model.RunningMode           `yaml:"mode"`
	Interval   time.Duration               `yaml:"interval"`
	CalendarID string                      `yaml:"calendar_id"`
	Handler    map[string]EventHandler     `yaml:"handler"`
	Action     map[model.ActionName]Action `yaml:"action"`
}

Config represents a config.yml.

func Parse

func Parse(configPath string) (*Config, error)

Parse parses config file and returns config data.

func (*Config) ActionConfigMap

func (c *Config) ActionConfigMap() map[model.ActionName]model.ActionConfig

ActionConfigMap returns action config map.

func (*Config) ActionNames

func (c *Config) ActionNames(event model.ScheduleEvent) ([]model.ActionName, bool)

ActionNames returns action names from event schedule.

func (*Config) Calendar

func (c *Config) Calendar() string

Calendar returns google calendar id.

func (*Config) RunningMode

func (c *Config) RunningMode() model.RunningMode

RunningMode returns running mode.

func (*Config) SyncInterval

func (c *Config) SyncInterval() time.Duration

SyncInterval retruns sync interval for resident mode.

type EventHandler

type EventHandler struct {
	Start []model.ActionName `yaml:"start"`
	End   []model.ActionName `yaml:"end"`
}

EventHandler is event handler which contains action names.

type HTTPRequestAction

type HTTPRequestAction struct {
	Method string      `yaml:"method"`
	Header http.Header `yaml:"header"`
	URL    string      `yaml:"url"`
}

HTTPRequestAction is configuration of HTTP action.

Jump to

Keyboard shortcuts

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