2. What we have:
message_bus
• Arbitrarily named topics
• Multiple event types per topic
• event_type explicitly defined as part of the message body
• Which topic should I listen to to get a particular event type?
• No schema validation — can send anything
• No schema versioning — how can we evolve the schema?
• No documentation of topics, event data structure, or data fields
• The message body is JSON
3. What we would like to have:
crealytics_events
• Required field event_type goes away — the topic determines the event
type (1:1 relationship)
• Events are serialized / deserialized to / from Avro
• Event model <=> Avro
• Each topic has its own schema, stored in a schema registry
• Schema evolution and reconciliation is done according to Avro
specifications
• Events are validated against the topic's schema upon production and
consumption
• Schemas and topics are documented with YARD
4. • The crealytics Ruby interface to Apache Kafka
• Abstracts away all concerns associated with
publishing, consuming, serializing, and
deserializing messages
• Supports MRI and JRuby
crealytics_events
v0.0.1
5. External dependencies
• avro-schema-registry
• Implementation of the Confluent Schema Registry API
as a Rails application
• avro-builder
• Ruby DSL to create Avro schemas
• avromatic
• Avromatic generates Ruby models from Avro schemas
and provides utilities to encode and decode them
9. Event models
• Inherit from BaseEvent
• Provides required fields: uuid, time_stamp, and event_source
• Provides method emit for sending events
• Have a unique associated topic inferred from the class name
• For example: CustomerEvent => customer-events
• Include the Avro schemas
13. What happens when we get
an event?
Remember event handlers during the configuration step?
Q: But what is an event handler?
A: Any object which responds to a method call
14. Wait, but where is Kafka?
Don’t worry about it
(CrealyticsEvents encapsulates all Kafka interaction)
15. Next steps
• Aggregate events, embedding events
• Schema version evolution
• Mapping handlers to event models instead of text
topics
• Improving default decoder