v1batch

package
v0.4.12 Latest Latest
Warning

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

Go to latest
Published: May 26, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//AuthHeader is the name of the HTTP Authorization header.
	AuthHeader = "Authorization"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainedJWTProvider

type ChainedJWTProvider struct {
	Providers []JWTProvider
	// contains filtered or unexported fields
}

ChainedJWTProvider provides a JWT based on multiple providers. The given providers are tried in sequential order.

func NewChainedJWTProvider

func NewChainedJWTProvider(providers ...JWTProvider) *ChainedJWTProvider

NewChainedJWTProvider creates a new chained jwt provider.

func (*ChainedJWTProvider) IsExpired

func (c *ChainedJWTProvider) IsExpired() bool

IsExpired will returned the expired state of the currently cached provider if there is one. If there is no current provider, true will be returned.

func (*ChainedJWTProvider) Retrieve

func (c *ChainedJWTProvider) Retrieve() (string, error)

Retrieve returns the jwt or error if no provider returned without error.

If a provider is found it will be cached and any calls to IsExpired() will return the expired state of the cached provider.

type Client

type Client struct {
	ClientConfig
	// contains filtered or unexported fields
}

Client is a client for the Nerdalize API.

func NewClient

func NewClient(conf ClientConfig) *Client

NewClient creates a new Nerd client from a config object. The http.DefaultClient will be used as default Doer.

func (*Client) CreateDataset

func (c *Client) CreateDataset(projectID, tag string) (output *v1payload.CreateDatasetOutput, err error)

CreateDataset creates a new dataset.

func (*Client) CreateQueue

func (c *Client) CreateQueue(projectID string) (output *v1payload.CreateQueueOutput, err error)

CreateQueue will create queue

func (*Client) CreateToken

func (c *Client) CreateToken(projectID string) (output *v1payload.CreateTokenOutput, err error)

CreateToken will create queue

func (*Client) DeleteQueue

func (c *Client) DeleteQueue(projectID, queueID string) (output *v1payload.DeleteQueueOutput, err error)

DeleteQueue will delete queue a queue with the provided id

func (*Client) DescribeDataset

func (c *Client) DescribeDataset(projectID, id string) (output *v1payload.DescribeDatasetOutput, err error)

DescribeDataset gets a dataset by ID.

func (*Client) DescribeQueue

func (c *Client) DescribeQueue(projectID, queueID string) (output *v1payload.DescribeQueueOutput, err error)

DescribeQueue returns detailed information of a queue

func (*Client) DescribeTask

func (c *Client) DescribeTask(projectID, queueID string, taskID int64) (output *v1payload.DescribeTaskOutput, err error)

DescribeTask will create an execute a new task

func (*Client) ExpelProject

func (c *Client) ExpelProject(projectID string) (output *v1payload.ExpelProjectOutput, err error)

ExpelProject will delete queue a queue with the provided id

func (*Client) ListDatasets

func (c *Client) ListDatasets(projectID, tag string) (output *v1payload.ListDatasetsOutput, err error)

ListDatasets gets a dataset by ID.

func (*Client) ListQueues

func (c *Client) ListQueues(projectID string) (output *v1payload.ListQueuesOutput, err error)

ListQueues will return all tasks in a queue

func (*Client) ListTasks

func (c *Client) ListTasks(projectID, queueID string) (output *v1payload.ListTasksOutput, err error)

ListTasks will return all tasks in a queue

func (*Client) ListWorkers

func (c *Client) ListWorkers(projectID string) (output *v1payload.ListWorkersOutput, err error)

ListWorkers will return all tasks in a worker

func (*Client) Ping

func (c *Client) Ping() error

Ping will error if there are connection issues

func (*Client) PlaceProject

func (c *Client) PlaceProject(projectID, host, token, capem, username, password string, insecure bool) (output *v1payload.PlaceProjectOutput, err error)

PlaceProject will create queue

func (*Client) ReceiveTaskRuns

