2016-11-09 11:52:09 +00:00
|
|
|
#ifndef OD_CLIENT_H_
|
|
|
|
#define OD_CLIENT_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* odissey.
|
|
|
|
*
|
|
|
|
* PostgreSQL connection pooler and request router.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct odclient_t odclient_t;
|
|
|
|
|
|
|
|
struct odclient_t {
|
2016-11-29 12:41:11 +00:00
|
|
|
mm_io_t io;
|
|
|
|
so_bestartup_t startup;
|
|
|
|
so_key_t key;
|
|
|
|
so_stream_t stream;
|
|
|
|
odserver_t *server;
|
|
|
|
void *pooler;
|
|
|
|
uint64_t id;
|
|
|
|
odlist_t link;
|
2016-11-09 11:52:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_clientinit(odclient_t *c)
|
|
|
|
{
|
2016-11-16 13:15:14 +00:00
|
|
|
c->id = 0;
|
2016-11-09 11:52:09 +00:00
|
|
|
c->io = NULL;
|
|
|
|
c->server = NULL;
|
2016-11-09 12:19:26 +00:00
|
|
|
c->pooler = NULL;
|
2016-11-10 12:15:46 +00:00
|
|
|
so_bestartup_init(&c->startup);
|
2016-11-16 13:15:14 +00:00
|
|
|
so_keyinit(&c->key);
|
2016-11-10 11:53:05 +00:00
|
|
|
so_stream_init(&c->stream);
|
2016-11-09 11:52:09 +00:00
|
|
|
od_listinit(&c->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline odclient_t*
|
|
|
|
od_clientalloc(void)
|
|
|
|
{
|
|
|
|
odclient_t *c = malloc(sizeof(*c));
|
|
|
|
if (c == NULL)
|
|
|
|
return NULL;
|
|
|
|
od_clientinit(c);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_clientfree(odclient_t *c)
|
|
|
|
{
|
2016-11-10 12:15:46 +00:00
|
|
|
so_bestartup_free(&c->startup);
|
2016-11-10 11:53:05 +00:00
|
|
|
so_stream_free(&c->stream);
|
2016-11-09 11:52:09 +00:00
|
|
|
free(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|