mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
added initial command structure
This commit is contained in:
parent
091797ad1a
commit
5af0224b29
4 changed files with 61 additions and 4 deletions
|
@ -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() {
|
||||
|
|
23
edge/main.go
23
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() {
|
||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,5 @@
|
|||
module github.com/RaaLabs/steward
|
||||
|
||||
go 1.15
|
||||
|
||||
require github.com/nats-io/nats.go v1.10.0
|
||||
|
|
17
go.sum
Normal file
17
go.sum
Normal file
|
@ -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=
|
Loading…
Reference in a new issue