v1batch

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 string) (output *v1payload.CreateDatasetOutput, err error)

CreateDataset creates a new dataset.

func (*Client) CreatePlan added in v0.5.9

func (c *Client) CreatePlan(projectID, PlanID, computeUnits string) (output *v1payload.CreatePlanOutput, err error)

CreatePlan will create a plan for the precised project.

func (*Client) CreatePullSecret added in v0.5.6

func (c *Client) CreatePullSecret(projectID, name, dockerUsername, dockerPassword string) (output *v1payload.CreateSecretOutput, err error)

CreatePullSecret will create a pull secret

func (*Client) CreateSecret added in v0.5.6

func (c *Client) CreateSecret(projectID, name, key, value string) (output *v1payload.CreateSecretOutput, err error)

CreateSecret will create secret

func (*Client) CreateToken

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

CreateToken will create a token

func (*Client) CreateWorkload added in v0.4.15

func (c *Client) CreateWorkload(projectID, image, inputDatasetID, pullSecret string, computeUnits uint64, env map[string]string, nrOfWorkers int, useCuteur bool) (output *v1payload.CreateWorkloadOutput, err error)

CreateWorkload will start a workload

func (*Client) DeletePlan added in v0.5.9

func (c *Client) DeletePlan(PlanID string) (output *v1payload.DeletePlanOutput, err error)

DeletePlan will delete a plan with the provided .

func (*Client) DeleteSecret added in v0.5.6

func (c *Client) DeleteSecret(projectID, name string) (output *v1payload.DeleteSecretOutput, err error)

DeleteSecret will delete a secret with the provided name

func (*Client) DescribeDataset

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

DescribeDataset gets a dataset by ID.

func (*Client) DescribeSecret added in v0.5.6

func (c *Client) DescribeSecret(projectID, name string) (output *v1payload.DescribeSecretOutput, err error)

DescribeSecret returns detailed information of a secret

func (*Client) DescribeTask

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

DescribeTask will create an execute a new task

func (*Client) DescribeWorkload added in v0.4.15

func (c *Client) DescribeWorkload(projectID, workloadID string) (output *v1payload.DescribeWorkloadOutput, err error)

DescribeWorkload returns detailed information of a workload

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 string) (output *v1payload.ListDatasetsOutput, err error)

ListDatasets gets a dataset by ID.

func (*Client) ListPlans added in v0.5.9

func (c *Client) ListPlans(projectID string) (output *v1payload.ListPlansOutput, err error)

ListPlans will return all Plans for a particular project if precised.

func (*Client) ListSecrets added in v0.5.6

func (c *Client) ListSecrets(projectID string) (output *v1payload.ListSecretsOutput, err error)

ListSecrets will return all secrets for a particular project

func (*Client) ListTasks

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

ListTasks will return all tasks in a queue

func (*Client) ListWorkloads added in v0.4.15

func (c *Client) ListWorkloads(projectID string) (output *v1payload.ListWorkloadsOutput, err error)

ListWorkloads will return all workloads

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, computeUnits string, insecure bool) (output *v1payload.PlaceProjectOutput, err error)

PlaceProject will create queue

func (*Client) ReceiveTaskRuns

func (c *Client) ReceiveTaskRuns(projectID, workloadID 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) RemovePlan added in v0.5.9

func (c *Client) RemovePlan(projectID, PlanID string) (output *v1payload.RemovePlanOutput, err error)

RemovePlan will delete a plan from the precised project.

func (*Client) SendRunFailure

func (c *Client) SendRunFailure(projectID, workloadID 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, workloadID 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, workloadID string, taskID int64, runToken, result, outputDatasetID 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, workloadID string, cmd []string, env map[string]string, stdin []byte) (output *v1payload.StartTaskOutput, err error)

StartTask will create an execute a new task

func (*Client) StopTask

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

StopTask will create queue

func (*Client) StopWorkload added in v0.4.15

func (c *Client) StopWorkload(projectID, workloadID string) (output *v1payload.StopWorkloadOutput, err error)

StopWorkload will stop a workload

func (*Client) UpdatePlan added in v0.5.9

func (c *Client) UpdatePlan(projectID, PlanID, computeUnits string) (output *v1payload.UpdatePlanOutput, err error)

UpdatePlan returns a plan with an updated cpu request.

func (*Client) WorkerLogs added in v0.5.1

func (c *Client) WorkerLogs(projectID, workloadID, workerID string) (output *v1payload.WorkerLogsOutput, err error)

WorkerLogs will return all workloads

type ClientConfig

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

ClientConfig provides config details to create a Nerd client.

type ClientDatasetInterface

type ClientDatasetInterface interface {
	CreateDataset(projectID string) (output *v1payload.CreateDatasetOutput, err error)
	ListDatasets(projectID 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, computeUnits 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 ClientPlanInterface added in v0.5.9

type ClientPlanInterface interface {
	CreatePlan(projectID, PlanID, computeUnits string) (output *v1payload.CreatePlanOutput, err error)
	RemovePlan(projectID, PlanID string) (output *v1payload.RemovePlanOutput, err error)
	DeletePlan(PlanID string) (output *v1payload.DeletePlanOutput, err error)
	ListPlans(projectID string) (output *v1payload.ListPlansOutput, err error)
	UpdatePlan(projectID, PlanID, computeUnits string) (output *v1payload.UpdatePlanOutput, err error)
}

ClientPlanInterface is an interface so client plan calls can be mocked.

type ClientRunInterface

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

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

type ClientSecretInterface added in v0.5.6

type ClientSecretInterface interface {
	CreateSecret(projectID, name, key, value string) (output *v1payload.CreateSecretOutput, err error)
	DeleteSecret(projectID, name string) (output *v1payload.DeleteSecretOutput, err error)
	DescribeSecret(projectID, name string) (output *v1payload.DescribeSecretOutput, err error)
	ListSecrets(projectID string) (output *v1payload.ListSecretsOutput, err error)
}

ClientSecretInterface is an interface so client secret calls can be mocked.

type ClientTaskInterface

type ClientTaskInterface interface {
	StartTask(projectID, workloadID string, cmd []string, env map[string]string, stdin []byte) (output *v1payload.StartTaskOutput, err error)
	StopTask(projectID, workloadID string, taskID int64) (output *v1payload.StopTaskOutput, err error)
	ListTasks(projectID, workloadID string, onlySuccessTasks bool) (output *v1payload.ListTasksOutput, err error)
	DescribeTask(projectID, workloadID string, taskID int64) (output *v1payload.DescribeTaskOutput, err error)
	ReceiveTaskRuns(projectID, workloadID 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 {
	WorkerLogs(projectID, workloadID, workerID string) (output *v1payload.WorkerLogsOutput, err error)
}

ClientWorkerInterface is an interface so client workload calls can be mocked.

type ClientWorkloadInterface added in v0.4.15

type ClientWorkloadInterface interface {
	CreateWorkload(projectID, image, inputDatasetID, pullSecret string, computeUnits uint64, env map[string]string, instances int, useCuteur bool) (output *v1payload.CreateWorkloadOutput, err error)
	StopWorkload(projectID, workloadID string) (output *v1payload.StopWorkloadOutput, err error)
	ListWorkloads(projectID string) (output *v1payload.ListWorkloadsOutput, err error)
	DescribeWorkload(projectID, workloadID string) (output *v1payload.DescribeWorkloadOutput, err error)
}

ClientWorkloadInterface is an interface so client workload calls can be mocked.

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