18 lines
278 B
Go

package pub
import (
"os"
"github.com/nats-io/nats.go"
)
func Publisher() (publisher func(string, []byte) error, closer func()) {
URI := os.Getenv("NATSURI")
if URI == "" {
panic("empty connection stream")
}
nc, _ := nats.Connect(URI)
return nc.Publish, nc.Close
}