On Tuesday, July 10, 2012 3:30:56 AM UTC-4, Grigori Kochanov wrote:
Hi,
Matt, thanks a lot for ideas,I am afraid to execute JS from a request because API will be open for the untrusted sources and the service is money-related.
Couldn't agree more, just offering it as a thought if you need a rule engine without having to create your own syntax.
I did not quite understand how to implement the idea with another json-rpc service along side of the main one.
How can I manage the methods in a batch request in one service with a request to another service?
None of this would use batch in the json-rpc spec. Batch is very much a 'execute this set of requests', it does not impose any control flow around them.
If you need that control flow, it is best implemented in another method that has the flow coded into it. Or like you suggested in your first post, accepts a logic structure to follow in making the actual calls.
Service A would contain all the individual calls you would want to make (createCustomer, setBillingAddress, setShippingAddress, addProductToCart, etc.).
Service B would contain your logic structured calls (i.e. createFullCustomerWithProducst(createCustomer_Data, [addProductToCart_Data, addProductToCart_Data]) ).
Service B's methods would take more complex data payloads and implement the logic of calling createCustomer, setBillingAddress, etc. in Service A.
Having Service B removes the need for the client supply a complex logic structure, and just a call an implemented logic structure, albeit still segmented from A's primary methods. A and B could be in the same service, but I just wanted to show the difference. Instead of having the client supply the structure, implement it inside of Service B.
Giving the client the ability to supply that structure and then having to also limit what gets done as a result of that structure is a lot of work if you don't need the flexibility. Issues to consider when parsing a client supplied logic structure (code in essence): prevent infinite loops, prevent sequence calls that don't make sense contextual sense, unexpected injection of bad data from failed prior calls in the chain, chain call recovery, etc.