Workers
Upsert Worker Config
Create or replace a worker configuration in each specified datacenter.
A normal configuration controls workers with direct, persistent connections. A serverless configuration starts workers through a URL and requires url and request_lifespan. Configurations for omitted datacenters are deleted. A failure can occur after some datacenters have already changed.
PUT https://api.rivet.dev/runner-configs/{runner_name}
Examples
curl -X PUT "https://api.rivet.dev/runner-configs/$RUNNER_NAME?namespace=$RIVET_NAMESPACE" \
-H "Authorization: Bearer $RIVET_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"datacenters": {
"local": {
"normal": {}
}
}
}'
const endpoint = "https://api.rivet.dev";
const namespace = process.env.RIVET_NAMESPACE ?? "default";
const token = process.env.RIVET_TOKEN ?? "";
const workerName = process.env.RUNNER_NAME ?? "default";
const params = new URLSearchParams({ namespace });
const response = await fetch(
`${endpoint}/runner-configs/${encodeURIComponent(workerName)}?${params}`,
{
method: "PUT",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ datacenters: { local: { normal: {} } } }),
},
);
console.log(await response.json());
export {};
Authentication
Send your namespace token as a bearer token in the Authorization header. Every control plane request also requires the namespace query parameter. See Authentication.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
runner_name | string | Yes | Name of the worker pool to configure. |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
namespace | string | Yes | Name of the namespace to operate in. |
Request Body
Content type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
datacenters | object | Yes | Map of datacenter names to worker configurations. |
Responses
200
Whether the endpoint configuration changed.
| Field | Type | Description |
|---|---|---|
endpoint_config_changed | boolean |
{
"endpoint_config_changed": false
}