1. Hello worker
In this tutorial, an application authenticates to Core, reports its identity, and appears in the Workers view. You need a running Core and a worker token.
Set the connection values
Provide these values through your shell, service manager, or secret store:
SYNAPSYS_CORE_URL=http://localhost:8080
SYNAPSYS_CORE_TOKEN=replace-with-your-worker-token
- Spring Boot
- Node.js
- Raw API
Add the Maven Central dependency, then configure:
spring:
application:
name: hello-worker
synapsys:
core-url: ${SYNAPSYS_CORE_URL}
core-token: ${SYNAPSYS_CORE_TOKEN}
Start the application. The starter owns the heartbeat lifecycle.
Install @synapsys-io/sdk, then:
const { Synapsys } = require('@synapsys-io/sdk');
const synapsys = new Synapsys({ workerName: 'hello-worker' });
synapsys.start();
Run node app.js. The SDK reads the Core URL and token from the environment.
Send a single authenticated heartbeat:
curl --request POST 'http://localhost:8080/api/v1/workers/heartbeat' \
--header "Authorization: Bearer ${SYNAPSYS_CORE_TOKEN}" \
--header 'Content-Type: application/json' \
--data '{"workerName":"hello-worker","framework":"unknown","heartbeatInterval":5,"processes":[]}'
An empty processes array is valid. A real client repeats the request on the stated
interval; see the Raw API loop.
Verify it
Sign in to Core and open Workers. hello-worker should appear after the first
successful heartbeat. Stop the application and it becomes inactive after Core no
longer receives its heartbeat.
There was no registration request: the authenticated heartbeat both introduces and
renews the worker. Keep workerName stable across restarts so Core recognises the
same application.
Next: add an endless process.