My implementation of gossip-gloomers - the fly.io distributed systems challenge (https://fly.io/dist-sys/)
at main 21 lines 481 B view raw
1package main 2 3import ( 4 "encoding/json" 5 6 maelstrom "github.com/jepsen-io/maelstrom/demo/go" 7) 8 9func (s *server) handleEcho(msg maelstrom.Message) error { 10 // Unmarshal the message body as an loosely-typed map. 11 var body map[string]any 12 if err := json.Unmarshal(msg.Body, &body); err != nil { 13 return err 14 } 15 16 // Update the message type to return back. 17 body["type"] = "echo_ok" 18 19 // Echo the original message back with the updated message type. 20 return s.node.Reply(msg, body) 21}