Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/runware_serverless_apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ runware serverless apps [flags]
* [runware serverless apps delete](runware_serverless_apps_delete.md) - Delete a serverless application
* [runware serverless apps endpoints](runware_serverless_apps_endpoints.md) - List endpoints for a serverless application
* [runware serverless apps env](runware_serverless_apps_env.md) - Manage plain-text environment variables for an application
* [runware serverless apps invoke](runware_serverless_apps_invoke.md) - Invoke an application endpoint
* [runware serverless apps list](runware_serverless_apps_list.md) - List serverless applications
* [runware serverless apps logs](runware_serverless_apps_logs.md) - Show logs for a serverless application
* [runware serverless apps resume](runware_serverless_apps_resume.md) - Resume a stopped serverless application
* [runware serverless apps scale](runware_serverless_apps_scale.md) - Scale a serverless application
* [runware serverless apps show](runware_serverless_apps_show.md) - Show details for a serverless application
* [runware serverless apps stop](runware_serverless_apps_stop.md) - Stop a serverless application
* [runware serverless apps tasks](runware_serverless_apps_tasks.md) - List and inspect application tasks
* [runware serverless apps usage](runware_serverless_apps_usage.md) - Show usage for a serverless application
* [runware serverless apps versions](runware_serverless_apps_versions.md) - Inspect application versions
* [runware serverless apps workers](runware_serverless_apps_workers.md) - List workers for a serverless application
Expand Down
59 changes: 59 additions & 0 deletions docs/runware_serverless_apps_invoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## runware serverless apps invoke

Invoke an application endpoint

### Synopsis

Submit a JSON payload to a named application endpoint.

endpointPath is a bare lowercase segment as returned by apps endpoints
(e.g. infer). A leading slash is rejected.

The default is async: the command prints the accepted task id. Pass --wait
to poll until the task is completed or failed.

--sync uses the sync invocation endpoint. If the platform wait window
expires, the command polls the returned task id; it never treats expiry as
a failure and never resubmits.

```
runware serverless apps invoke <appId> <endpointPath> [flags]
```

### Examples

```
# list endpoint paths, then invoke asynchronously
runware serverless apps endpoints my-app
runware serverless apps invoke my-app infer -f payload.json

# wait for a completed task (sync, then poll if the wait window expires)
runware serverless apps invoke my-app infer --sync -f payload.json

# async invoke and poll
runware serverless apps invoke my-app infer --wait -f payload.json
```

### Options

```
-f, --body string JSON payload file, or - for stdin (default {})
-h, --help help for invoke
--poll-interval duration Polling interval when waiting for a task (default 2s)
--sync Use sync invocation and wait for a terminal task
--wait Poll until the task is completed or failed
```

### Options inherited from parent commands

```
--debug Show full debug output
-F, --format string CLI output format: table, json, yaml (default "table")
--transport string Transport protocol: ws (WebSocket) or http (REST) (default "ws")
-v, --verbose Show request/response details
```

### SEE ALSO

* [runware serverless apps](runware_serverless_apps.md) - Manage deployed serverless applications

51 changes: 51 additions & 0 deletions docs/runware_serverless_apps_tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## runware serverless apps tasks

List and inspect application tasks

### Synopsis

List TTL-bounded task metadata for an application.

This is a recovery window, not persisted history. Pending includes queued,
running, and retrying work. A page can be empty and still have nextCursor.

```
runware serverless apps tasks <appId> [flags]
```

### Examples

```
# list recent tasks
runware serverless apps tasks my-app --limit 10

# filter by status
runware serverless apps tasks my-app --status pending

# page through results
runware serverless apps tasks my-app --limit 10 --cursor <nextCursor>
```

### Options

```
--cursor string Pagination cursor from a previous nextCursor
-h, --help help for tasks
--limit int Maximum number of tasks to return (1-100)
--status string Filter by status (pending, completed, or failed)
```

### Options inherited from parent commands

