My implementation of gossip-gloomers - the fly.io distributed systems challenge (https://fly.io/dist-sys/)

setup of maelstrom inside docker container and first challenge complete

Signed-off-by: Will Andrews <will7989@hotmail.com>

willdot.net 89769d91

+75
+8
Dockerfile
··· 1 + FROM homebrew/brew 2 + 3 + RUN brew install openjdk graphviz gnuplot golang 4 + 5 + RUN curl -LJO https://github.com/jepsen-io/maelstrom/releases/download/v0.2.3/maelstrom.tar.bz2 6 + RUN tar -xvf maelstrom.tar.bz2 7 + 8 + WORKDIR /home/linuxbrew/app
+11
docker-compose.yaml
··· 1 + services: 2 + gossip-gloomers: 3 + container_name: gossip-gloomers 4 + build: . 5 + environment: 6 + - TEST_TO_RUN=placeholder_value 7 + volumes: 8 + # Mount the code in this repo so that the run script can build the app inside the container 9 + # on the fly inside of needing to build the app before hand 10 + - .:/home/linuxbrew/app 11 + command: ./run.sh
+5
go.mod
··· 1 + module tangled.sh/willdot.net/gossip-gloomers 2 + 3 + go 1.25.0 4 + 5 + require github.com/jepsen-io/maelstrom/demo/go v0.0.0-20251128144731-cb7f07239012
+2
go.sum
··· 1 + github.com/jepsen-io/maelstrom/demo/go v0.0.0-20251128144731-cb7f07239012 h1:j2FpC/930Px9SWIn8lgzxEiEZOvaQ9EUs37+e1QCNLA= 2 + github.com/jepsen-io/maelstrom/demo/go v0.0.0-20251128144731-cb7f07239012/go.mod h1:i6aVIs5AIOOaQF1lAisBm7DDeWM1Iopf+26UxjagsCU=
+29
main.go
··· 1 + package main 2 + 3 + import ( 4 + "encoding/json" 5 + "log" 6 + 7 + maelstrom "github.com/jepsen-io/maelstrom/demo/go" 8 + ) 9 + 10 + func main() { 11 + n := maelstrom.NewNode() 12 + n.Handle("echo", func(msg maelstrom.Message) error { 13 + // Unmarshal the message body as an loosely-typed map. 14 + var body map[string]any 15 + if err := json.Unmarshal(msg.Body, &body); err != nil { 16 + return err 17 + } 18 + 19 + // Update the message type to return back. 20 + body["type"] = "echo_ok" 21 + 22 + // Echo the original message back with the updated message type. 23 + return n.Reply(msg, body) 24 + }) 25 + 26 + if err := n.Run(); err != nil { 27 + log.Fatal(err) 28 + } 29 + }
+7
readme.md
··· 1 + ## Gossip Gloomers 2 + 3 + This is my solutions to the [Gossip Gloomers](https://fly.io/dist-sys/) distributed systems problem by fly.io 4 + 5 + I have created a docker image for running the tests inside which can be run using `docker-compose run --rm -e TEST_TO_RUN=echo gossip-gloomers` (replacing the TEST_TO_RUN env to be the test to run). 6 + 7 + Note: The docker image is based off of the `homebrew/brew` image which is quite a whopper of an image so be prepaerd for a longish build time. Need to optimise that to be honest.
+13
run.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + go install . 4 + 5 + # Go back to where maelstrom is so that the additional files that are created when running it 6 + # don't end up in the mounted volume and on our local machines 7 + cd /home/linuxbrew/maelstrom/ 8 + 9 + if [ "$TEST_TO_RUN" = 'echo' ]; then 10 + ./maelstrom test -w $TEST_TO_RUN --bin /home/linuxbrew/go/bin/gossip-gloomers --node-count 1 --time-limit 10 11 + else 12 + echo "invalid input" 13 + fi