Skip to content

Instantly share code, notes, and snippets.

@dasch
Last active Aug 16, 2017
Embed
What would you like to do?
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
def show
@post = Post.find(params[:id])
event = {
post_id: @post.id,
ip_address: request.remote_ip,
timestamp: Time.now,
}
# Calling `deliver_async` will enqueue the message in an asynchronous
# Kafka producer that will periodically deliver all pending messages.
DeliveryBoy.deliver_async(event.to_json, topic: "post-views")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment