Skip to content

Background jobs and workers

“Worker” in Sylva can mean three related things. This page disambiguates them so you land in the right repository when debugging.

1. LoopBack Worker model (Identity Manager / api-models)

Section titled “1. LoopBack Worker model (Identity Manager / api-models)”

The API exposes a Worker resource with remote methods only (no standard model CRUD). Examples from the public contract (see API reference):

  • POST /Worker/processWebhookAnalytics
  • POST /Worker/scheduled-cleanup
  • POST /Worker/cleanupExpiredTokens
  • POST /Worker/cleanupOrphanProjects

Implementation lives in api-models under worker/ (methods, hooks) and is loaded by Identity Manager like any other model. These endpoints are invoked by schedulers, webhooks, or internal HTTP calls—often from GCP (Cloud Scheduler → HTTP, Pub/Sub push, etc.).

When you add a new HTTP-triggered maintenance or analytics job that belongs with the LoopBack app, this is the usual place.

Identity Manager dependencies include @google-cloud/tasks, @google-cloud/pubsub, and related libraries. Many Project and SystemUser flows enqueue work (invitations, analytics, debounced actions) rather than doing everything inline. Those code paths are still inside api-models / Identity Manager server code; look for Cloud Tasks and Pub/Sub usage in model methods.

3. sylva-worker repository (standalone packages)

Section titled “3. sylva-worker repository (standalone packages)”

The sylva-worker repo holds separate Node (and other) packages that are deployed as their own processes or functions. Examples present in the workspace (names are illustrative—check each package.json):

Package / areaLikely purpose
pdf-makerPDF generation (e.g. pdfmake + GCS)
pdf-printerRelated PDF pipeline
component-parserParses content/component data; uses MongoDB, GCS
image-resizerImage processing
algolia-indexerSearch indexing
bigquery-loaderAnalytics / data warehouse loads
e2e-testsWorker-related integration tests
selenium-clusterKubernetes/Helm for Selenium
visa_formPython tooling (isolated use case)

These services typically:

  • Use service account JSON (e.g. gcloud.service.key*.json patterns in repo—never commit real keys; use secrets in deployment).
  • Talk to GCS, MongoDB, or other GCP APIs in the same project as Sylva.

Operational notes (e.g. clearing Pub/Sub backlog) may appear in the repo README snippets.

CriterionPrefer
Tight coupling to LoopBack models, transactions, ACLapi-models Worker or model method + Task queue
Heavy dependency isolation, different runtime, or reuse across servicessylva-worker package + deploy separately
User-visible API contract must stay under /apiLoopBack remote method