odissey: add route object

This commit is contained in:
Dmitry Simonenko 2016-11-11 12:26:55 +03:00
parent 60a8edc212
commit 1645bb694c
1 changed files with 50 additions and 0 deletions

50
core/od_route.h Normal file
View File

@ -0,0 +1,50 @@
#ifndef OD_ROUTE_H_
#define OD_ROUTE_H_
/*
* odissey.
*
* PostgreSQL connection pooler and request router.
*/
typedef struct odroute_t odroute_t;
struct odroute_t {
odscheme_route_t *route;
odserver_pool_t server_pool;
char *user;
int user_len;
char *database;
int database_len;
odlist_t link;
};
static inline void
od_routeinit(odroute_t *route)
{
route->route = NULL;
route->user = NULL;
route->user_len = 0;
route->database = NULL;
route->datababase_len = 0;
od_serverpool_init(&route->server_pool);
od_listinit(&route->link);
}
static inline odroute_t*
od_routealloc(void) {
odroute_t *route = malloc(sizeof(*route));
if (route == NULL)
return NULL;
od_routeinit(route);
return route;
}
static inline void
od_routefree(odroute_t *route)
{
od_serverpool_free(&route->server_pool);
free(route);
}
#endif