Giter Club home page Giter Club logo

Comments (10)

freemo avatar freemo commented on June 26, 2024 1

from goblin.

freemo avatar freemo commented on June 26, 2024 1

Side note (ill repost this on the relevant ticket as well). The fork I have going locally adds transaction support though likely not in the way the original ask intended, but I think the only elegant way possible given the underlying gremlin implementation.

Basically I took advantage of the fact that the only way to get a traversal is either 1) use the raw driver and pass text-based traversals through it (unless im mistaken this is impractical for an OGM, though maybe I'm missing something). 2) Treat each traversal itself as its own transaction and accept that you cant manually create transactions that spread across multiple invocations of traversals (this appears to be the official answer)

So I decided to exploit feature #2 and implement a sort of optimistic locking that works with one caveat, it is only useful when adding new edges and nodes it isnt useful for modifying them in place. This may seem like a big caveat, and it is, but it also is useful when along side another feature I implemented: per-element immutability. In that case if an element is set as immutable then it can be created, but never destroyed nor modified after its initial creation.When these two new features I added are used in tandem you basically get something that is basically optimistic locking that works on immutable graphs.

Let me explain further. Its very typical in immutable graphs that you still need to maintain integrity. This means that a single node or edge may be inconsistent on its own and only makes sense when connected in a valid pattern, a simple example being a graph that must be connected to be valid. As such you may want to create a set of edges and nodes but with the guarantee they either all get created or none of them. Thus the optimistic locking I mentioned.

How it works:

I created a new attribute on Element classes called __immutable__ which takes an enum that has one of three values: {OFF, SIMPLE, TRANSACTIONAL}. When the value is OFF it behaves classically, this is also the default value if nothing is set. SIMPLE only creates immutability but makes not transactional guarantees. TRANSACTIONAL gives the combined functionality of both I mentioned. When this mode is set then transactions occur automatically through the flush method. Whenever a flush occurs a randomly generated UUID is created as a transaction identifier. Then all element updates throw an exception and only allow element creation. When being created every element is given a property called "dirty" which contains the transaction ID. If all saved elements succeed to write to them database then a final traversal is called, written especially a single traversal, which will drop the property dirty from all elements where the ID is matched, this effectively makes the edges and nodes live. However if an exception occurs a rollback traversal is called which drops all the dirty elements.

Finally at startup the system can call a method which scans the DB for any dirty values that may be left over from a crash and removed them as well.

Using this mechanism I was able to get guaranteed DB integrity. So far its only used in single-application-single-database configuration. But I plan to adopt it for multiple application front ends. For that I'd need to do some integrity checking as part of the commit traversal.

I can pull out the code for this if you are interested, right now its just something i use locally.

from goblin.

freemo avatar freemo commented on June 26, 2024 1

from goblin.

dekoza avatar dekoza commented on June 26, 2024 1

@freemo I'm sorry but your GitLab instance is failing. Is there any chance for a github mirror?

Also, the documentation is very lacking and sourcecode has confusing docstrings. There are also issues with from_dict methods and default param for Property. I'd love to post a PR but... your GitLab instance is failing.

from goblin.

freemo avatar freemo commented on June 26, 2024 1

from goblin.

freemo avatar freemo commented on June 26, 2024 1

from goblin.

davebshow avatar davebshow commented on June 26, 2024

from goblin.

dekoza avatar dekoza commented on June 26, 2024

Anything changed over the past months? I'd love to see this lib alive again and updated to support gremlinpython 3.4

from goblin.

dekoza avatar dekoza commented on June 26, 2024

@freemo thank you! The last question is - should I send PRs to gitlab only or is github also OK?

from goblin.

freemo avatar freemo commented on June 26, 2024

@freemo thank you! The last question is - should I send PRs to gitlab only or is github also OK?

@dekoza Gitlab is technically the official spot since its where I have all the CI setup. I will accept PR on github but its extra work/steps for me so I do prefer if you do it on gitlab if your willing.

from goblin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.