Documentation ¶
Index ¶
- Constants
- type ChainedJWTProvider
- type Client
- func (c *Client) CreateDataset(projectID string) (output *v1payload.CreateDatasetOutput, err error)
- func (c *Client) CreateToken(projectID string) (output *v1payload.CreateTokenOutput, err error)
- func (c *Client) CreateWorkload(projectID, image, inputDatasetID string, env map[string]string, instances int, ...) (output *v1payload.CreateWorkloadOutput, err error)
- func (c *Client) DescribeDataset(projectID, id string) (output *v1payload.DescribeDatasetOutput, err error)
- func (c *Client) DescribeTask(projectID, workloadID string, taskID int64) (output *v1payload.DescribeTaskOutput, err error)
- func (c *Client) DescribeWorkload(projectID, workloadID string) (output *v1payload.DescribeWorkloadOutput, err error)
- func (c *Client) ExpelProject(projectID string) (output *v1payload.ExpelProjectOutput, err error)
- func (c *Client) ListDatasets(projectID string) (output *v1payload.ListDatasetsOutput, err error)
- func (c *Client) ListTasks(projectID, workloadID string, onlySuccessTasks bool) (output *v1payload.ListTasksOutput, err error)
- func (c *Client) ListWorkloads(projectID string) (output *v1payload.ListWorkloadsOutput, err error)
- func (c *Client) Ping() error
- func (c *Client) PlaceProject(projectID, host, token, capem, username, password string, insecure bool) (output *v1payload.PlaceProjectOutput, err error)
- func (c *Client) ReceiveTaskRuns(projectID, workloadID string, timeout time.Duration, queueOps QueueOps) (output []*v1payload.Run, err error)
- func (c *Client) SendRunFailure(projectID, workloadID string, taskID int64, ...) (output *v1payload.SendRunFailureOutput, err error)
- func (c *Client) SendRunHeartbeat(projectID, workloadID string, taskID int64, runToken string) (output *v1payload.SendRunHeartbeatOutput, err error)
- func (c *Client) SendRunSuccess(projectID, workloadID string, taskID int64, ...) (output *v1payload.SendRunSuccessOutput, err error)
- func (c *Client) SendUploadHeartbeat(projectID, datasetID string) (output *v1payload.SendUploadHeartbeatOutput, err error)
- func (c *Client) SendUploadSuccess(projectID, datasetID string) (output *v1payload.SendUploadSuccessOutput, err error)
- func (c *Client) StartTask(projectID, workloadID string, cmd []string, env map[string]string, ...) (output *v1payload.StartTaskOutput, err error)
- func (c *Client) StopTask(projectID, workloadID string, taskID int64) (output *v1payload.StopTaskOutput, err error)
- func (c *Client) StopWorkload(projectID, workloadID string) (output *v1payload.StopWorkloadOutput, err error)
- type ClientConfig
- type ClientDatasetInterface
- type ClientInterface
- type ClientPingInterface
- type ClientPlacementInterface
- type ClientRunInterface
- type ClientTaskInterface
- type ClientTokenInterface
- type ClientUploadInterface
- type ClientWorkloadInterface
- type Doer
- type HTTPError
- type JWTProvider
- type QueueOps
- type StaticJWTProvider
Constants ¶
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) 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 string, env map[string]string, instances int, useCuteur bool) (output *v1payload.CreateWorkloadOutput, err error)
CreateWorkload will start a workload
func (*Client) DescribeDataset ¶
func (c *Client) DescribeDataset(projectID, id string) (output *v1payload.DescribeDatasetOutput, err error)
DescribeDataset gets a dataset by ID.
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) 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) 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, 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) 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
type ClientConfig ¶
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 ClientInterface ¶
type ClientInterface interface { ClientDatasetInterface ClientPingInterface ClientWorkloadInterface ClientTaskInterface ClientRunInterface ClientTokenInterface ClientUploadInterface ClientPlacementInterface }
ClientInterface is an interface so client 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 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 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 ClientWorkloadInterface ¶ added in v0.4.15
type ClientWorkloadInterface interface { CreateWorkload(projectID, image, inputDatasetID string, 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 HTTPError ¶
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.
type JWTProvider ¶
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.