This repository contains the Worker charm for JGOL (Juju Game of Life) - a distributed implementation of Conway's Game of Life designed to exercise Juju's orchestration capabilities. Each unit in the deployment represents a single cell in the Game of Life grid.
The system consists of two charms working together:
- Role: Implements the Game of Life cells and coordination logic
- Responsibilities:
- Each unit represents one cell in the grid
- Uses a peer relation to communicate with other worker units
- The leader unit runs additional "god" code that:
- Manages the global topology map of the grid
- Coordinates game generations
- Distributes state information to all cells
- Non-leader units act as individual cells that:
- Receive topology and state from the leader
- Calculate their next generation state based on Conway's rules
- Report updated state back through the peer relation
- Role: Runs only the "god" code for managing the game
- Responsibilities:
- Maintains the global grid topology
- Coordinates game iterations
- Distributes state to worker units
- No individual cell logic - pure coordination
- Worker charm: Dual-purpose - cells + optional god mode (leader unit)
- Coordinator charm: Single-purpose - only god/coordination logic
- Both use the
worldrelation endpoint to communicate - Workers use peer relations to communicate among themselves
Each worker unit implements these rules:
- Birth: A dead cell with exactly 3 live neighbors becomes alive
- Survival: A live cell with 2 or 3 live neighbors stays alive
- Death: All other cases result in a dead cell
┌──────────────────────────────────────┐
│ Worker Charm Deployment │
│ │
│ ┌─────────────────────────────────┐ │
│ │ Leader Unit (app/0) │ │
│ │ • Cell logic │ │
│ │ • God code (topology & state) │ │
│ └────────┬────────────────────────┘ │
│ │ peer relation │
│ │ (topology map + state) │
│ ┌────┴────┬────────┬───────┐ │
│ ↓ ↓ ↓ ↓ │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌────┐ │
│ │app/1 │ │app/2 │ │app/3 │ │... │ │
│ │Cell │ │Cell │ │Cell │ │Cell│ │
│ └──────┘ └──────┘ └──────┘ └────┘ │
└──────────────────────────────────────┘
- Leader unit publishes topology map (neighbor relationships) to peer relation
- Leader distributes current generation state to all units
- Each unit calculates its next state based on neighbors' states from the map
- Units report their new state back through peer relation
- Leader synchronizes the new generation and repeats
Tests use a 3x3 grid topology where each cell knows its neighbors:
0 1 2
3 4 5
6 7 8
- Unit 4 (center cell) has all 8 possible neighbors, making it ideal for comprehensive testing
- Tests verify the
worldrelation for communication with coordinator - The
remote_app_datasimulates data from either the coordinator charm or the leader unit
- Uses
opsframework for charm development - Topology map format:
{"app/0": ["app/1", "app/3", ...], ...} - State format: Individual keys per unit (e.g.,
"app/4": "1"for alive,"0"for dead) - Relation endpoint:
world - Communication: JSON-encoded data through Juju relations