-
Notifications
You must be signed in to change notification settings - Fork 71
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
UUID to Fedora Path does not work inside transactions #185
Comments
I am trying to think how you can resolve this in any fashion? Do we use a SQLite db? We would need to handle transactions as well as regular resources. So In a transaction, the above returns a transaction prefixed path, so we use that until the transaction is committed (or rolled back) then we need to update with the un-prefixed path. How do we deal with abandoned transactions? Add a timestamp and update it for each action on a transaction, wipe them after N minutes of inactivity? |
Or we could submit our own quad to the triplestore from the microservices. Once it is committed or rolledback we can delete it as either:
Also we don't have to change the behaviour for normal actions, only items created in transactions. |
The advantage of using the triplestore for this seems mostly to be the fact that the triplestore already exists in the infrastructure. For this particular session-based interaction, I'd highly recommend using something like Redis that already supports key expiry. Also, all operations are entirely atomic, which means one less thing to worry about in a distributed context. The downside is that it's one more thing to install and keep running. |
Thanks @acoburn, I figured there would be something out there. Redis looks very simple and easy. I'll see about implementing it as simple key (UUID) value (fedora path) pair for now. |
Okay, so I played around with this for a bit and I have two problems. I have solutions but I'm sure there are better ways. So let me know if I am crazy or if you have a suggestion.
So I think it is probably easiest to generate a JSON list of values ala:
Then store that in Redis with the transaction ID as the key
This would mean we would pull the entire object for each action on a transaction, but I think it is the easiest as we set a single expiry in Redis and update it if the transaction is acted upon.
So I am thinking about a super simple transform like:
So after an object is created in Fedora we can get the transform
This gives us the path and UUID in a simple JSON-LD object. Which we add using the data structure in 1. Thoughts? |
That makes sense to me. |
Hi sadly stil on the train and i have a lot of thoughts on this. How will you manage a tx session that expired or was rolled back, will to clean that how from reddis? If we are keeping resources involved in a transaction checked (means we keep track on them) there are a lot of better/faster ways than reddis right now (on year 2016) so we could maybe explore the options/discuss them before going further with this? Also, since we are passing TX around, assuming all resources belonging in a common tx will be done using the same client/server pair(means coming from the same source and using the same microservice..i hope we are not try resolve right now multi service same tx) we can simply make use of cookies and headers right? We can even use silex/symphony caching options to avoid putting yet.another.service right now to maintain. Train moves a lot!. |
So the idea is that Redis allows you to add an expiry to your entries. So if nothing happens on them then they are automatically removed. I would also only use this for actions in a transaction and as a fail-over from the triplestore, because I would like to have the triplestore as the main source of this information. I am dealing only within a single transaction, but if you had two clients using the same transaction ID. Then they could refer to objects the other generated as they would both get back the same object from Redis. Changes that each makes, might cause a problem however. I am abstracting this with an interface so we should be able to put any implementation behind it that you want. So if you've got a better one, we can happily make that the default. Redis seems like a nice easy solution for now. |
This is very early, but just to give an idea of what I was thinking. |
Also, that doesn't do anything special (hence the name KeyCache). It could be made specialized and have it deal with the intricacies of the information internally. For example: |
@DiegoPino I have a problem. Where this keyCache would be useful is inside the idToUri. So if the triplestore query returns 0 rows then check the keyCache. But I need access to the transaction ID. We could pass the TX ID in each time, but is there another way to access the Request? |
@whikloj, of course. (Convert callbacks can be also services, but i suspect you don't like services so much! 👍 ) |
Okay, so here are the 3 for this now.
The cache is super simple, but the idea is you could easily replace it with APC, Memcache, Redis, etc using the same (https://github.com/moust/silex-cache-service-provider) library. |
Found also an extra use for you cache Jared... in the future we could even block a resource to be touched by another TX or direct call if it's in the cache. Good work! |
We might want to refactor the cache, and namespace the different caches then. Like have my UuidCache class prepend "uuidcache:" to the keys. To allow for multiple separate caches. |
cool, next sprint |
The idea of using a UUID matched via the triplestore to a fedora path assumes that it is indexed. In the case of a transaction, nothing is done until the transaction is committed.
So...
@Islandora-CLAW/7-x-2-x-committers : Ideas?
The text was updated successfully, but these errors were encountered: