Steve Singer steve at ssinger.info
Sun Jul 26 19:03:12 PDT 2015
During the slony session at the PGCON unconference some people asked 
about an API so they could manipulate slony clusters without having to 
call slonik.

I've done a draft attempt at moving slonik functionality into a library.

You can view my draft API here
https://github.com/ssinger/slony1-engine/blob/libslonik/src/slonik/slonik_api.h

A sample program that uses it might look like

        struct SlonikContext * context;

         SlonikApi_NodeConnInfo n1;
         n1.no_id=1;
         n1.conninfo="host=localhost dbname=test1 port=5435";
         SlonikApi_NodeConnInfo ** n_list =malloc(sizeof( 
SlonikApi_NodeConnInfo *)*2);
         n_list[0]=&n1;
         n_list[1]=NULL;
         context = slonik_api_init_context("disorder_replica",n_list);
         slonik_api_sync(context,1);
         slonik_api_subscribe_set(context,1,1,2,0,0);


The idea is that you would setup a structure with the conninfo 
configuration and init your slony context.  You would then pass this 
context to the function call for the slonik command you want to call.

I'd like to get a sense of how people feel about this API.

If we like the API in general then we still need to figure out how to 
deal with error reporting.  The library still prints errors and messages 
to stdout which isn't ideal for an API.  We could either pass a file 
stream to the context or use callback functions

I haven't yet added support for try blocks but I think that would be 
straightforward to do. I also need to make slonik statically link with 
the library.

I have only done limited testing so far.  If we like this API I will 
then write wrappers to allow the Java JVM to call into libslonik and add 
some tests to the slony test framework.


More information about the Slony1-general mailing list