From 5af0224b2946277223b5709d529b19e88d6b26be Mon Sep 17 00:00:00 2001 From: postmannen Date: Mon, 25 Jan 2021 15:50:44 +0100 Subject: [PATCH] added initial command structure --- central/main.go | 23 +++++++++++++++++++++-- edge/main.go | 23 +++++++++++++++++++++-- go.mod | 2 ++ go.sum | 17 +++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 go.sum diff --git a/central/main.go b/central/main.go index 57d8f4d..cf01977 100644 --- a/central/main.go +++ b/central/main.go @@ -13,9 +13,28 @@ import ( "github.com/nats-io/nats.go" ) +type messageType int + +const ( + // shellCommand, wait for and return the output + // of the command in the ACK message. This means + // that the command should be executed immediately + // and that we should get the confirmation that it + // was successful or not. + shellCommand messageType = iota + // eventCommand, just wait for the ACK that the + // message is received. What action happens on the + // receiving side is up to the received to decide. + eventCommand messageType = iota +) + type Message struct { - ID int // The Unique ID of the message - Data string // The actual data in the message + // The Unique ID of the message + ID int + // The actual data in the message + Data string + // The type of the message being sent + MessageType messageType } func main() { diff --git a/edge/main.go b/edge/main.go index 593b717..5d571ef 100644 --- a/edge/main.go +++ b/edge/main.go @@ -9,9 +9,28 @@ import ( "github.com/nats-io/nats.go" ) +type messageType int + +const ( + // shellCommand, wait for and return the output + // of the command in the ACK message. This means + // that the command should be executed immediately + // and that we should get the confirmation that it + // was successful or not. + shellCommand messageType = iota + // eventCommand, just wait for the ACK that the + // message is received. What action happens on the + // receiving side is up to the received to decide. + eventCommand messageType = iota +) + type Message struct { - ID int // The Unique ID of the message - Data string // The actual data in the message + // The Unique ID of the message + ID int + // The actual data in the message + Data string + // The type of the message being sent + MessageType messageType } func main() { diff --git a/go.mod b/go.mod index eaa6afe..22e564e 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/RaaLabs/steward go 1.15 + +require github.com/nats-io/nats.go v1.10.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..3dd11f0 --- /dev/null +++ b/go.sum @@ -0,0 +1,17 @@ +github.com/nats-io/jwt v0.3.2 h1:+RB5hMpXUUA2dfxuhBTEkMOrYmM+gKIZYS1KjSostMI= +github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= +github.com/nats-io/nats.go v1.10.0 h1:L8qnKaofSfNFbXg0C5F71LdjPRnmQwSsA4ukmkt1TvY= +github.com/nats-io/nats.go v1.10.0/go.mod h1:AjGArbfyR50+afOUotNX2Xs5SYHf+CoOa5HH1eEl2HE= +github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nkeys v0.1.4 h1:aEsHIssIk6ETN5m2/MD8Y4B2X7FfXrBAUdkyRvbVYzA= +github.com/nats-io/nkeys v0.1.4/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= +github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 h1:3zb4D3T4G8jdExgVU/95+vQXfpEPiMdCaZgmGVxjNHM= +golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=