dbcl_data.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * $Id$
  3. *
  4. * DB CLuster core functions
  5. *
  6. * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com)
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. /*! \file
  25. * \brief DB_CLUSTER :: Core
  26. * \ingroup db_cluster
  27. * Module: \ref db_cluster
  28. */
  29. #ifndef _DBCL_DATA_H_
  30. #define _DBCL_DATA_H_
  31. #include "../../lib/srdb1/db.h"
  32. #include "../../str.h"
  33. #define DBCL_PRIO_SIZE 10
  34. #define DBCL_CLIST_SIZE 5
  35. #define DBCL_CON_INACTIVE 1
  36. typedef struct dbcl_shared
  37. {
  38. int state;
  39. unsigned int aticks;
  40. } dbcl_shared_t;
  41. typedef struct dbcl_con
  42. {
  43. str name;
  44. unsigned int conid;
  45. str db_url;
  46. db1_con_t *dbh;
  47. db_func_t dbf;
  48. int flags;
  49. dbcl_shared_t *sinfo;
  50. struct dbcl_con *next;
  51. } dbcl_con_t;
  52. typedef struct dbcl_cdata
  53. {
  54. dbcl_con_t *clist[DBCL_CLIST_SIZE];
  55. int clen;
  56. int prio;
  57. int mode;
  58. int crt;
  59. } dbcl_cdata_t;
  60. typedef struct dbcl_cls
  61. {
  62. str name;
  63. unsigned int clsid;
  64. unsigned int ref;
  65. dbcl_cdata_t rlist[DBCL_PRIO_SIZE];
  66. dbcl_cdata_t wlist[DBCL_PRIO_SIZE];
  67. dbcl_con_t *usedcon;
  68. struct dbcl_cls *next;
  69. } dbcl_cls_t;
  70. int dbcl_init_dbf(dbcl_cls_t *cls);
  71. int dbcl_init_connections(dbcl_cls_t *cls);
  72. int dbcl_close_connections(dbcl_cls_t *cls);
  73. dbcl_cls_t *dbcl_get_cluster(str *name);
  74. int dbcl_valid_con(dbcl_con_t *sc);
  75. int dbcl_inactive_con(dbcl_con_t *sc);
  76. int dbcl_parse_con_param(char *val);
  77. int dbcl_parse_cls_param(char *val);
  78. #endif /* KM_DBASE_H */