jadell / neo4jphp

PHP wrapper of the Neo4j REST interface
Other
533 stars 137 forks source link

async ? #41

Open stephaneerard opened 12 years ago

stephaneerard commented 12 years ago

Would it be possible to make this lib async using CURL multi ?

This lib might be of help https://github.com/ericmuyser/php-class-curl/blob/master/src/curl.php but there is still a need to run a ->update() in a while loop to gather returns... Which is faked async imo.

Any insight ?

Thanks !

jadell commented 12 years ago

I hadn't thought about it. What do you think the API for that might look like?

One thing to keep in mind is that every request will be wrapped in a transaction on the server side. So doing something like saving two nodes and then attaching them in a relationship might be difficult to do this way:

// This happens async
$nodeA->save(function () { ... });
// This happens async
$nodeB->save(function () { ... });
// If either of the first two calls don't return before this one, Bad Things will occur
$nodeA->relateTo($nodeB, 'FOO')->save(function (){ ... });

What problem are you trying to solve? If it's the case of too many server calls, perhaps batches are the way to go? Maybe we could make batches requests (where all the operations occur in the same transaction) async, but not the rest of the library?

I'm interested to hear any thoughts and ideas you have about this.