Knowing that the answer to the question in the subject is probably "don't 
do that", I'm looking for a way to support database-like transactions 
(i.e., event-loop atomic operations) spanning multiple server objects.

Here's a simplified schema to help explain the problem:

# A transaction holds a list of actions that should be processed in a single
# event-loop atomic operation.
struct Transaction {
    actions @0 :List(Action);
    
    struct Action {
        union {
            nop @0 :Void;
            execute @1 :Callable;
            #doSomething @2 :AnotherType;
            #etc...
        }
    }
}

# A callable is a server-side object conveying the capability of calling
# some server function as part of a transaction.
interface Callable { }

# Some other interface that serves callables (simplified example) and
# processes transactions.
interface Bootstrap {
    getCallable @0 (name :Text) -> (callable :Callable);
    
    process @1 (transaction :Transaction);
}

A client can obtain Callables from the server through e.g. the Bootstrap 
interface, and should then be able to pass that Callable as part of a 
Transaction back to the server. The Callable::Server implementation 
contains a std::function that should be called for any Callable that is 
executed as part of a transaction.

Unfortunately (although it totally makes sense), the Transaction Reader 
available in the Bootstrap implementation's process method only provides a 
Callable::Client, without a possibility (as far as I can tell) of 
retrieving the associated Callable::Server object. Thus it is not possible 
to retrieve nor call the std::function object associated with the Callable.

Adding a call method to the Callable interface would allow it to be called 
by the process method or directly by the client, but not (again as far as I 
can tell) in an event-loop atomic manner as part of a transaction.

I hope that the scenario above is understandable. If not I'd be more than 
happy to elaborate on points that are not clear.

Am I overlooking something that would allow somehow calling the 
std::function of a Callable implementation from within the process method? 
Does anyone have a different suggestion for achieving something like this?

I would like to avoid implementing a custom capability system that replaces 
Callable with a struct containing an id. But perhaps it is the only way?

Thanks!
Johannes

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/capnproto.

Reply via email to