2018-08-28 14:43:46 +00:00
|
|
|
#ifndef ODYSSEY_ROUTER_H
|
|
|
|
#define ODYSSEY_ROUTER_H
|
2017-05-26 12:17:45 +00:00
|
|
|
|
|
|
|
/*
|
2018-03-12 14:03:15 +00:00
|
|
|
* Odyssey.
|
2017-05-26 12:17:45 +00:00
|
|
|
*
|
2018-04-04 13:19:58 +00:00
|
|
|
* Scalable PostgreSQL connection pooler.
|
2020-04-02 11:00:56 +00:00
|
|
|
*/
|
2017-05-26 12:17:45 +00:00
|
|
|
|
|
|
|
typedef struct od_router od_router_t;
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
struct od_router {
|
2018-12-06 14:23:15 +00:00
|
|
|
pthread_mutex_t lock;
|
2020-11-23 09:13:28 +00:00
|
|
|
|
2020-04-02 11:00:56 +00:00
|
|
|
od_rules_t rules;
|
2018-12-06 14:23:15 +00:00
|
|
|
od_route_pool_t route_pool;
|
2020-11-23 09:13:28 +00:00
|
|
|
/* clients */
|
2019-10-10 10:00:33 +00:00
|
|
|
od_atomic_u32_t clients;
|
2019-10-15 14:15:37 +00:00
|
|
|
od_atomic_u32_t clients_routing;
|
2020-11-23 09:13:28 +00:00
|
|
|
/* servers */
|
2020-01-23 06:22:58 +00:00
|
|
|
od_atomic_u32_t servers_routing;
|
2020-11-23 09:13:28 +00:00
|
|
|
/* error logging */
|
2020-07-08 06:26:17 +00:00
|
|
|
od_error_logger_t *router_err_logger;
|
2020-11-23 09:13:28 +00:00
|
|
|
/* router has type of list */
|
|
|
|
od_list_t servers;
|
2017-05-26 12:17:45 +00:00
|
|
|
};
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
#define od_router_lock(router) pthread_mutex_lock(&router->lock);
|
2020-10-27 08:47:25 +00:00
|
|
|
#define od_router_unlock(router) pthread_mutex_unlock(&router->lock);
|
2017-05-26 12:17:45 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
void od_router_init(od_router_t *);
|
|
|
|
void od_router_free(od_router_t *);
|
2021-01-21 11:24:43 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
int od_router_reconfigure(od_router_t *, od_rules_t *);
|
|
|
|
int od_router_expire(od_router_t *, od_list_t *);
|
|
|
|
void od_router_gc(od_router_t *);
|
|
|
|
void od_router_stat(od_router_t *, uint64_t, od_route_pool_stat_cb_t, void **);
|
2021-01-21 11:24:43 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
extern int od_router_foreach(od_router_t *, od_route_pool_cb_t, void **);
|
2017-06-01 09:28:23 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
od_router_status_t od_router_route(od_router_t *router, od_client_t *client);
|
2017-05-27 13:14:39 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
void od_router_unroute(od_router_t *, od_client_t *);
|
2017-05-31 10:49:12 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
od_router_status_t od_router_attach(od_router_t *, od_client_t *, bool);
|
|
|
|
void od_router_detach(od_router_t *, od_client_t *);
|
|
|
|
void od_router_close(od_router_t *, od_client_t *);
|
2017-05-30 15:04:59 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
od_router_status_t od_router_cancel(od_router_t *, kiwi_key_t *,
|
|
|
|
od_router_cancel_t *);
|
2018-12-06 14:23:15 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
void od_router_kill(od_router_t *, od_id_t *);
|
2017-05-30 11:34:08 +00:00
|
|
|
|
2020-07-08 06:26:17 +00:00
|
|
|
static inline int
|
|
|
|
od_route_pool_stat_err_router(od_router_t *router,
|
2020-12-28 10:43:31 +00:00
|
|
|
od_route_pool_stat_route_error_cb_t callback,
|
|
|
|
void **argv)
|
2020-07-08 06:26:17 +00:00
|
|
|
{
|
|
|
|
return callback(router->router_err_logger, argv);
|
|
|
|
}
|
|
|
|
|
2018-08-28 14:43:46 +00:00
|
|
|
#endif /* ODYSSEY_ROUTER_H */
|