1
0
Fork 0

Update example consumer

This commit is contained in:
Gregory Eremin 2015-10-24 19:28:17 +03:00
parent 797e892120
commit 6d56b1b3be
1 changed files with 4 additions and 4 deletions

View File

@ -1,14 +1,14 @@
package daemons
import (
"log"
"time"
"github.com/localhots/satan"
)
// PriceConsumer consumes price update messages and prints them to the console.
type PriceConsumer struct {
satan.BaseConsumer
satan.BaseDaemon
}
// PriceUpdate describes a price update message.
@ -19,8 +19,8 @@ type PriceUpdate struct {
// Startup creates a new subscription for ProductPriceUpdates topic.
func (p *PriceConsumer) Startup() {
b.Subscribe("ProductPriceUpdates", func(u PriceUpdate) {
log.Printf("Price for %q is now $%.2f", u.Product, u.Amount)
p.Subscribe("ProductPriceUpdates", func(u PriceUpdate) {
p.Logf("Price for %q is now $%.2f", u.Product, u.Amount)
})
p.LimitRate(5, time.Second)
}