Update example consumer
This commit is contained in:
parent
797e892120
commit
6d56b1b3be
@ -1,14 +1,14 @@
|
|||||||
package daemons
|
package daemons
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"time"
|
||||||
|
|
||||||
"github.com/localhots/satan"
|
"github.com/localhots/satan"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PriceConsumer consumes price update messages and prints them to the console.
|
// PriceConsumer consumes price update messages and prints them to the console.
|
||||||
type PriceConsumer struct {
|
type PriceConsumer struct {
|
||||||
satan.BaseConsumer
|
satan.BaseDaemon
|
||||||
}
|
}
|
||||||
|
|
||||||
// PriceUpdate describes a price update message.
|
// PriceUpdate describes a price update message.
|
||||||
@ -19,8 +19,8 @@ type PriceUpdate struct {
|
|||||||
|
|
||||||
// Startup creates a new subscription for ProductPriceUpdates topic.
|
// Startup creates a new subscription for ProductPriceUpdates topic.
|
||||||
func (p *PriceConsumer) Startup() {
|
func (p *PriceConsumer) Startup() {
|
||||||
b.Subscribe("ProductPriceUpdates", func(u PriceUpdate) {
|
p.Subscribe("ProductPriceUpdates", func(u PriceUpdate) {
|
||||||
log.Printf("Price for %q is now $%.2f", u.Product, u.Amount)
|
p.Logf("Price for %q is now $%.2f", u.Product, u.Amount)
|
||||||
})
|
})
|
||||||
p.LimitRate(5, time.Second)
|
p.LimitRate(5, time.Second)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user