http

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTaskServiceRoutes

func AddTaskServiceRoutes(handler *httpd.Handler, log *zap.Logger, svc taskmodel.TaskService) error

func KapacitorUserFromContext

func KapacitorUserFromContext(ctx context.Context) *auth.User

func RemoveTaskServiceRoutes

func RemoveTaskServiceRoutes(handler *httpd.Handler) error

func WithKapacitorUser

func WithKapacitorUser(ctx context.Context, user auth.User) context.Context

Types

type Task

type Task struct {
	ID              platform.ID            `json:"id"`
	OwnerUsername   string                 `json:"ownerID"`
	UnusedOrgId     string                 `json:"orgID"`
	Name            string                 `json:"name"`
	Description     string                 `json:"description,omitempty"`
	Status          string                 `json:"status"`
	Flux            string                 `json:"flux"`
	Every           string                 `json:"every,omitempty"`
	Cron            string                 `json:"cron,omitempty"`
	Offset          string                 `json:"offset,omitempty"`
	LatestCompleted string                 `json:"latestCompleted,omitempty"`
	LastRunStatus   string                 `json:"lastRunStatus,omitempty"`
	LastRunError    string                 `json:"lastRunError,omitempty"`
	CreatedAt       string                 `json:"createdAt,omitempty"`
	UpdatedAt       string                 `json:"updatedAt,omitempty"`
	Metadata        map[string]interface{} `json:"metadata,omitempty"`
}

Task is a package-specific Task format that preserves the expected format for the API, where time values are represented as strings

func NewFrontEndTask

func NewFrontEndTask(t taskmodel.Task) Task

NewFrontEndTask converts a internal task type to a task that we want to display to users

type TaskHandler

type TaskHandler struct {
	TaskService taskmodel.TaskService
	errors2.HTTPErrorHandler
	// contains filtered or unexported fields
}

TaskHandler represents an HTTP API handler for tasks.

func (*TaskHandler) Handle

func (h *TaskHandler) Handle(w http.ResponseWriter, r *http.Request, user auth.User)

func (*TaskHandler) HandlerFunc

func (h *TaskHandler) HandlerFunc(method string, pattern string, handler func(w http.ResponseWriter, r *http.Request))

type TaskService

type TaskService struct {
	Client *httpc.Client
}

TaskService connects to Influx via HTTP using tokens to manage tasks.

func (TaskService) CancelRun

func (t TaskService) CancelRun(ctx context.Context, taskID, runID platform.ID) error

CancelRun stops a longer running run.

func (TaskService) CreateTask

func (t TaskService) CreateTask(ctx context.Context, tc taskmodel.TaskCreate) (*taskmodel.Task, error)

CreateTask creates a new task.

func (TaskService) DeleteTask

func (t TaskService) DeleteTask(ctx context.Context, id platform.ID) error

DeleteTask removes a task by ID and purges all associated data and scheduled runs.

func (TaskService) FindLogs

func (t TaskService) FindLogs(ctx context.Context, filter taskmodel.LogFilter) ([]*taskmodel.Log, int, error)

FindLogs returns logs for a run.

func (TaskService) FindRunByID

func (t TaskService) FindRunByID(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)

FindRunByID returns a single run of a specific task.

func (TaskService) FindRuns

func (t TaskService) FindRuns(ctx context.Context, filter taskmodel.RunFilter) ([]*taskmodel.Run, int, error)

FindRuns returns a list of runs that match a filter and the total count of returned runs.

func (TaskService) FindTaskByID

func (t TaskService) FindTaskByID(ctx context.Context, id platform.ID) (*taskmodel.Task, error)

FindTaskByID returns a single task

func (TaskService) FindTasks

func (t TaskService) FindTasks(ctx context.Context, filter taskmodel.TaskFilter) ([]*taskmodel.Task, int, error)

FindTasks returns a list of tasks that match a filter (limit 100) and the total count of matching tasks.

func (TaskService) ForceRun

func (t TaskService) ForceRun(ctx context.Context, taskID platform.ID, scheduledFor int64) (*taskmodel.Run, error)

ForceRun starts a run manually right now.

func (TaskService) RetryRun

func (t TaskService) RetryRun(ctx context.Context, taskID, runID platform.ID) (*taskmodel.Run, error)

RetryRun creates and returns a new run (which is a retry of another run).

func (TaskService) UpdateTask

func (t TaskService) UpdateTask(ctx context.Context, id platform.ID, upd taskmodel.TaskUpdate) (*taskmodel.Task, error)

UpdateTask updates a single task with changeset.

Jump to

Keyboard shortcuts

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