Documentation ¶
Overview ¶
IronWorker (elastic computing) client library
Index ¶
- Variables
- func ConfigAsString() (string, error)
- func ConfigFromJSON(v interface{}) error
- func ConfigReader() (io.ReadCloser, error)
- func IronTaskDir() string
- func IronTaskId() string
- func ParseFlags()
- func PayloadAsString() (string, error)
- func PayloadFromJSON(v interface{}) error
- func PayloadReader() (io.ReadCloser, error)
- type Code
- type CodeInfo
- type CodeSource
- type Schedule
- type ScheduleInfo
- type Task
- type TaskInfo
- type TaskListParams
- type Worker
- func (w *Worker) CodePackageDelete(codeId string) (err error)
- func (w *Worker) CodePackageDownload(codeId string) (code Code, err error)
- func (w *Worker) CodePackageInfo(codeId string) (code CodeInfo, err error)
- func (w *Worker) CodePackageList(page, perPage int) (codes []CodeInfo, err error)
- func (w *Worker) CodePackageRevisions(codeId string) (code Code, err error)
- func (w *Worker) CodePackageUpload(code Code) (id string, err error)
- func (w *Worker) FilteredTaskList(params TaskListParams) (tasks []TaskInfo, err error)
- func (w *Worker) Schedule(schedules ...Schedule) (scheduleIds []string, err error)
- func (w *Worker) ScheduleCancel(scheduleId string) (err error)
- func (w *Worker) ScheduleInfo(scheduleId string) (info ScheduleInfo, err error)
- func (w *Worker) ScheduleList() (schedules []ScheduleInfo, err error)
- func (w *Worker) TaskCancel(taskId string) (err error)
- func (w *Worker) TaskInfo(taskId string) (task TaskInfo, err error)
- func (w *Worker) TaskList() (tasks []TaskInfo, err error)
- func (w *Worker) TaskLog(taskId string) (log []byte, err error)
- func (w *Worker) TaskProgress(taskId string, progress int, msg string) (err error)
- func (w *Worker) TaskQueue(tasks ...Task) (taskIds []string, err error)
- func (w *Worker) TaskQueueWebhook() (err error)
- func (w *Worker) WaitForTask(taskId string) chan TaskInfo
- func (w *Worker) WaitForTaskLog(taskId string) chan []byte
Constants ¶
This section is empty.
Variables ¶
var ( TaskDir string TaskId string )
var GoCodeRunner = []byte(`#!/bin/sh
root() {
while [ $# -gt 0 ]; do
if [ "$1" = "-d" ]; then
printf "%s\n" "$2"
break
fi
done
}
cd "$(root "$@")"
chmod +x worker
./worker "$@"
`)
Functions ¶
func ConfigAsString ¶
func ConfigFromJSON ¶
func ConfigFromJSON(v interface{}) error
func ConfigReader ¶
func ConfigReader() (io.ReadCloser, error)
func IronTaskDir ¶
func IronTaskDir() string
func IronTaskId ¶
func IronTaskId() string
func PayloadAsString ¶
func PayloadFromJSON ¶
func PayloadFromJSON(v interface{}) error
func PayloadReader ¶
func PayloadReader() (io.ReadCloser, error)
Types ¶
type Code ¶
type Code struct { Id string `json:"id,omitempty"` Name string `json:"name"` Runtime string `json:"runtime,omitempty"` FileName string `json:"file_name,omitempty"` Config string `json:"config,omitempty"` MaxConcurrency int `json:"max_concurrency,omitempty"` Retries int `json:"retries,omitempty"` Stack string `json:"stack,omitempty"` Image string `json:"image,omitempty"` Command string `json:"command,omitempty"` RetriesDelay time.Duration `json:"-"` Source CodeSource `json:"-"` Host string `json:"host,omitempty"` }
type CodeInfo ¶
type CodeInfo struct { Id string `json:"id"` LatestChecksum string `json:"latest_checksum,omitempty"` LatestHistoryId string `json:"latest_history_id"` Name string `json:"name"` ProjectId string `json:"project_id"` Runtime *string `json:"runtime,omitempty"` Rev int `json:"rev"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` LatestChange time.Time `json:"latest_change"` }
type CodeSource ¶
type Schedule ¶
type Schedule struct { CodeName string `json:"code_name"` Delay *time.Duration `json:"delay"` EndAt *time.Time `json:"end_at"` MaxConcurrency *int `json:"max_concurrency"` Name string `json:"name"` Payload string `json:"payload"` Priority *int `json:"priority"` RunEvery *int `json:"run_every"` RunTimes *int `json:"run_times"` StartAt *time.Time `json:"start_at"` Cluster string `json:"cluster"` Label string `json:"label"` }
type ScheduleInfo ¶
type ScheduleInfo struct { CodeName string `json:"code_name"` CreatedAt time.Time `json:"created_at"` EndAt time.Time `json:"end_at"` Id string `json:"id"` LastRunTime time.Time `json:"last_run_time"` MaxConcurrency int `json:"max_concurrency"` Msg string `json:"msg"` NextStart time.Time `json:"next_start"` ProjectId string `json:"project_id"` RunCount int `json:"run_count"` RunTimes int `json:"run_times"` StartAt time.Time `json:"start_at"` Status string `json:"status"` UpdatedAt time.Time `json:"updated_at"` }
type TaskInfo ¶
type TaskInfo struct { CodeHistoryId string `json:"code_history_id"` CodeId string `json:"code_id"` CodeName string `json:"code_name"` CodeRev string `json:"code_rev"` Id string `json:"id"` Payload string `json:"payload"` ProjectId string `json:"project_id"` Status string `json:"status"` Msg string `json:"msg,omitempty"` ScheduleId string `json:"schedule_id"` Duration int `json:"duration"` RunTimes int `json:"run_times"` Timeout int `json:"timeout"` Percent int `json:"percent,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` }
type TaskListParams ¶
type Worker ¶
func (*Worker) CodePackageDelete ¶
CodePackageDelete deletes a code package
func (*Worker) CodePackageDownload ¶
CodePackageDownload downloads a code package
func (*Worker) CodePackageInfo ¶
CodePackageInfo gets info about a code package
func (*Worker) CodePackageList ¶
CodePackageList lists code packages.
The page argument decides the page of code packages you want to retrieve, starting from 0, maximum is 100.
The perPage argument determines the number of code packages to return. Note this is a maximum value, so there may be fewer packages returned if there aren’t enough results. If this is < 1, 1 will be the default. Maximum is 100.
func (*Worker) CodePackageRevisions ¶
CodePackageRevisions lists the revisions of a code pacakge
func (*Worker) CodePackageUpload ¶
CodePackageUpload uploads a code package
func (*Worker) FilteredTaskList ¶
func (w *Worker) FilteredTaskList(params TaskListParams) (tasks []TaskInfo, err error)
func (*Worker) ScheduleCancel ¶
ScheduleCancel cancels a scheduled task
func (*Worker) ScheduleInfo ¶
func (w *Worker) ScheduleInfo(scheduleId string) (info ScheduleInfo, err error)
ScheduleInfo gets info about a scheduled task
func (*Worker) ScheduleList ¶
func (w *Worker) ScheduleList() (schedules []ScheduleInfo, err error)
ScheduleList lists Scheduled Tasks
func (*Worker) TaskCancel ¶
TaskCancel cancels a Task
func (*Worker) TaskProgress ¶
TaskProgress sets a Task's Progress
func (*Worker) TaskQueueWebhook ¶
TaskQueueWebhook queues a Task from a Webhook
func (*Worker) WaitForTask ¶
WaitForTask returns a channel that will receive the completed task and is closed afterwards. If an error occured during the wait, the channel will be closed.