-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi worker setup #6
Conversation
resource_user_key = "#{resource.to_gid}:#{user.to_gid}" | ||
digested_block_key = ActiveSupport::Digest.hexdigest("#{block_location}:#{resource_user_key}") | ||
|
||
# the store item (identified by block location, resource, and user) might already be present | ||
store_item = Cubism.store[digested_block_key] || Cubism::BlockStoreItem.new( | ||
block_location: block_location, | ||
resource_gid: resource.to_gid.to_s, | ||
user_gid: user.to_gid.to_s | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps an almost meaningless "optimization", but we don't need to get the gid
twice for resource
and user
:
resource_user_key = "#{resource.to_gid}:#{user.to_gid}" | |
digested_block_key = ActiveSupport::Digest.hexdigest("#{block_location}:#{resource_user_key}") | |
# the store item (identified by block location, resource, and user) might already be present | |
store_item = Cubism.store[digested_block_key] || Cubism::BlockStoreItem.new( | |
block_location: block_location, | |
resource_gid: resource.to_gid.to_s, | |
user_gid: user.to_gid.to_s | |
) | |
resource_gid = resource.to_gid.to_s | |
user_gid = user.to_gid.to_s | |
resource_user_key = [resource_gid, user_gid].join(":") | |
digested_block_key = ActiveSupport::Digest.hexdigest("#{block_location}:#{resource_user_key}") | |
# the store item (identified by block location, resource, and user) might already be present | |
store_item = Cubism.store[digested_block_key] || Cubism::BlockStoreItem.new( | |
block_location: block_location, | |
resource_gid: resource_gid, | |
user_gid: user_gid | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Seemingly I can't commit to an already merged PR though 🙈
Bug Fix
Description
Previously, blocks were fetched from a singleton which (obviously) cannot work across multiple processes.
This PR introduces a way to extract the actual ERB source of the cubism block via a
Preprocessor
and actually render it inline inBroadcaster
. Since kredis is in the picture already, it is used to store the block location, source, as well as resource and user IDs under a combined hashed key.