func (c *Client) ReceiveTaskRuns(projectID, queueID string, timeout time.Duration, queueOps QueueOps) (output []*v1payload.Run, err error)

ReceiveTaskRuns will long poll the aws sqs queue for the availability of new runs. It will receive and delete messages once decoded

func (*Client) SendRunFailure

func (c *Client) SendRunFailure(projectID, queueID string, taskID int64, runToken, errCode, errMessage string) (output *v1payload.SendRunFailureOutput, err error)

SendRunFailure will send a failure for a run

func (*Client) SendRunHeartbeat

func (c *Client) SendRunHeartbeat(projectID, queueID string, taskID int64, runToken string) (output *v1payload.SendRunHeartbeatOutput, err error)

SendRunHeartbeat will send a heartbeat for a task run

func (*Client) SendRunSuccess

func (c *Client) SendRunSuccess(projectID, queueID string, taskID int64, runToken, result string) (output *v1payload.SendRunSuccessOutput, err error)

SendRunSuccess will send a successfully run for a task

func (*Client) SendUploadHeartbeat

func (c *Client) SendUploadHeartbeat(projectID, datasetID string) (output *v1payload.SendUploadHeartbeatOutput, err error)

SendUploadHeartbeat will send a heartbeat for a task run

func (*Client) SendUploadSuccess

func (c *Client) SendUploadSuccess(projectID, datasetID string) (output *v1payload.SendUploadSuccessOutput, err error)

SendUploadSuccess will send a successfully run for a task

func (*Client) StartTask

func (c *Client) StartTask(projectID, queueID string, cmd []string, env map[string]string, stdin []byte) (output *v1payload.StartTaskOutput, err error)

StartTask will create an execute a new task

func (*Client) StartWorker

func (c *Client) StartWorker(projectID, image, queueID string, env map[string]string, inputDatasetID string) (output *v1payload.StartWorkerOutput, err error)

StartWorker will create worker

func (*Client) StopTask

func (c *Client) StopTask(projectID, queueID string, taskID int64) (output *v1payload.StopTaskOutput, err error)

StopTask will create queue

func (*Client) StopWorker

func (c *Client) StopWorker(projectID, workerID string) (output *v1payload.StopWorkerOutput, err error)

StopWorker will delete worker a worker with the provided id

type ClientConfig

type ClientConfig struct {
	Doer        Doer
	JWTProvider JWTProvider
	Base        *url.URL
	Logger      client.Logger
}

ClientConfig provides config details to create a Nerd client.

type ClientDatasetInterface

type ClientDatasetInterface interface {
	CreateDataset(projectID, tag string) (output *v1payload.CreateDatasetOutput, err error)
	ListDatasets(projectID, tag string) (output *v1payload.ListDatasetsOutput, err error)
	DescribeDataset(projectID, id string) (output *v1payload.DescribeDatasetOutput, err error)
}

ClientDatasetInterface is an interface so client dataset calls can be mocked.

type ClientPingInterface

type ClientPingInterface interface {
	Ping() error
}

ClientPingInterface is an interface so client ping calls can be mocked.

type ClientPlacementInterface

type ClientPlacementInterface interface {
	PlaceProject(projectID, host, token, capem, username, password string, insecure bool) (output *v1payload.PlaceProjectOutput, err error)
	ExpelProject(projectID string) (output *v1payload.ExpelProjectOutput, err error)
}

ClientPlacementInterface is an interface for placement of project

type ClientQueueInterface

type ClientQueueInterface interface {
	CreateQueue(projectID string) (output *v1payload.CreateQueueOutput, err error)
	DeleteQueue(projectID, queueID string) (output *v1payload.DeleteQueueOutput, err error)
	DescribeQueue(projectID, queueID string) (output *v1payload.DescribeQueueOutput, err error)
	ListQueues(projectID string) (output *v1payload.ListQueuesOutput, err error)
}

ClientQueueInterface is an interface so client queue calls can be mocked.

type ClientRunInterface

