I've created vapi for gearmand ( http://gearman.org/ ) library, in short, it's a job server/client with bindings to almost every popular language.
As i'm new to Vala i will appreciate if anyone checks vapi and find
errors or gives some advice on better syntax.
Thanks.
Example of use (assuming --pkg gearmand):
using Gearman;
void testClient ()
{
stdout.printf ("Running client \n");
var client = Gearman.Client ();
client.add_server ("localhost", 4730);
Gearman.ReturnError? rc;
size_t? result_size;
void * value = client.do("reverse", "unique_value",
"my string to
reverse", "my string to reverse".length,
out result_size, out
rc);
string *result = value;
stdout.printf ("Result: %s \n", result);
}
void testWorker ()
{
stdout.printf ("Running worker \n");
var worker = Gearman.Worker ();
worker.add_server ("localhost", 4730);
ReturnError ret = worker.add_function("reverse", 0, reverse, null);
while (true)
{
worker.work();
}
}
void main (string[] args)
{
stdout.printf ("Gearman version: %s\n", Gearman.Version);
if (args[1] == "worker")
testWorker ();
else
testClient ();
}
void * reverse (Gearman.Job job, void * context, size_t size, ReturnError ret)
{
string *str = job.workload();
string result = str->reverse();
job.send_complete(result, result.length);
stdout.printf ("Request: '%s'\n", str);
stdout.printf ("Result: '%s'\n", result);
return null;
}
gearmand.vapi
Description: Binary data
_______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