```
--debug Show full debug output
-F, --format string CLI output format: table, json, yaml (default "table")
--transport string Transport protocol: ws (WebSocket) or http (REST) (default "ws")
-v, --verbose Show request/response details
```

### SEE ALSO

* [runware serverless apps](runware_serverless_apps.md) - Manage deployed serverless applications
* [runware serverless apps tasks show](runware_serverless_apps_tasks_show.md) - Show a single application task

34 changes: 34 additions & 0 deletions docs/runware_serverless_apps_tasks_show.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
## runware serverless apps tasks show

Show a single application task

```
runware serverless apps tasks show <appId> <taskId> [flags]
```

### Examples

```
# show a task
runware serverless apps tasks show my-app 7c9e6679-7425-40de-944b-e07fc1f90ae7
```

### Options

```
-h, --help help for show
```

### Options inherited from parent commands

```
--debug Show full debug output
-F, --format string CLI output format: table, json, yaml (default "table")
--transport string Transport protocol: ws (WebSocket) or http (REST) (default "ws")
-v, --verbose Show request/response details
```

### SEE ALSO

* [runware serverless apps tasks](runware_serverless_apps_tasks.md) - List and inspect application tasks

37 changes: 32 additions & 5 deletions internal/api/serverless/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ const defaultTimeout = 30 * time.Second
// exceed the default request timeout on slow links or larger codebases.
const createAppTimeout = 5 * time.Minute

// invokeSyncTimeout bounds startSyncTask. It must exceed the platform wait
// window so a 504/202 with taskId is received; a client-side timeout would
// lose the id and force a resubmit (a second billable run).
const invokeSyncTimeout = 5 * time.Minute

// GpuType is the public catalogue entry for a supported GPU type.
type GpuType = gen.GpuType

Expand Down Expand Up @@ -82,6 +87,24 @@ type BuildStatus = gen.BuildStatus
// ListWorkersParams are optional filters for ListWorkers.
type ListWorkersParams = gen.ListWorkersParams

// Task is a serverless invocation.
type Task = gen.Task

// TaskStatus is a task lifecycle status.
type TaskStatus = gen.TaskStatus

// TaskPayload is the JSON object forwarded to an endpoint handler.
type TaskPayload = gen.TaskPayload

// ListTasksParams are optional filters for ListTasks.
type ListTasksParams = gen.ListTasksParams

const (
TaskStatusPending TaskStatus = gen.TaskStatusPending
TaskStatusCompleted TaskStatus = gen.TaskStatusCompleted
TaskStatusFailed TaskStatus = gen.TaskStatusFailed
)

// Endpoint is an app HTTP endpoint.
type Endpoint = gen.Endpoint

Expand Down Expand Up @@ -178,19 +201,23 @@ func newGeneratedClient(apiKey, baseURL string, httpClient gen.HttpRequestDoer)
}

// createInner returns a generated client suitable for createApp.
// When the underlying doer is an *http.Client with a positive Timeout shorter
// than createAppTimeout, a clone with the longer timeout is used so
// large uploads are not cut off. A zero Timeout (no deadline) is left unchanged.
func (c *Client) createInner() *gen.ClientWithResponses {
return c.innerWithMinTimeout(createAppTimeout)
}

// innerWithMinTimeout returns the generated client, cloning the HTTP client
// when its Timeout is shorter than minTimeout. A zero Timeout (no deadline) is left
// unchanged.
func (c *Client) innerWithMinTimeout(minTimeout time.Duration) *gen.ClientWithResponses {
hc, ok := c.doer.(*http.Client)
if !ok {
return c.inner
}
if hc.Timeout == 0 || hc.Timeout >= createAppTimeout {
if hc.Timeout == 0 || hc.Timeout >= minTimeout {
return c.inner
}
cloned := *hc
cloned.Timeout = createAppTimeout
cloned.Timeout = minTimeout
return newGeneratedClient(c.apiKey, c.baseURL, &cloned)
}

Expand Down
Loading