Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wprowadzenie do Watermill - Gophers Silesia

Wprowadzenie do Watermill - Gophers Silesia

Budowanie aplikacji event-driven powinno być równie proste, co budowanie API HTTP - taki cel postawiliśmy sobie, gdy zaczynaliśmy pracę nad Watermillem. Chciałbym opowiedzieć historię o tym, jak stworzyliśmy jedną z najpopularniejszych bibliotek do obsługi eventów w Go.
Nie chcę jednak skończyć na teorii - podczas prezentacji napiszemy gotową do wdrożenia aplikację opartą o Watermilla, która będzie posiadała podstawowe funkcjonalności takie jak logowanie, metryki, czy poison queue. Nasz serwis będzie też całkowicie niezależny od użytego Pub/Suba: będzie mógł działać zarówno z RabbitMQ, Kafką, czy nawet z prostą implementacją opartą o MySQL.

Robert Laszczak

March 05, 2020
Tweet

More Decks by Robert Laszczak

Other Decks in Technology

Transcript

  1. • I’m Robert • Tech Lead @ • Blogging at

    https://threedots.tech/ • @roblaszczak at
  2. • Consumer groups • Partitioning • At-least-once delivery • Message

    Ack and Nack support • Not losing any message • Not everyone is familiar with event-driven architecture
  3. (1978) • Write programs that do one thing and do

    it well. • Write programs to work together. • Write programs to handle text streams message, because that is a universal interface.
  4. type Publisher interface { Publish(topic string, messages ...*Message) error Close()

    error } type Subscriber interface { Subscribe(ctx context.Context, topic string) (<-chan *Message, error) Close() error }
  5. func TestPublishSubscribe(t *testing.T) { features := tests.Features{ ConsumerGroups: true, ExactlyOnceDelivery:

    false, GuaranteedOrder: false, Persistent: true, } tests.TestPubSub( t, features, createPubSub, createPubSubWithConsumerGrup, ) }
  6. var stressTestTestsCount = 10 func TestPubSubStressTest( t *testing.T, features Features,

    pubSubConstructor PubSubConstructor, consumerGroupPubSubConstructor ConsumerGroupPubSubConstructor, ) { for i := 0; i < stressTestTestsCount; i++ { t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { t.Parallel() TestPubSub(t, features, pubSubConstructor, consumerGroupConstructor) }) } }
  7. Pub/Sub Publish (messages / s) Subscribe (messages / s) Kafka

    70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608
  8. Pub/Sub Publish (messages / s) Subscribe (messages / s) Kafka

    70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608
  9. Pub/Sub Publish (messages / s) Subscribe (messages / s) Kafka

    70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608
  10. • It’s hard to show everything in 20 minutes :)

    • Kafka and Google Cloud Pub/Sub internals • At-least-once delivery • CQRS component
  11. Photo by Micheile Henderson @micheile010 // Visual Stories [nl] on

    Unsplash Photo by Thomas Ehling on Unsplash