mongodb_connection.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Copyright (C) 2014 Daniel-Constantin Mierla (asipto.com)
  3. *
  4. * This file is part of Kamailio, a free SIP server.
  5. *
  6. * Kamailio is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * Kamailio is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. *
  20. */
  21. #ifndef _MONGODB_CONNECTION_H_
  22. #define _MONGODB_CONNECTION_H_
  23. #include <mongoc.h>
  24. #include <bson.h>
  25. #include "../../lib/srdb1/db_pool.h"
  26. #include "../../lib/srdb1/db_id.h"
  27. typedef struct km_mongodb_con {
  28. struct db_id* id; /*!< Connection identifier */
  29. unsigned int ref; /*!< Reference count */
  30. struct pool_con* next; /*!< Next connection in the pool */
  31. mongoc_client_t *con; /*!< Connection representation */
  32. mongoc_collection_t *collection; /*!< Collection link */
  33. mongoc_cursor_t *cursor; /*!< Cursor link */
  34. bson_t *colsdoc; /*!< Names of columns */
  35. int nrcols; /*!< Nunmber of columns */
  36. } km_mongodb_con_t;
  37. #define MONGODB_CON(db_con) ((km_mongodb_con_t*)((db_con)->tail))
  38. km_mongodb_con_t* db_mongodb_new_connection(const struct db_id* id);
  39. void db_mongodb_free_connection(struct pool_con* con);
  40. #endif