Documentation
¶
Index ¶
- Variables
- func Authenticate(w rest.ResponseWriter, r *rest.Request)
- func DeleteAccount(w rest.ResponseWriter, r *rest.Request)
- func DeleteApplication(w rest.ResponseWriter, r *rest.Request)
- func DeleteApplications(w rest.ResponseWriter, r *rest.Request)
- func DeleteQueue(w rest.ResponseWriter, r *rest.Request)
- func DeleteQueues(w rest.ResponseWriter, r *rest.Request)
- func DeleteTask(w rest.ResponseWriter, r *rest.Request)
- func DeleteTasks(w rest.ResponseWriter, r *rest.Request)
- func GetAccount(w rest.ResponseWriter, r *rest.Request)
- func GetAccounts(w rest.ResponseWriter, r *rest.Request)
- func GetApplication(w rest.ResponseWriter, r *rest.Request)
- func GetApplications(w rest.ResponseWriter, r *rest.Request)
- func GetAttempt(w rest.ResponseWriter, r *rest.Request)
- func GetAttempts(w rest.ResponseWriter, r *rest.Request)
- func GetBase(r *rest.Request) *models.Base
- func GetCurentAccount(r *rest.Request) *bson.ObjectId
- func GetQueue(w rest.ResponseWriter, r *rest.Request)
- func GetQueues(w rest.ResponseWriter, r *rest.Request)
- func GetStatus(w rest.ResponseWriter, r *rest.Request)
- func GetTask(w rest.ResponseWriter, r *rest.Request)
- func GetTasks(w rest.ResponseWriter, r *rest.Request)
- func New(s *store.Store, adminPassword string, logStyle string) (*rest.Api, error)
- func PatchAccount(w rest.ResponseWriter, r *rest.Request)
- func PathAccountID(r *rest.Request) (bson.ObjectId, error)
- func PostAccount(w rest.ResponseWriter, r *rest.Request)
- func PostAttempt(w rest.ResponseWriter, r *rest.Request)
- func PutApplication(w rest.ResponseWriter, r *rest.Request)
- func PutQueue(w rest.ResponseWriter, r *rest.Request)
- func PutTask(w rest.ResponseWriter, r *rest.Request)
- func UnixToRFC3339(ts int64) string
- type Account
- type Application
- type Attempt
- type AuthBasicMiddleware
- type BaseMiddleware
- type Queue
- type Task
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidAccountID is returned when an invalid Account ID is found. ErrInvalidAccountID = errors.New("invalid account ID") )
var ( // ErrInvalidAttemptID is returned when an invalid Attempt ID is found. ErrInvalidAttemptID = errors.New("invalid attempt ID") )
Functions ¶
func Authenticate ¶
func Authenticate(w rest.ResponseWriter, r *rest.Request)
func DeleteAccount ¶
func DeleteAccount(w rest.ResponseWriter, r *rest.Request)
DeleteAccount handles DELETE request on /accounts/:account
func DeleteApplication ¶
func DeleteApplication(w rest.ResponseWriter, r *rest.Request)
DeleteApplication ...
func DeleteApplications ¶
func DeleteApplications(w rest.ResponseWriter, r *rest.Request)
DeleteApplications ...
func GetAccount ¶
func GetAccount(w rest.ResponseWriter, r *rest.Request)
GetAccount handles GET request on /accounts/:account
func GetApplication ¶
func GetApplication(w rest.ResponseWriter, r *rest.Request)
GetApplication ...
func GetApplications ¶
func GetApplications(w rest.ResponseWriter, r *rest.Request)
GetApplications ...
func PatchAccount ¶
func PatchAccount(w rest.ResponseWriter, r *rest.Request)
PatchAccount handles PATCH requests on /accounts
func PostAccount ¶
func PostAccount(w rest.ResponseWriter, r *rest.Request)
PostAccount handles POST requests on /accounts
func PutApplication ¶
func PutApplication(w rest.ResponseWriter, r *rest.Request)
PutApplication ...
func UnixToRFC3339 ¶
UnixToRFC3339 converts a Unix timestamp to a human readable format.
Types ¶
type Account ¶
type Account struct {
// ID is the ID of the Account.
ID string `json:"id"`
// Name is display name for the Account.
Name *string `json:"name"`
// Created is the date when the Account was created.
Created string `json:"created"`
// Key is the secret key to authenticate the Account ID.
Key string `json:"key"`
}
Account is an account to access the service.
func NewAccountFromModel ¶
NewAccountFromModel returns an API Account given a model Account.
type Application ¶
type Application struct {
// ID is the ID of the Application.
ID string `json:"id"`
// Created is the date when the Application was created.
Created string `json:"created"`
// Account is the ID of the Account owning the Application.
Account string `json:"account"`
// Name is the application's name.
Name string `json:"name"`
}
Application is a list of Tasks with a common application Name.
func NewApplicationFromModel ¶
func NewApplicationFromModel(application *models.Application) *Application
NewApplicationFromModel returns a Application object for use with the Rest API from a Application model.
type Attempt ¶
type Attempt struct {
// ID is the Attempt ID.
ID string `json:"id"`
// Created is the date when the Attempt was created.
Created string `json:"created"`
// Account is the ID of the Account owning the Task.
Account string `json:"account"`
// Application is the name of the parent Application.
Application string `json:"application"`
// Task is the task's name.
Task string `json:"name"`
// TaskID is the ID of the parent Task of this attempt.
TaskID string `json:"taskID"`
// Queue is the name of the parent Queue.
Queue string `json:"queue"`
// URL is the URL that the worker with requests.
URL string `json:"url"`
// HTTPAuth is the HTTP authentication to use if any.
HTTPAuth models.HTTPAuth `json:"auth"`
// Method is the HTTP method that will be used to execute the request.
Method string `json:"method"`
// Headers are the HTTP headers that will be used schedule executing the request.
Headers map[string]string `json:"headers,omitempty"`
// Payload is arbitrary data that will be POSTed on the URL.
Payload string `json:"payload,omitempty"`
// At is a date representing the time this attempt will be executed.
At string `json:"at,omitempty"`
// Finished is a Unix timestamp representing the time the attempt finished.
Finished string `json:"finished,omitempty"`
// Status is either `pending`, `retrying`, `canceled`, `success` or `error`
Status string `json:"status"`
// StatusCode is the HTTP status code.
StatusCode int32 `json:"statusCode,omitempty"`
// StatusMessage is a human readable message related to the StatusCode.
StatusMessage string `json:"statusMessage,omitempty"`
}
Attempt is used for the Rest API.
func NewAttemptFromModel ¶
NewAttemptFromModel returns a Task object for use with the Rest API from a Task model.
type AuthBasicMiddleware ¶
type AuthBasicMiddleware struct {
// Realm name to display to the user. Required.
Realm string
// Callback function that should perform the authentication of the user based on userId and
// password. Must return true on success, false on failure. Required.
Authenticator func(userId string, password string, request *rest.Request) bool
// Callback function that should perform the authorization of the authenticated user. Called
// only after an authentication success. Must return true on success, false on failure.
// Optional, default to success.
Authorizator func(userId string, request *rest.Request) bool
}
AuthBasicMiddleware provides a simple AuthBasic implementation. On failure, a 401 HTTP response is returned. On success, the wrapped middleware is called, and the userId is made available as request.Env["REMOTE_USER"].(string)
func (*AuthBasicMiddleware) MiddlewareFunc ¶
func (mw *AuthBasicMiddleware) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc
MiddlewareFunc makes AuthBasicMiddleware implement the Middleware interface.
type BaseMiddleware ¶
func (*BaseMiddleware) MiddlewareFunc ¶
func (mw *BaseMiddleware) MiddlewareFunc(next rest.HandlerFunc) rest.HandlerFunc
type Queue ¶
type Queue struct {
// ID is the ID of the Queue.
ID string `json:"id"`
// Created is the date when the Queue was created.
Created string `json:"created"`
// Account is the ID of the Account owning the Queue.
Account string `json:"account"`
// Application is the name of the parent Application.
Application string `json:"application"`
// Name is the queue's name.
Name string `json:"name"`
// Retry is the retry strategy parameters in case of errors.
Retry *models.Retry `json:"retry"`
// MaxInFlight is the maximum number of attempts executed in parallel.
MaxInFlight int `json:"maxInFlight"`
// InFlight is the current number of attempts executed in parallel.
InFlight int `json:"inFlight"`
}
Queue ...
func NewQueueFromModel ¶
NewQueueFromModel returns a Queue object for use with the Rest API from a Queue model.
type Task ¶
type Task struct {
// ID is the Task ID.
ID string `json:"id"`
// Created is the date when the Task was created.
Created string `json:"created"`
// Account is the ID of the Account owning the Task.
Account string `json:"account"`
// Application is the name of the parent Application.
Application string `json:"application"`
// Name is the task's name.
Name string `json:"name"`
// Queue is the name of the parent Queue.
Queue string `json:"queue"`
// URL is the URL that the worker with requests.
URL string `json:"url"`
// HTTPAuth is the HTTP authentication to use if any.
HTTPAuth models.HTTPAuth `json:"auth"`
// Method is the HTTP method that will be used to execute the request.
Method string `json:"method"`
// Headers are the HTTP headers that will be used schedule executing the request.
Headers map[string]string `json:"headers,omitempty"`
// Payload is arbitrary data that will be POSTed on the URL.
Payload string `json:"payload,omitempty"`
// Schedule is a cron specification describing the recurrency if any.
Schedule string `json:"schedule,omitempty"`
// At is a date representing the next time a attempt will be executed.
At string `json:"at,omitempty"`
// Status is either `pending`, `retrying`, `canceled`, `success` or `error`
Status string `json:"status"`
// Executed is the date of the last time a attempt was executed.
Executed string `json:"executed,omitempty"`
// Active is the task active.
Active *bool `json:"active"`
// Errors counts the number of attempts that failed.
Errors int `json:"errors"`
// LastError is the date of the last attempt in error status.
LastError string `json:"lastError,omitempty"`
// LastSuccess is the date of the last attempt in success status.
LastSuccess string `json:"lastSuccess,omitempty"`
// Executions counts the number of attempts that were executed.
Executions int `json:"executions"`
// ErrorRate is the rate of errors in percent.
ErrorRate int `json:"errorRate"`
// Retry is the retry strategy parameters in case of errors.
Retry *models.Retry `json:"retry"`
}
Task is used for the Rest API.
func NewTaskFromModel ¶
NewTaskFromModel returns a Task object for use with the Rest API from a Task model.