An experimental pub/sub client and server project.
at main 462 B view raw
1package client 2 3// Message represents a message that can be published or consumed 4type Message struct { 5 Topic string `json:"topic"` 6 Data []byte `json:"data"` 7 8 ack chan bool 9} 10 11// NewMessage creates a new message 12func NewMessage(topic string, data []byte) *Message { 13 return &Message{ 14 Topic: topic, 15 Data: data, 16 ack: make(chan bool), 17 } 18} 19 20// Ack will send the provided value of the ack to the server 21func (m *Message) Ack(ack bool) { 22 m.ack <- ack 23}