Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

tribble-example-stack

An event-driven system spread over two tribble clusters, built to exercise the platform the way a customer would: several services, two data stores, scheduled jobs, private networking inside a cluster and public HTTPS between clusters.

This repo holds the picture and the documentation. The code lives in the service repos listed below.

The architecture

Two clusters: us-west-2 runs Vector, Postgres and the reconciler; pdx1-metrics3 runs n8n in queue mode

Follow the numbers:

  1. An event arrives. A producer POSTs JSON to Vector, the only way in.
  2. Vector stores it. Every event becomes one row in the events table. Nothing else writes to that database.
  3. The reconciler reads. It starts every minute, reads the events, works out what each process should do next, and exits. It keeps no state of its own.
  4. It runs a workflow. For a step that needs work done, it calls an n8n webhook in the other cluster and waits for the answer.
  5. n8n queues and executes. The webhook processor puts the job on Redis and a worker picks it up.
  6. The workflow reports back. It posts its result to Vector as a new event, which lands in the same table (step 2).
  7. The reconciler records its progress the same way: as events posted to Vector. On its next run it reads them back and carries on from there.

So there is one loop: everything that happens is an event, and every event goes through Vector into one table.

What runs where

cluster service kind reachable from built from
us-west-2 Vector always running internet (basic auth) tribble-example-vector
us-west-2 Postgres (events) data store, with a volume its cluster only platform template
us-west-2 Reconciler scheduled, every minute nothing calls it tribble-example-reconciler
us-west-2 Migrate scheduled job nothing calls it tribble-example-reconciler
pdx1-metrics3 n8n main always running internet (login) tribble-example-n8n
pdx1-metrics3 n8n webhooks always running internet (token) tribble-example-n8n
pdx1-metrics3 n8n workers always running, 2 replicas nothing calls them tribble-example-n8n
pdx1-metrics3 Postgres (n8n) data store, with a volume its cluster only platform template
pdx1-metrics3 Redis job queue its cluster only platform template

Two rules follow from the platform:

  • Inside a cluster apps reach each other by an internal name on a private network.
  • Between clusters there is no private network. The two calls that cross (4 and 6) go over public HTTPS and carry credentials.

One event, end to end

The sample process, check_site, checks that a website answers.

sequenceDiagram
    autonumber
    participant P as Producer
    box us-west-2
        participant V as Vector
        participant DB as Postgres (events)
        participant R as Reconciler
    end
    box pdx1-metrics3
        participant N as n8n
    end

    P->>V: site_check_requested (domain)
    V->>DB: insert
    Note over R: next run, within a minute
    R->>DB: read new events
    R->>V: check_site_opened
    R->>N: run the site-check workflow
    N-->>R: answer (status, ok)
    R->>V: check_site_checked
    N->>V: site_check_reported
    V->>DB: insert (all three)
    Note over R: next run
    R->>DB: read, find site_check_reported
    R->>V: check_site_reported (cycle complete)
Loading

A run that starts before Vector has written the previous run's events repeats a step. Every step is safe to repeat, so the cost is a second call, not a wrong result.

Where the code lives

repo what it is
tribble-example-vector Vector's image and config: HTTP in, Postgres out
tribble-example-reconciler the reconciler, the process definitions, the events schema, the n8n workflow
tribble-example-n8n n8n's image for all three roles
tribble-example-kafka a single-node Kafka, built but not part of the system yet

Each app is built by tribble from its repo and rebuilt when the repo changes.

Status

n8n in queue mode running
Vector and Postgres running; Vector accepts and rejects requests as it should
Reconciler running every minute, nothing to do yet
The site-check workflow in n8n not imported yet
One event through the whole loop not run yet
Kafka between Vector and the reconciler deferred

Decisions

  • Postgres, not MySQL. Vector can write to Postgres and cannot write to MySQL.
  • No Kafka for now. With one consumer that polls every minute, a table does the job of the log. Kafka stays a later test of the platform, not a need of the system.
  • The reconciler never writes to the database. It posts events like every other producer, so there is one way in and one writer.
  • Two clusters on purpose. The split is there to test how apps in different clusters work together, not because the system needs it.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors