amboy: Index | Files

package rest

import ""


Package Files

client_abortable_pool.go client_queue.go client_reporting.go service_abortable_pool.go service_queue.go service_queue_create.go service_queue_fetch.go service_queue_job.go service_queue_stats.go service_reporting.go

type ManagementClient Uses

type ManagementClient struct {
    // contains filtered or unexported fields

ManagementClient provides a go wrapper to the management service.

func NewManagementClient Uses

func NewManagementClient(url string) *ManagementClient

NewManagementClient constructs a new ManagementClient instance that constructs a new http.Client.

func NewManagementClientFromExisting Uses

func NewManagementClientFromExisting(client *http.Client, url string) *ManagementClient

NewManagementClientFromExisting builds a ManagementClient instance from an existing http.Client.

func (*ManagementClient) AbortAllJobs Uses

func (c *ManagementClient) AbortAllJobs(ctx context.Context) error

AbortAllJobs issues the request to terminate all currently running jobs managed by the pool that backs the request.

func (*ManagementClient) AbortJob Uses

func (c *ManagementClient) AbortJob(ctx context.Context, job string) error

AbortJob sends the abort signal for a running job to the management service, return any errors from the service. A nil response indicates that the job has been successfully terminated.

func (*ManagementClient) IsRunning Uses

func (c *ManagementClient) IsRunning(ctx context.Context, job string) (bool, error)

IsRunning checks if a job with a specified id is currently running in the remote queue. Check the error value to identify if false response is due to a communication problem with the service or is legitimate.

func (*ManagementClient) ListJobs Uses

func (c *ManagementClient) ListJobs(ctx context.Context) ([]string, error)

ListJobs returns a full list of all running jobs managed by the pool that the service reflects.

type ManagementService Uses

type ManagementService struct {
    // contains filtered or unexported fields

ManagementService defines a set of rest routes that make it possible to remotely manage the jobs running in an abortable pool.

func NewManagementService Uses

func NewManagementService(p amboy.AbortableRunner) *ManagementService

NewManagementService returns a service that defines REST routes can manage an abortable pool.

func (*ManagementService) AbortAllJobs Uses

func (s *ManagementService) AbortAllJobs(rw http.ResponseWriter, r *http.Request)

AbortAllJobs is an http.HandlerFunc that sends the signal to abort all running jobs in the pool. May return a 408 (timeout) if the calling context was canceled before the operation returned. Otherwise, this handler returns 200. The body of the response is always empty.

func (*ManagementService) AbortRunningJob Uses

func (s *ManagementService) AbortRunningJob(rw http.ResponseWriter, r *http.Request)

AbortRunningJob is an http.HandlerFunc that terminates the execution of a single running job, returning a 400 response when the job doesn't exist.

func (*ManagementService) App Uses

func (s *ManagementService) App() *gimlet.APIApp

App returns a gimlet app with all of the routes registered.

func (*ManagementService) GetJobStatus Uses

func (s *ManagementService) GetJobStatus(rw http.ResponseWriter, r *http.Request)

GetJobStatus is an http.HandlerFunc reports on the status (running or not running) of a specific job.

func (*ManagementService) ListJobs Uses

func (s *ManagementService) ListJobs(rw http.ResponseWriter, r *http.Request)

ListJobs is an http.HandlerFunc that returns a list of all running jobs in the pool.

type QueueClient Uses

type QueueClient struct {
    // contains filtered or unexported fields

QueueClient provides an interface for interacting with a remote amboy Service.

func NewQueueClient Uses

func NewQueueClient(host string, port int, prefix string) (*QueueClient, error)

NewQueueClient takes host, port, and URI prefix information and constructs a new QueueClient.

func NewQueueClientFromExisting Uses

func NewQueueClientFromExisting(client *http.Client, host string, port int, prefix string) (*QueueClient, error)

NewQueueClientFromExisting takes an existing http.Client object and produces a new QueueClient object.

func (*QueueClient) FetchJob Uses

func (c *QueueClient) FetchJob(ctx context.Context, name string) (amboy.Job, error)

FetchJob takes the name of a queue, and returns if possible a representation of that job object.

func (*QueueClient) Host Uses

func (c *QueueClient) Host() string

Host returns the current host.

func (*QueueClient) JobComplete Uses

func (c *QueueClient) JobComplete(ctx context.Context, name string) (bool, error)

JobComplete checks the stats of a job, by name, and returns true if that job is complete. When false, check the second return value to ensure that the job exists in the remote queue.

func (*QueueClient) PendingJobs Uses

func (c *QueueClient) PendingJobs(ctx context.Context) (int, error)

PendingJobs reports on the total number of jobs currently dispatched by the queue to workers.

func (*QueueClient) Port Uses

func (c *QueueClient) Port() int

Port returns the current port value for the QueueClient.

func (*QueueClient) Prefix Uses

func (c *QueueClient) Prefix() string

Prefix accesses the prefix for the client, The prefix is the part of the URI between the end-point and the hostname, of the API.

func (*QueueClient) Running Uses

func (c *QueueClient) Running(ctx context.Context) (bool, error)

Running is true when the underlying queue is running and accepting jobs, and false when the queue is not runner or if there's a problem connecting to the queue.

func (*QueueClient) SetHost Uses

func (c *QueueClient) SetHost(h string) error

SetHost allows callers to change the hostname (including leading "http(s)") for the Client. Returns an error if the specified host does not start with "http".

func (*QueueClient) SetPort Uses

func (c *QueueClient) SetPort(p int) error

SetPort allows callers to change the port used for the client. If the port is invalid, returns an error and sets the port to the default value. (3000)

func (*QueueClient) SetPrefix Uses

func (c *QueueClient) SetPrefix(p string) error

SetPrefix allows callers to modify the prefix, for this client,

func (*QueueClient) SubmitJob Uses

func (c *QueueClient) SubmitJob(ctx context.Context, j amboy.Job) (string, error)

SubmitJob adds a job to a remote queue connected to the rest interface.

func (*QueueClient) Wait Uses

func (c *QueueClient) Wait(ctx context.Context, name string) bool

Wait blocks until the job identified by the name argument is complete. Does not handle the case where a job does not exist.

func (*QueueClient) WaitAll Uses

func (c *QueueClient) WaitAll(ctx context.Context) bool

WaitAll waits for *all* pending jobs in the queue to complete.

type QueueService Uses

type QueueService struct {
    // contains filtered or unexported fields

QueueService is used as a place holder for application state and configuration.

func NewQueueService Uses

func NewQueueService() *QueueService

NewQueueService constructs a new service object. Use the Open() method to initialize the service. The Open and OpenWithOptions methods configure an embedded amboy service. If you use SetQueue you do not need to call an open method.

Use the App() method to get a gimlet Application that you can use to run the service.

func (*QueueService) App Uses

func (s *QueueService) App() *gimlet.APIApp

App provides access to the gimplet.APIApp instance which builds and orchestrates the REST API. Use this method if you want to combine the routes in this QueueService with another service, or add additional routes to support other application functionality.

func (*QueueService) Close Uses

func (s *QueueService) Close()

Close releases resources (i.e. the queue) associated with the service. If you've used SetQueue to define the embedded queue, rather than Open/OpenWithOptions,

func (*QueueService) Create Uses

func (s *QueueService) Create(w http.ResponseWriter, r *http.Request)

Create provides an interface for REST clients to create jobs in the local queue that backs the service.

func (*QueueService) Fetch Uses

func (s *QueueService) Fetch(w http.ResponseWriter, r *http.Request)

Fetch is an http handler that writes a job interchange object to a the response, and allows clients to retrieve jobs from the service.

func (*QueueService) JobStatus Uses

func (s *QueueService) JobStatus(w http.ResponseWriter, r *http.Request)

JobStatus is a http.HandlerFunc that writes a job status document to the request.

func (*QueueService) Open Uses

func (s *QueueService) Open(ctx context.Context) error

Open populates the application and starts the underlying queue. This method sets and initializes a LocalLimitedSize queue implementation, with 2 workers and storage for 256 jobs. Use OpenInfo to have more control over the embedded queue. Use the Close() method on the service to terminate the queue.

func (*QueueService) OpenWithOptions Uses

func (s *QueueService) OpenWithOptions(ctx context.Context, opts QueueServiceOptions) error

OpenWithOptions makes it possible to configure the underlying queue in a service. Use the Close() method on the service to terminate the queue.

func (*QueueService) Queue Uses

func (s *QueueService) Queue() amboy.Queue

Queue provides access to the underlying queue object for the service.

func (*QueueService) SetQueue Uses

func (s *QueueService) SetQueue(q amboy.Queue) error

SetQueue allows callers to inject an alternate queue implementation.

func (*QueueService) Status Uses

func (s *QueueService) Status(w http.ResponseWriter, r *http.Request)

Status defines an http.HandlerFunc that returns health check and current staus status information for the entire service.

func (*QueueService) WaitAll Uses

func (s *QueueService) WaitAll(w http.ResponseWriter, r *http.Request)

WaitAll blocks waiting for all pending jobs in the queue to stop. Has a default timeout of 10 seconds, and returns 408 (request timeout) when the timeout succeeds.

func (*QueueService) WaitJob Uses

func (s *QueueService) WaitJob(w http.ResponseWriter, r *http.Request)

WaitJob waits for a single job to be complete. It takes a timeout argument, which defaults to 10 seconds, and returns 408 (request timeout) if the timeout is reached before the job completes.

type QueueServiceOptions Uses

type QueueServiceOptions struct {
    // ForceTimeout makes it possible to control how long to wait
    // for pending jobs to complete before canceling existing
    // work. If this value is zeroed, the Open operation will
    // close the previous queue and start a new queue, otherwise
    // it will attempt to wait for the specified time before closing
    // the previous queue.
    ForceTimeout time.Duration `bson:"force_timeout,omitempty" json:"force_timeout,omitempty" yaml:"force_timeout,omitempty"`

    // The default queue constructed by Open/OpenWith retains a
    // limited number of completed jobs to avoid unbounded memory
    // growth. This value *must* be specified.
    QueueSize int `bson:"queue_size" json:"queue_size" yaml:"queue_size"`

    // Controls the maximum number of go routines that can service
    // jobs in a queue.
    NumWorkers int `bson:"num_workers" json:"num_workers" yaml:"num_workers"`

QueueServiceOptions provides a way to configure resources allocated by a service.

type ReportingClient Uses

type ReportingClient struct {
    // contains filtered or unexported fields

ReportingClient provides a wrapper for communicating with an amboy rest service for queue reporting. It implements the reporting.Reporter interface and allows you to remotely interact with running jobs on a system.

func NewReportingClient Uses

func NewReportingClient(url string) *ReportingClient

NewReportingClient constructs a ReportingClient instance constructing a new HTTP client.

func NewReportingClientFromExisting Uses

func NewReportingClientFromExisting(client *http.Client, url string) *ReportingClient

NewReportingClientFromExisting constructs a new ReportingClient instance from an existing HTTP Client.

func (*ReportingClient) JobIDsByState Uses

func (c *ReportingClient) JobIDsByState(ctx context.Context, jobType string, filter reporting.CounterFilter) (*reporting.JobReportIDs, error)

JobIDsByState returns a list of job IDs for each job type, for all jobs matching the filter. Filuter value are defined as constants in the reporting package.

func (*ReportingClient) JobStatus Uses

func (c *ReportingClient) JobStatus(ctx context.Context, filter reporting.CounterFilter) (*reporting.JobStatusReport, error)

JobStatus a count, by job type, for all jobs that match the Counter filter. CounterFilter values are defined as constants in the reporting package.

func (*ReportingClient) RecentErrors Uses

func (c *ReportingClient) RecentErrors(ctx context.Context, dur time.Duration, filter reporting.ErrorFilter) (*reporting.JobErrorsReport, error)

RecentErrors returns an error report for jobs that have completed in the given window that have had errors. Use the filter to de-duplicate errors. ErrorFilter values are defined as constants in the reporting package.

func (*ReportingClient) RecentJobErrors Uses

func (c *ReportingClient) RecentJobErrors(ctx context.Context, jobType string, dur time.Duration, filter reporting.ErrorFilter) (*reporting.JobErrorsReport, error)

RecentJobErrors returns an error report for jobs of a specific type that have encountered errors that have completed within the specified window. The ErrorFilter values are defined as constants in the reporting package.

func (*ReportingClient) RecentTiming Uses

func (c *ReportingClient) RecentTiming(ctx context.Context, dur time.Duration, filter reporting.RuntimeFilter) (*reporting.JobRuntimeReport, error)

RecentTiming returns timing data latency or duration of job run time for jobs in the window defined by the duration value. You must specify a timing filter (e.g. Latency or Duration) with a constant defined in the reporting package.

type ReportingService Uses

type ReportingService struct {
    // contains filtered or unexported fields

ReportingService wraps a reporter instance as described in the reporting package and provides an HTTP interface for all of the methods provided by the reporter.

func NewReportingService Uses

func NewReportingService(r reporting.Reporter) *ReportingService

NewReportingService constructs a reporting service from the reporter provided.

func (*ReportingService) App Uses

func (s *ReportingService) App() *gimlet.APIApp

App returns a gimlet application with all of the routes configured.

func (*ReportingService) GetJobStatus Uses

func (s *ReportingService) GetJobStatus(rw http.ResponseWriter, r *http.Request)

GetJobStatus is an http.HandlerFunc that provides access to counts of all jobs that match a defined filter.

func (*ReportingService) GetJobStatusByType Uses

func (s *ReportingService) GetJobStatusByType(rw http.ResponseWriter, r *http.Request)

GetJobStatusByType is an http.HandlerFunc that produces a list of job IDs for jobs that match a defined filter.

func (*ReportingService) GetRecentErrors Uses

func (s *ReportingService) GetRecentErrors(rw http.ResponseWriter, r *http.Request)

GetRecentErrors is an http.HandlerFunc that returns an error report including number of errors, total number of jobs, grouped by type, with the error messages. Uses a filter that can optionally remove duplicate errors.

func (*ReportingService) GetRecentErrorsByType Uses

func (s *ReportingService) GetRecentErrorsByType(rw http.ResponseWriter, r *http.Request)

GetRecentErrorsByType is an http.Handlerfunc returns an errors report for only a single type of jobs.

func (*ReportingService) GetRecentTimings Uses

func (s *ReportingService) GetRecentTimings(rw http.ResponseWriter, r *http.Request)

GetRecentTimings is an http.HandlerFunc that produces a report that lists the average runtime (duration) or latency of jobs.

Package rest imports 15 packages (graph) and is imported by 9 packages. Updated 2019-05-24. Refresh now. Tools for package owners.