type ClientRunInterface interface {
	SendRunHeartbeat(projectID, queueID string, taskID int64, runToken string) (output *v1payload.SendRunHeartbeatOutput, err error)
	SendRunSuccess(projectID, queueID string, taskID int64, runToken, result string) (output *v1payload.SendRunSuccessOutput, err error)
	SendRunFailure(projectID, queueID string, taskID int64, runToken, errCode, errMessage string) (output *v1payload.SendRunFailureOutput, err error)
}

ClientRunInterface is an interface so client task calls can be mocked.

type ClientTaskInterface

type ClientTaskInterface interface {
	StartTask(projectID, queueID string, cmd []string, env map[string]string, stdin []byte) (output *v1payload.StartTaskOutput, err error)
	StopTask(projectID, queueID string, taskID int64) (output *v1payload.StopTaskOutput, err error)
	ListTasks(projectID, queueID string) (output *v1payload.ListTasksOutput, err error)
	DescribeTask(projectID, queueID string, taskID int64) (output *v1payload.DescribeTaskOutput, err error)
	ReceiveTaskRuns(projectID, queueID string, timeout time.Duration, queueOps QueueOps) (output []*v1payload.Run, err error)
}

ClientTaskInterface is an interface so client task calls can be mocked.

type ClientTokenInterface

type ClientTokenInterface interface {
	CreateToken(projectID string) (output *v1payload.CreateTokenOutput, err error)
}

ClientTokenInterface is an interface so client token calls can be mocked.

type ClientUploadInterface

type ClientUploadInterface interface {
	SendUploadHeartbeat(projectID, datasetID string) (output *v1payload.SendUploadHeartbeatOutput, err error)
	SendUploadSuccess(projectID, datasetID string) (output *v1payload.SendUploadSuccessOutput, err error)
}

ClientUploadInterface is an interface so client task calls can be mocked.

type ClientWorkerInterface

type ClientWorkerInterface interface {
	StartWorker(projectID, image, queueID string, env map[string]string, inputDatasetID string) (output *v1payload.StartWorkerOutput, err error)
	StopWorker(projectID, workerID string) (output *v1payload.StopWorkerOutput, err error)
	ListWorkers(projectID string) (output *v1payload.ListWorkersOutput, err error)
}

ClientWorkerInterface is an interface for placement of project

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer executes http requests. It is implemented by *http.Client.

type HTTPError

type HTTPError struct {
	StatusCode int
	Err        *v1payload.Error
}

HTTPError is an error that is used when a server responded with a status code >= 400. Based on the actual status code a custom error message will be generated.

func (HTTPError) Cause

func (e HTTPError) Cause() error

Cause is implemented to be compatible with the pkg/errors package.

func (HTTPError) Error

func (e HTTPError) Error() string

Error returns the error message specific for the status code.

type JWTProvider

type JWTProvider interface {
	IsExpired() bool
	Retrieve() (string, error)
}

JWTProvider is capable of providing a JWT. When IsExpired return false the in-memory JWT will be used to prevent from calling Retrieve for each API call.

type QueueOps

type QueueOps interface {
	ReceiveMessages(queueURL string, maxNoOfMessages, waitTimeSeconds int64) (messages []interface{}, err error)
	UnmarshalMessage(message interface{}, v interface{}) error
	DeleteMessage(queueURL string, message interface{}) error
}

QueueOps is an interface that includes queue operations.

type StaticJWTProvider

type StaticJWTProvider struct {
	JWT string
}

StaticJWTProvider is a simple JWT provider that always returns the same JWT.

func NewStaticJWTProvider

func NewStaticJWTProvider(jwt string) *StaticJWTProvider

NewStaticJWTProvider creates a new StaticJWTProvider for the given jwt.

func (*StaticJWTProvider) IsExpired

func (s *StaticJWTProvider) IsExpired() bool

IsExpired always returns false.

func (*StaticJWTProvider) Retrieve

func (s *StaticJWTProvider) Retrieve() (string, error)

Retrieve always returns the given jwt.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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