-
Notifications
You must be signed in to change notification settings - Fork 30
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
Base62 encoding for @user_id is problematic for namespacing #11
Comments
I've solved this for now by adding an activity_feed_key method to the model file for the resource:
Not ideal but works. |
When you define a feed you can optionally specify a namespace so that multiple feeds can be defined against a shared redis instance. Are you using the namespace when defining your feeds? Perhaps I misunderstand the problem. If you could paste the code that defines your feeds, and then also show how you are storing the keys that would be helpful. |
Also, have you seen this page that shows how you can implement base62 serialization? |
I'm using the namespace to differentiate between accounts and documents. This is my simplefeed.rb initializer:
The issue is that I want a unique namespace for each document, which is inside a tenant table, per account. The document namespace should be something like |
I still don't understand your case.
I am sorry for asking so many questions, but your use-case is really not clear to me, and without the context it's hard to visualize your requirements. If you can shed more light into this, and like I asked earlier, show examples of how you are reading from the feeds, and how you are writing to both feeds, that would make it possible for me to help you. Thanks! |
Another option is to show mockups of what you are building — feel free to email them to me. My address is my github username AT google' free email service. Thanks! |
I'm using the Apartment gem with Postgres. Every account has effectively has its own database (schema). There are resources that are in the public schema (accounts for example) and resources that are per-schema (documents for example). The account IDs are unique across the application, so I've had no problems creating activity feeds for accounts. I just use their ID to write to their feeds. The document IDs are only unique on a per-account basis. The first document in every account has an ID of 1. In order to keep the activity feeds for documents from polluting eachother, I have to namespace their feed id on a per-account basis. This is why I've needed this method on my document model:
When writing and reading to the feed, I use |
Thanks for this context, let me think about it. |
I think i'm missing some fundamental details. I havent used a bigint as an identifier in over a decade, i must be making incorrect assumptions when reading
|
Just coming back to this now that i'm much more familiar now. @kigster i think @archonic problem is a lot simpler than the discussion surrounding it. You can't pass a string into the activity initializer. This will fail every-time
It might be misleading because def uuid_as_bigint
UUID4(id).to_i
end
I'll dig into the source and figure out where my assumptions are incorrect. I'm not trying to do anything complicated with namespacing or event serialization, just trying to translate my identifiers |
This is great! And you are right, I think the code assumes integer data type for the user id. I’ll take a pass at confirming it, and if confirmed — switching it to a string, but don’t let me stop you :) |
yeah i just looked at the key template, i can actually easily provide my own base62 string direct from my uuid representation.
I'll try patching, i see specs so it should be straight forward for a modified signature that takes an already encoded identifier |
Thanks, everyone, for participating and especially to @rromanchuk for helping me understand the problem. I now fully get the issue, which comes down to:
SolutionHead over to #16 for the proposed solution and the corresponding PR #17 |
I'm using simple-feed in an application with apartment. I have 1 activity feed per resource in each account and don't want resources with the same ID to pollute feeds outside of their account. So I need to namespace the user_id. I've tried
#{account.id}_#{resource.id}
and#{account.id}x#{resource.id}
but both are hitting this error when storing the event:Do you know how I can safely namespace feeds into their account while satisfying base62 encoding? From what I've read, everything in
[a-z][A-Z][0-9]
should be safe but that's not what I'm seeing.The text was updated successfully, but these errors were encountered: