Fix examples
This commit is contained in:
parent
5e2ce03913
commit
cf973483d5
|
@ -14,8 +14,8 @@ type NumberPrinter struct {
|
||||||
|
|
||||||
// Startup sets up panic handler and starts enqueuing number printing jobs.
|
// Startup sets up panic handler and starts enqueuing number printing jobs.
|
||||||
func (n *NumberPrinter) Startup() {
|
func (n *NumberPrinter) Startup() {
|
||||||
n.HandlePanics(func(err interface{}) {
|
n.HandlePanics(func(err error) {
|
||||||
n.Logf("Oh, crap! There was a panic, take a look: %v", err)
|
n.Logf("Oh, crap! There was a panic, take a look: %s", err.Error())
|
||||||
})
|
})
|
||||||
|
|
||||||
n.LimitRate(3, time.Second)
|
n.LimitRate(3, time.Second)
|
||||||
|
|
|
@ -3,12 +3,12 @@ package daemons
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/localhots/shezmu"
|
"github.com/localhots/shezmu/consumer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 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 {
|
||||||
shezmu.BaseDaemon
|
consumer.Consumer
|
||||||
}
|
}
|
||||||
|
|
||||||
// PriceUpdate describes a price update message.
|
// PriceUpdate describes a price update message.
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"github.com/localhots/shezmu"
|
"github.com/localhots/shezmu/consumer"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConsumerState contains data that is required to create a Kafka consumer.
|
// ConsumerState contains data that is required to create a Kafka consumer.
|
||||||
|
@ -70,8 +70,8 @@ func Shutdown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe creates a shezmu.Streamer implementation for Kafka messaging queue.
|
// Subscribe creates a consumer.Streamer implementation for Kafka messaging queue.
|
||||||
func (s Subscriber) Subscribe(consumerName, topic string) shezmu.Streamer {
|
func (s Subscriber) Subscribe(consumerName, topic string) consumer.Streamer {
|
||||||
c, ok := consumers[consumerName]
|
c, ok := consumers[consumerName]
|
||||||
if !ok {
|
if !ok {
|
||||||
panic(fmt.Errorf("Consumer %q has no config", consumerName))
|
panic(fmt.Errorf("Consumer %q has no config", consumerName))
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/localhots/shezmu"
|
"github.com/localhots/shezmu"
|
||||||
"github.com/localhots/shezmu/example/daemons"
|
"github.com/localhots/shezmu/examples/daemons-kafka/daemons"
|
||||||
"github.com/localhots/shezmu/example/kafka"
|
"github.com/localhots/shezmu/examples/daemons-kafka/kafka"
|
||||||
"github.com/localhots/shezmu/server"
|
"github.com/localhots/shezmu/server"
|
||||||
"github.com/localhots/shezmu/stats"
|
"github.com/localhots/shezmu/stats"
|
||||||
)
|
)
|
||||||
|
@ -31,7 +31,6 @@ func main() {
|
||||||
server.Start()
|
server.Start()
|
||||||
|
|
||||||
s := shezmu.Summon()
|
s := shezmu.Summon()
|
||||||
s.Subscriber = kafka.Subscriber{}
|
|
||||||
s.DaemonStats = stats.NewGroup(statsLogger, statsServer)
|
s.DaemonStats = stats.NewGroup(statsLogger, statsServer)
|
||||||
|
|
||||||
s.AddDaemon(&daemons.NumberPrinter{})
|
s.AddDaemon(&daemons.NumberPrinter{})
|
||||||
|
|
Loading…
Reference in New Issue