Skip to content

Commit

Permalink
Bump examples to watermill-kafka v2.0.0 (#132)
Browse files Browse the repository at this point in the history
* Bump examples to watermill-kafka v2.0.0

* Fix path in docs
  • Loading branch information
m110 authored Sep 17, 2019
1 parent 537c1e0 commit 5007336
Show file tree
Hide file tree
Showing 28 changed files with 117 additions and 68 deletions.
2 changes: 1 addition & 1 deletion _examples/basic/1-your-first-app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module main.go

require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-kafka v1.0.1
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
)
4 changes: 2 additions & 2 deletions _examples/basic/1-your-first-app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2 h1:DCKR8kSLHUyZny6LiKtO7h+IZPMo0t9x786FOZmoAh4=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2/go.mod h1:gjVFKc8aN+vmEHw3pA0kh4mmuwHe02nyfghb6IWWiKE=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 h1:YQgkPKNWF0VrN87ito+CpG15AOsXzG/8fXilTROHpZI=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1/go.mod h1:rkfdt6PpcQpOGhyublmmGIYUs6qGN3ajYT6P3jYpFYE=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0 h1:+8FeCjF+BgW5b8L7TofMYw8eQUiITF/0evJh38wt3W0=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0/go.mod h1:0/RwtDh+LUbVawbSoN2ifZbqhbaW8OK5AJLZ6g7BESE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
21 changes: 13 additions & 8 deletions _examples/basic/1-your-first-app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill-kafka/pkg/kafka"
"github.com/ThreeDotsLabs/watermill-kafka/v2/pkg/kafka"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/message/router/middleware"
"github.com/ThreeDotsLabs/watermill/message/router/plugin"
Expand Down Expand Up @@ -94,9 +94,10 @@ func main() {
// createPublisher is a helper function that creates a Publisher, in this case - the Kafka Publisher.
func createPublisher() message.Publisher {
kafkaPublisher, err := kafka.NewPublisher(
brokers,
marshaler,
nil,
kafka.PublisherConfig{
Brokers: brokers,
Marshaler: marshaler,
},
logger,
)
if err != nil {
Expand All @@ -108,10 +109,14 @@ func createPublisher() message.Publisher {

// createSubscriber is a helper function similar to the previous one, but in this case it creates a Subscriber.
func createSubscriber(consumerGroup string) message.Subscriber {
kafkaSubscriber, err := kafka.NewSubscriber(kafka.SubscriberConfig{
Brokers: brokers,
ConsumerGroup: consumerGroup, // every handler will use a separate consumer group
}, nil, marshaler, logger)
kafkaSubscriber, err := kafka.NewSubscriber(
kafka.SubscriberConfig{
Brokers: brokers,
Unmarshaler: marshaler,
ConsumerGroup: consumerGroup, // every handler will use a separate consumer group
},
logger,
)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion _examples/basic/2-realtime-feed/consumer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module main.go

require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-kafka v1.0.1
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
github.com/pkg/errors v0.8.1
)
4 changes: 2 additions & 2 deletions _examples/basic/2-realtime-feed/consumer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2 h1:DCKR8kSLHUyZny6LiKtO7h+IZPMo0t9x786FOZmoAh4=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2/go.mod h1:gjVFKc8aN+vmEHw3pA0kh4mmuwHe02nyfghb6IWWiKE=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 h1:YQgkPKNWF0VrN87ito+CpG15AOsXzG/8fXilTROHpZI=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1/go.mod h1:rkfdt6PpcQpOGhyublmmGIYUs6qGN3ajYT6P3jYpFYE=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0 h1:+8FeCjF+BgW5b8L7TofMYw8eQUiITF/0evJh38wt3W0=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0/go.mod h1:0/RwtDh+LUbVawbSoN2ifZbqhbaW8OK5AJLZ6g7BESE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
Expand Down
13 changes: 9 additions & 4 deletions _examples/basic/2-realtime-feed/consumer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"

"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill-kafka/pkg/kafka"
"github.com/ThreeDotsLabs/watermill-kafka/v2/pkg/kafka"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/message/router/middleware"
"github.com/ThreeDotsLabs/watermill/message/router/plugin"
Expand All @@ -25,7 +25,13 @@ func main() {
logger := watermill.NewStdLogger(false, false)
logger.Info("Starting the consumer", nil)

pub, err := kafka.NewPublisher(brokers, marshaler, nil, logger)
pub, err := kafka.NewPublisher(
kafka.PublisherConfig{
Brokers: brokers,
Marshaler: marshaler,
},
logger,
)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -101,10 +107,9 @@ func createSubscriber(consumerGroup string, logger watermill.LoggerAdapter) mess
sub, err := kafka.NewSubscriber(
kafka.SubscriberConfig{
Brokers: brokers,
Unmarshaler: marshaler,
ConsumerGroup: consumerGroup,
},
nil,
marshaler,
logger,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion _examples/basic/2-realtime-feed/producer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ module main.go

require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-kafka v1.0.1
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
github.com/brianvoe/gofakeit v3.18.0+incompatible
)
4 changes: 2 additions & 2 deletions _examples/basic/2-realtime-feed/producer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2 h1:DCKR8kSLHUyZny6LiKtO7h+IZPMo0t9x786FOZmoAh4=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2/go.mod h1:gjVFKc8aN+vmEHw3pA0kh4mmuwHe02nyfghb6IWWiKE=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 h1:YQgkPKNWF0VrN87ito+CpG15AOsXzG/8fXilTROHpZI=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1/go.mod h1:rkfdt6PpcQpOGhyublmmGIYUs6qGN3ajYT6P3jYpFYE=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0 h1:+8FeCjF+BgW5b8L7TofMYw8eQUiITF/0evJh38wt3W0=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0/go.mod h1:0/RwtDh+LUbVawbSoN2ifZbqhbaW8OK5AJLZ6g7BESE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
10 changes: 8 additions & 2 deletions _examples/basic/2-realtime-feed/producer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/brianvoe/gofakeit"

"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill-kafka/pkg/kafka"
"github.com/ThreeDotsLabs/watermill-kafka/v2/pkg/kafka"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/message/router/middleware"
)
Expand All @@ -30,7 +30,13 @@ func main() {

rand.Seed(time.Now().Unix())

publisher, err := kafka.NewPublisher(brokers, kafka.DefaultMarshaler{}, nil, logger)
publisher, err := kafka.NewPublisher(
kafka.PublisherConfig{
Brokers: brokers,
Marshaler: kafka.DefaultMarshaler{},
},
logger,
)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion _examples/http-to-kafka/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module main.go
require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-http v1.0.1
github.com/ThreeDotsLabs/watermill-kafka v1.0.1
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
github.com/pkg/errors v0.8.1
)
4 changes: 2 additions & 2 deletions _examples/http-to-kafka/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/ThreeDotsLabs/watermill v1.0.0-rc.2 h1:DCKR8kSLHUyZny6LiKtO7h+IZPMo0t
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2/go.mod h1:gjVFKc8aN+vmEHw3pA0kh4mmuwHe02nyfghb6IWWiKE=
github.com/ThreeDotsLabs/watermill-http v1.0.1 h1:9g/toufWmYAZvBOnHcugXiV4yG5X33/1B0oZLwztS7M=
github.com/ThreeDotsLabs/watermill-http v1.0.1/go.mod h1:zb7mWf582wx5x/uy0N9PGfiZCG0f63Tk/D4sNtidTSk=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 h1:YQgkPKNWF0VrN87ito+CpG15AOsXzG/8fXilTROHpZI=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1/go.mod h1:rkfdt6PpcQpOGhyublmmGIYUs6qGN3ajYT6P3jYpFYE=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0 h1:+8FeCjF+BgW5b8L7TofMYw8eQUiITF/0evJh38wt3W0=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0/go.mod h1:0/RwtDh+LUbVawbSoN2ifZbqhbaW8OK5AJLZ6g7BESE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
Expand Down
10 changes: 8 additions & 2 deletions _examples/http-to-kafka/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill-http/pkg/http"
"github.com/ThreeDotsLabs/watermill-kafka/pkg/kafka"
"github.com/ThreeDotsLabs/watermill-kafka/v2/pkg/kafka"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/message/router/middleware"
"github.com/ThreeDotsLabs/watermill/message/router/plugin"
Expand All @@ -31,7 +31,13 @@ func main() {
flag.Parse()
logger := watermill.NewStdLogger(true, true)

kafkaPublisher, err := kafka.NewPublisher([]string{*kafkaAddr}, kafka.DefaultMarshaler{}, nil, logger)
kafkaPublisher, err := kafka.NewPublisher(
kafka.PublisherConfig{
Brokers: []string{*kafkaAddr},
Marshaler: kafka.DefaultMarshaler{},
},
logger,
)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion _examples/kafka-to-http/producer/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ module main.go

require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-kafka v1.0.1
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
)
4 changes: 2 additions & 2 deletions _examples/kafka-to-http/producer/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWso
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2 h1:DCKR8kSLHUyZny6LiKtO7h+IZPMo0t9x786FOZmoAh4=
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2/go.mod h1:gjVFKc8aN+vmEHw3pA0kh4mmuwHe02nyfghb6IWWiKE=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 h1:YQgkPKNWF0VrN87ito+CpG15AOsXzG/8fXilTROHpZI=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1/go.mod h1:rkfdt6PpcQpOGhyublmmGIYUs6qGN3ajYT6P3jYpFYE=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0 h1:+8FeCjF+BgW5b8L7TofMYw8eQUiITF/0evJh38wt3W0=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0/go.mod h1:0/RwtDh+LUbVawbSoN2ifZbqhbaW8OK5AJLZ6g7BESE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
10 changes: 8 additions & 2 deletions _examples/kafka-to-http/producer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/ThreeDotsLabs/watermill"
"github.com/ThreeDotsLabs/watermill-kafka/pkg/kafka"
"github.com/ThreeDotsLabs/watermill-kafka/v2/pkg/kafka"
"github.com/ThreeDotsLabs/watermill/message"
)

Expand All @@ -24,7 +24,13 @@ const (
)

func main() {
pub, err := kafka.NewPublisher(brokers, kafka.DefaultMarshaler{}, nil, logger)
pub, err := kafka.NewPublisher(
kafka.PublisherConfig{
Brokers: brokers,
Marshaler: kafka.DefaultMarshaler{},
},
logger,
)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion _examples/kafka-to-http/router/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module main.go
require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-http v1.0.1
github.com/ThreeDotsLabs/watermill-kafka v1.0.1
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
)
4 changes: 2 additions & 2 deletions _examples/kafka-to-http/router/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/ThreeDotsLabs/watermill v1.0.0-rc.2 h1:DCKR8kSLHUyZny6LiKtO7h+IZPMo0t
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2/go.mod h1:gjVFKc8aN+vmEHw3pA0kh4mmuwHe02nyfghb6IWWiKE=
github.com/ThreeDotsLabs/watermill-http v1.0.1 h1:9g/toufWmYAZvBOnHcugXiV4yG5X33/1B0oZLwztS7M=
github.com/ThreeDotsLabs/watermill-http v1.0.1/go.mod h1:zb7mWf582wx5x/uy0N9PGfiZCG0f63Tk/D4sNtidTSk=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 h1:YQgkPKNWF0VrN87ito+CpG15AOsXzG/8fXilTROHpZI=
github.com/ThreeDotsLabs/watermill-kafka v1.0.1/go.mod h1:rkfdt6PpcQpOGhyublmmGIYUs6qGN3ajYT6P3jYpFYE=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0 h1:+8FeCjF+BgW5b8L7TofMYw8eQUiITF/0evJh38wt3W0=
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0/go.mod h1:0/RwtDh+LUbVawbSoN2ifZbqhbaW8OK5AJLZ6g7BESE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
12 changes: 8 additions & 4 deletions _examples/kafka-to-http/router/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/ThreeDotsLabs/watermill"
watermill_http "github.com/ThreeDotsLabs/watermill-http/pkg/http"
"github.com/ThreeDotsLabs/watermill-kafka/pkg/kafka"
"github.com/ThreeDotsLabs/watermill-kafka/v2/pkg/kafka"
"github.com/ThreeDotsLabs/watermill/message"
"github.com/ThreeDotsLabs/watermill/message/router/plugin"
)
Expand Down Expand Up @@ -39,9 +39,13 @@ func main() {
panic(err)
}

subscriber, err := kafka.NewSubscriber(kafka.SubscriberConfig{
Brokers: []string{"kafka:9092"},
}, nil, kafka.DefaultMarshaler{}, logger)
subscriber, err := kafka.NewSubscriber(
kafka.SubscriberConfig{
Brokers: []string{"kafka:9092"},
Unmarshaler: kafka.DefaultMarshaler{},
},
logger,
)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion _examples/sql/transactional-events/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
github.com/ThreeDotsLabs/watermill v1.0.0-rc.2
github.com/ThreeDotsLabs/watermill-kafka v1.0.1 // indirect
github.com/ThreeDotsLabs/watermill-kafka/v2 v2.0.0
github.com/ThreeDotsLabs/watermill-sql v0.1.1
github.com/go-sql-driver/mysql v1.4.1
)
Loading

0 comments on commit 5007336

Please sign in to comment.