66

Software

obarun.org

Module services

A module is a service of Type = module that, at parse time, expands into a whole set of services managed as one. You author it once as an instantiated service — webapp@ — and stamp out as many independent instances as you need — webapp@blog, webapp@shop, … — each a complete, self-contained bundle parsed from the same template.

The shape of a module

Picture one template you stamp into sealed bundles of services:

       webapp@                       the template — you write it once
          │
          │  instantiate:  webapp@blog, webapp@shop, …
          ▼
   ┌── webapp@blog ─────────┐
   │                        │        each instance is a sealed
   │   worker ──▶ server    │        bundle: its services depend
   │     └─────▶ cache      │        on one another, privately
   │                        │
   └───────────┬────────────┘
               │                     only the bundle — not its
               ▼                     insides — reaches outward
          postgresql                 (a module-level dependency)

Three ideas are the whole concept:

Everything below follows from those three.

What a module gives you

One artifact, many instances

The template, its inside services, its tunables and its expansion rules all live in one directory (webapp@/). That directory is the deliverable — ship it, and an admin stamps out webapp@blog, webapp@shop, … at will. Each is parsed independently, so instances never share state, never collide, and are started, enabled or removed on their own.

The whole stack in one command

Starting an instance brings up all of its inside services at once, in dependency order — the module already knows what it contains, so you never wire them up or start them one by one:

66 start webapp@blog        # server, worker and cache come up together

Configured as a whole, per instance

A module carries its tunables in [Environment], and each instance can be set differently with 66 configure. The shape of the set can vary too: a module’s configure script runs at parse time and decides which inside services take part — one instance with a worker, another without, from the same sources and with no duplication.

Safe to evolve

Because the wall is real, a module’s internals are yours to change — add a service, rename one, split one in two — with no risk to the rest of the system, since nothing out there was ever allowed to reach in. The system’s dependency graph stays a set of clean, self-contained bundles instead of one sprawling web where anything can hook onto anything.

Problems a module solves

Reach for a module whenever you ship several services that belong together and must be instantiated and configured as a unit.

If you only need to order or co-start a few fixed services, a plain dependency between them is simpler — a module earns its keep when instantiation, per-instance configuration and isolation come together.

Next steps