Roadmap for 0.1.0-alpha in Valum
0.0.1
is far behind what will be introduced in 0.1.0-alpha
. This release
will bring new features and API improvements.
We are releasing a new alpha since the first version was a working but incomplete prototype.
Along with the changes already introduced, the release will be ready as soon as the following will be done:
- merge complete FastCGI integration in the trunk, which include integration of
GLib.Application
in the server design - api documentation (improvments and merge of
valadoc
branch) - improve user documentation
- more tests and a measured coverage with gcov
Integration of GLib.Application
is really cool. It basically provide any
written application with a GLib.MainLoop
to process asynchronous tasks and
signals to handle startup and shutdown events right from the Server
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using Valum;
using VSGI.Soup;
var app = new Router ();
var server = new Server (app);
// unique identifier for your application
app.set_application_id ("your.unique.application.id");
app.get("", (req, res) => {
res.write ("Hello world!".data);
});
server.startup.connect (() => {
// no request have been processed yet
// initialize services here (eg. database, memcached, ...)
});
server.shutdown.connect (() => {
// called after the mainloop finished
// all requests have been processed
});
server.run ();
Moreover, application can access a DBusConnection
and obtain environment data
or request external services.
This sample uses the org.freedesktop.hostname
DBus service to obtain
information about the hosting environment. Note that you can use DBus to
perform IPC between workers
fairly easily in Vala.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var connection = server.get_dbus_connection ();
app.get ("hostname", (req, res) => {
// asynchronous dbus call
connection.call.begin (
"org.freedesktop.hostname", // bus name
"/org/freedesktop/hostname", // object path
"org.freedesktop.hostname", // interface
"Hostname",
null, // no arguments
VariantType.STRING, // return type
DBusCallFlags.NONE,
-1, // timeout
null,
(obj, r) => {
var hostname = connection.call.end (r);
res.write (hostname.get_string ().data);
});
});
GLib.Application are designed to be held and released so that it can quit automatically whenever it’s idle (with a possible timout). Gtk uses it to count the number of opened windows, we use it to measure the number of processing requests.
Past a certain timeout after the last release, the worker will terminate.
If you have a long-running operation to process asynchronously that does not involve writting the response (in which case, you are better blocking), you have to hold the application to keep it alive while it’s processing.
What next?
The next release will be more substantial:
- middlewares
- components (if relevant)
- improve VSGI specification
- more signals to handle external events
- better documentation to guide implementations
- new VSGI implementations (SCGI & CGI)
- extract VSGI (if ready)
I decided to go ahead for a Mustache implementation that targets GLib and GObject. I’m still surprised that it hasn’t been done yet. It is clearly essential to bring Vala in general purpose web development. The development will be in a separate project here on GitHub and it will not block the release of the framework.
GResource API is really great and it would be truly amazing to bundle Mustache templates like we already do with CTPL.