2017-05-25 12:00:58 +00:00
|
|
|
#ifndef OD_ROUTE_H
|
|
|
|
#define OD_ROUTE_H
|
|
|
|
|
|
|
|
/*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Odissey.
|
2017-05-25 12:00:58 +00:00
|
|
|
*
|
2017-07-05 12:42:49 +00:00
|
|
|
* Advanced PostgreSQL connection pooler.
|
2017-05-25 12:00:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct od_route od_route_t;
|
|
|
|
|
|
|
|
struct od_route
|
|
|
|
{
|
2017-07-21 14:29:01 +00:00
|
|
|
od_schemeroute_t *scheme;
|
2017-05-25 12:00:58 +00:00
|
|
|
od_routeid_t id;
|
2017-08-11 10:24:41 +00:00
|
|
|
od_serverstat_t periodic_stats;
|
2017-08-11 14:19:32 +00:00
|
|
|
od_serverstat_t periodic_stats_avg;
|
2017-08-11 15:19:29 +00:00
|
|
|
int stats_mark;
|
2017-05-25 12:00:58 +00:00
|
|
|
od_serverpool_t server_pool;
|
|
|
|
od_clientpool_t client_pool;
|
|
|
|
od_list_t link;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_route_init(od_route_t *route)
|
|
|
|
{
|
|
|
|
route->scheme = NULL;
|
|
|
|
od_routeid_init(&route->id);
|
|
|
|
od_serverpool_init(&route->server_pool);
|
|
|
|
od_clientpool_init(&route->client_pool);
|
2017-08-11 15:19:29 +00:00
|
|
|
route->stats_mark = 0;
|
2017-08-11 10:24:41 +00:00
|
|
|
memset(&route->periodic_stats, 0, sizeof(route->periodic_stats));
|
2017-08-11 14:19:32 +00:00
|
|
|
memset(&route->periodic_stats_avg, 0, sizeof(route->periodic_stats_avg));
|
2017-05-25 12:00:58 +00:00
|
|
|
od_list_init(&route->link);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline od_route_t*
|
2017-06-29 14:05:48 +00:00
|
|
|
od_route_allocate(void)
|
|
|
|
{
|
2017-05-25 12:00:58 +00:00
|
|
|
od_route_t *route = malloc(sizeof(*route));
|
|
|
|
if (route == NULL)
|
|
|
|
return NULL;
|
|
|
|
od_route_init(route);
|
|
|
|
return route;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
od_route_free(od_route_t *route)
|
|
|
|
{
|
|
|
|
od_routeid_free(&route->id);
|
|
|
|
od_serverpool_free(&route->server_pool);
|
|
|
|
free(route);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* OD_ROUTE_H */
|