Last active
August 16, 2017 11:47
-
-
Save dasch/4c166c3b4b9a2fa91fda5334735963f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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