I've been working on improving the c_glib implementation with the goal
of being able to use Cassandra from Vala, C, and languages supported by
GObject Introspection.  Unfortunately, I've come to realize that there
are some issues with the c_glib implementation which can't really be
resolved without backwards-incompatible API changes to both the library
and the code generated by the compiler.

I'm willing to do the work to make those changes happen (and help
maintain the resulting API), but I don't want to write the code until I
know that people are willing to break backwards compatibility, or create
a new implementation based on GLib/GObject/GIO and deprecate c_glib.

I think the easiest way to see what I'm talking about is to look at an
example, so here is the function generated for executing a prepared
statement in Cassandra:

        gboolean
        cassandra_cassandra_client_execute_prepared_cql_query (
          CassandraCassandraIf * iface,
          CassandraCqlResult ** _return,
          const gint32 itemId,
          const GPtrArray * values,
          CassandraInvalidRequestException ** ire,
          CassandraUnavailableException ** ue,
          CassandraTimedOutException ** te,
          CassandraSchemaDisagreementException ** sde,
          GError ** error);

The most obvious issue is that Thrift exceptions are not GErrors, which
means that after executing the function, in addition to checking error
for problems, you also need to check ire, ue, te, and sde.

Next, it returns a boolean instead of what the Cassandra thrift file
specified (that second argument, _return, is what Cassandra wants us to
return).

This function should be generated as

        CassandraCqlResult *
        cassandra_cassandra_execute_prepared_cql_query (
          CassandraCassandra * cassandra,
          const gint32 itemId,
          const GPtrArray * values,
          GError ** error);

You get all the same information, but it's *much* easier to access.  (I
know the CassandraCassandra thing is a little weird, but that's just
because of a Cassandra service in a Cassandra namespace.  Not much can
be done about that.)

There is also the issue of moving to GIO, which would provide almost
free support for things like

      * TLS
      * Compression
      * Things other than TCP (UDP, UNIX domain sockets, in-memory
        buffers, etc.)
      * DNS-SD, on both clients and servers
      * Asynchronous operations
      * Cancellable operations
      * Buffered I/O
      * Multi-threaded servers

I know that most of those things can be accomplished with the existing
API (and the last two already are), but to be honest it's a bit of a
pain (especially in C), and integrating tightly with GIO could make it
trivial.

There are also many more minor issues.  You may have noticed that I
changed "CassandraCassandraIf *" to "CassandraCassandra *" above.
GObject properties, and implementation details, are exposed publicly as
fields when they shouldn't be.  Here is what a string constant looks
like in the code generated by the compiler:

        #define CASSANDRA_VERSION g_strdup ("19.24.0")

So, what do you think?  Is it time to break backwards compatibility?


-Evan

Reply via email to