The Ur/Web runtime system represents asynchronous channels for message passing between clients with an ID that is generated by the when a new channel is allocated, and uses this for example when you insert a 'channel' into the database. Would it be possible to move this channel generation into the database itself, perhaps with a sequence or something similar?
My motivation is this: I have this fancy little perl script here that uploads and runs multiple Ur/Web applications across several hosts transparently (via ssh) and load balances them with an HTTP proxy automatically. So it basically just allows you to shoot a compiler-generated .exe to a few places and the main system takes care of balancing in a very simplistic manner. It's reminiscent of a script in the Opa distribution that does something similar (although perl > bash.) This all works out very well in fact! It works well when using regular SQL tables, postgres or mysql, and ajax and all the stuff that *should* work, does work. But because of the ID generation in the runtime system (read: per process,) I can't make applications that use message passing work at all, because multiple executables will step over each others channel IDs when clients connect. Chronologically: 1. Start two processes, on port 8081 and 8082. Both connect to the same database. 2. Client 1 visits HTTP proxy. Redirects them to process on port 8081. 3. Port 8081 process generates a new channel for the client connection and stuffs it in the database for further use. This is the first client, so the runtime system increments a counter and gives this channel an ID of 1. 4. Client 2 visits HTTP proxy. Directs them to process on port 8082. 5. Port 8082 process generates a new channel ID for the client connection, but it *also* generates 1 and tries to insert it into the *same* database. 6. Insert error (Channel ID already in use.) Process goes bye-bye. Now perhaps it's just the structure of my application (a table with one field of type 'client int' which is a PRIMARY KEY,) that makes this so obvious, but I think the general problem remains that multiple instances will step on each others toes one way or another with IDs which they attempt to insert as each process will generate the same IDs independently. I believe the same will basically apply to client IDs as well since they're generated in a similar manner. So is it feasible/possible to move this ID generation for clients/channels into the DB and/or compiler, so multiple connected instances can be coherent? I guess it's worth asking if this is even considered a valid use case or if it's feasible at all given the current design. Channels/client IDs are probably only really useful when you're using a database engine to store them anyway. I just threw the script together over the course of the day to see if the idea would actually work. It mostly does, but this sorta makes it non-workable at the moment for anything beyond non-trivial/not aware of it. It'd be pretty neat if it could work 100%, though. -- Regards, Austin _______________________________________________ Ur mailing list [email protected] http://www.impredicative.com/cgi-bin/mailman/listinfo/ur
