Add missing comments

pull/24/head
Aloïs Micard 4 years ago
parent a0be5160dc
commit 11f04b1ca3
No known key found for this signature in database
GPG Key ID: 1A0EB82F071F5EFE

@ -1,5 +1,7 @@
package nats
// Msg represent a message send-able trough NATS
type Msg interface {
// Subject returns the subject where message should be push
Subject() string
}

@ -6,10 +6,12 @@ import (
"github.com/nats-io/nats.go"
)
// PublishMsg publish given Msg
func PublishMsg(nc *nats.Conn, msg Msg) error {
return PublishJSON(nc, msg.Subject(), msg)
}
// ReadMsg read message from given connection
func ReadMsg(nc *nats.Msg, msg Msg) error {
return ReadJSON(nc, msg)
}

@ -16,6 +16,7 @@ type URLTodoMsg struct {
URL string `json:"url"`
}
// Subject returns the subject where message should be push
func (msg *URLTodoMsg) Subject() string {
return URLTodoSubject
}
@ -25,15 +26,18 @@ type URLFoundMsg struct {
URL string `json:"url"`
}
// Subject returns the subject where message should be push
func (msg *URLFoundMsg) Subject() string {
return URLFoundSubject
}
// NewResourceMsg represent a crawled resource
type NewResourceMsg struct {
URL string `json:"url"`
Body string `json:"body"`
}
// Subject returns the subject where message should be push
func (msg *NewResourceMsg) Subject() string {
return NewResourceSubject
}

Loading…
Cancel
Save