Skip to Content
Hands-On Microservices with Kubernetes
book

Hands-On Microservices with Kubernetes

by Gigi Sayfan
July 2019
Intermediate to advanced
502 pages
14h
English
Packt Publishing
Content preview from Hands-On Microservices with Kubernetes

Subscribing to link events with NATS

The news service uses the Listen() function from pkg/link_manager_events/listener.go. It accepts the NATS server URL and an event sink that implements the LinkManagerEvents interface. It connects to the NATS server and then subscribes to the link-events subject. This is the same subject that the event sender is sending those events to:

package link_manager_events import ( om "github.com/the-gigi/delinkcious/pkg/object_model" ) func Listen(url string, sink om.LinkManagerEvents) (err error) { conn, err := connect(url) if err != nil { return } conn.Subscribe(subject, func(e *Event) { switch e.EventType { case om.LinkAdded: { sink.OnLinkAdded(e.Username, e.Link) } case om.LinkUpdated: { sink.OnLinkAdded(e.Username, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kubernetes Microservices

Kubernetes Microservices

Richard Chesterwood
Cloud Native DevOps with Kubernetes

Cloud Native DevOps with Kubernetes

John Arundel, Justin Domingus
Microservices: Up and Running

Microservices: Up and Running

Ronnie Mitra, Irakli Nadareishvili

Publisher Resources

ISBN: 9781789805468Supplemental Content