2016-11-11 09:26:55 +00:00
|
|
|
#ifndef OD_ROUTE_H_
|
|
|
|
#define OD_ROUTE_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* odissey.
|
|
|
|
*
|
|
|
|
* PostgreSQL connection pooler and request router.
|
|
|
|
*/
|
|
|
|
|
2016-11-29 13:19:12 +00:00
|
|
|
typedef struct od_route_t od_route_t;
|
2016-11-11 09:26:55 +00:00
|
|
|
|
2016-11-29 13:19:12 +00:00
|
|
|
struct od_route_t {
|
2016-11-29 13:09:16 +00:00
|
|
|
od_schemeroute_t *scheme;
|
2016-11-29 13:18:16 +00:00
|
|
|
od_routeid_t id;
|
2016-11-29 13:17:16 +00:00
|
|
|
od_serverpool_t server_pool;
|
2017-02-02 11:30:31 +00:00
|
|
|
od_clientpool_t client_pool;
|
2017-02-21 10:53:02 +00:00
|
|
|
od_stat_t stats;
|
2016-11-29 13:03:39 +00:00
|
|
|
od_list_t link;
|
2016-11-11 09:26:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
2016-11-29 13:19:12 +00:00
|
|
|
od_routeinit(od_route_t *route)
|
2016-11-11 09:26:55 +00:00
|
|
|
{
|
2016-11-11 10:42:30 +00:00
|
|
|
route->scheme = NULL;
|
|
|
|
od_routeid_init(&route->id);
|
2016-11-11 09:26:55 +00:00
|
|
|
od_serverpool_init(&route->server_pool);
|
2017-02-02 11:30:31 +00:00
|
|
|
od_clientpool_init(&route->client_pool);
|
2017-02-21 10:53:02 +00:00
|
|
|
od_stat_init(&route->stats);
|
2016-11-11 09:26:55 +00:00
|
|
|
od_listinit(&route->link);
|
|
|
|
}
|
|
|
|
|
2016-11-29 13:19:12 +00:00
|
|
|
static inline od_route_t*
|
2016-11-11 09:26:55 +00:00
|
|
|
od_routealloc(void) {
|
2016-11-29 13:19:12 +00:00
|
|
|
od_route_t *route = malloc(sizeof(*route));
|
2016-11-11 09:26:55 +00:00
|
|
|
if (route == NULL)
|
|
|
|
return NULL;
|
|
|
|
od_routeinit(route);
|
|
|
|
return route;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2016-11-29 13:19:12 +00:00
|
|
|
od_routefree(od_route_t *route)
|
2016-11-11 09:26:55 +00:00
|
|
|
{
|
2016-11-11 10:42:30 +00:00
|
|
|
od_routeid_free(&route->id);
|
2016-11-11 09:26:55 +00:00
|
|
|
od_serverpool_free(&route->server_pool);
|
|
|
|
free(route);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|