odyssey/core/od_client.h

61 lines
1.0 KiB
C
Raw Normal View History

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 od_client_t od_client_t;
2016-11-09 11:52:09 +00:00
struct od_client_t {
2017-01-24 11:01:36 +00:00
mm_io_t io;
2017-01-24 13:38:59 +00:00
od_schemeuser_t *scheme;
2017-01-24 11:01:36 +00:00
so_bestartup_t startup;
so_key_t key;
so_stream_t stream;
od_server_t *server;
2017-02-02 09:27:31 +00:00
void *route;
2017-01-24 11:01:36 +00:00
void *pooler;
uint64_t id;
2017-02-02 09:27:31 +00:00
od_list_t link_queue;
2017-01-24 11:01:36 +00:00
od_list_t link;
2016-11-09 11:52:09 +00:00
};
static inline void
od_clientinit(od_client_t *c)
2016-11-09 11:52:09 +00:00
{
c->io = NULL;
2017-01-24 13:38:59 +00:00
c->scheme = NULL;
2017-01-24 11:01:36 +00:00
c->id = 0;
2016-11-09 11:52:09 +00:00
c->server = NULL;
c->route = NULL;
2016-11-09 12:19:26 +00:00
c->pooler = NULL;
so_bestartup_init(&c->startup);
so_keyinit(&c->key);
so_stream_init(&c->stream);
2017-02-02 09:27:31 +00:00
od_listinit(&c->link_queue);
2016-11-09 11:52:09 +00:00
od_listinit(&c->link);
}
static inline od_client_t*
2016-11-09 11:52:09 +00:00
od_clientalloc(void)
{
od_client_t *c = malloc(sizeof(*c));
2016-11-09 11:52:09 +00:00
if (c == NULL)
return NULL;
od_clientinit(c);
return c;
}
static inline void
od_clientfree(od_client_t *c)
2016-11-09 11:52:09 +00:00
{
so_bestartup_free(&c->startup);
so_stream_free(&c->stream);
2016-11-09 11:52:09 +00:00
free(c);
}
#endif