Go types for the GSD Cloud wire protocol — the message format the daemon and relay use to talk to each other over websockets.
go get github.com/gsd-build/protocol-goimport (
"encoding/json"
protocol "github.com/gsd-build/protocol-go"
)
// Decode an incoming frame:
env, err := protocol.ParseEnvelope(data)
if err != nil {
// handle error
}
switch msg := env.Payload.(type) {
case *protocol.Hello:
_ = msg.MachineID
case *protocol.Task:
_ = msg.Prompt
}
// Encode an outgoing frame — marshal the payload struct directly:
data, _ := json.Marshal(&protocol.Hello{
Type: protocol.MsgTypeHello,
MachineID: "machine-1",
})See PROTOCOL.md for the wire format specification.
MIT — see LICENSE.