Skip to content

A small Golang project to demostrate an event-driven microservice using nats

License

Notifications You must be signed in to change notification settings

TonyPath/activity-ingestion-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Activity Ingestion Microservice

go.mod Go version


Main Components

Consumer

Listens for messages coming from ActivityFired and SendActivityDigest subjects by creating two subscriptions through Stream method provided by the consumer. Both subscription are created under the group name activity-ingestion-svc so that in case of horizontal scaling e ach message will be randomly balanced to only one of the subscribers

consumer, err := natskit.NewConsumer(natsURL, log)

h1 := func(ctx context.Context, msg *nats.Msg) error {...}
consumer.Stream(ctx, "ActivityFired", "activity-ingestion-svc", h1)

h2 := func(ctx context.Context, msg *nats.Msg) error { ... }
consumer.Stream(ctx, "SendActivityDigest", "activity-ingestion-svc", h2)

Producer

Publish messages to ActivityDigest subject

producer, err := natskit.NewProducer(natsURL, log)
producer.Publish("ActivityDigest", activityDigestMessage)

About

A small Golang project to demostrate an event-driven microservice using nats

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published