couchbase 4.2.3 → 4.2.5-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CMakeLists.txt +136 -11
  2. package/deps/couchbase-cxx-client/CMakeLists.txt +54 -4
  3. package/deps/couchbase-cxx-client/README.md +1 -0
  4. package/deps/couchbase-cxx-client/bin/create-search-index +164 -0
  5. package/deps/couchbase-cxx-client/bin/init-cluster +55 -10
  6. package/deps/couchbase-cxx-client/bin/run-unit-tests +62 -6
  7. package/deps/couchbase-cxx-client/bin/travel-sample-index-v6.json +184 -0
  8. package/deps/couchbase-cxx-client/bin/travel-sample-index.json +188 -0
  9. package/deps/couchbase-cxx-client/cmake/Documentation.cmake +0 -1
  10. package/deps/couchbase-cxx-client/cmake/OpenSSL.cmake +98 -3
  11. package/deps/couchbase-cxx-client/cmake/Testing.cmake +8 -0
  12. package/deps/couchbase-cxx-client/cmake/build_config.hxx.in +3 -0
  13. package/deps/couchbase-cxx-client/core/bucket.cxx +183 -152
  14. package/deps/couchbase-cxx-client/core/bucket.hxx +17 -4
  15. package/deps/couchbase-cxx-client/core/cluster.hxx +18 -1
  16. package/deps/couchbase-cxx-client/core/cluster_options.hxx +1 -0
  17. package/deps/couchbase-cxx-client/core/error_context/key_value.cxx +2 -1
  18. package/deps/couchbase-cxx-client/core/error_context/key_value.hxx +10 -12
  19. package/deps/couchbase-cxx-client/core/error_context/search.hxx +1 -1
  20. package/deps/couchbase-cxx-client/core/impl/analytics.cxx +1 -0
  21. package/deps/couchbase-cxx-client/core/impl/boolean_field_query.cxx +40 -0
  22. package/deps/couchbase-cxx-client/core/impl/boolean_query.cxx +62 -0
  23. package/deps/couchbase-cxx-client/core/impl/cluster.cxx +1 -0
  24. package/deps/couchbase-cxx-client/core/impl/conjunction_query.cxx +51 -0
  25. package/deps/couchbase-cxx-client/core/impl/date_range.cxx +89 -0
  26. package/deps/couchbase-cxx-client/core/impl/date_range_facet.cxx +54 -0
  27. package/deps/couchbase-cxx-client/core/impl/date_range_facet_result.cxx +64 -0
  28. package/deps/couchbase-cxx-client/core/impl/date_range_query.cxx +125 -0
  29. package/deps/couchbase-cxx-client/core/impl/disjunction_query.cxx +51 -0
  30. package/deps/couchbase-cxx-client/core/impl/encoded_search_facet.hxx +29 -0
  31. package/deps/couchbase-cxx-client/core/impl/encoded_search_query.hxx +29 -0
  32. package/deps/couchbase-cxx-client/core/impl/encoded_search_sort.hxx +29 -0
  33. package/deps/couchbase-cxx-client/core/impl/geo_bounding_box_query.cxx +46 -0
  34. package/deps/couchbase-cxx-client/core/impl/geo_distance_query.cxx +43 -0
  35. package/deps/couchbase-cxx-client/core/impl/geo_polygon_query.cxx +46 -0
  36. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.cxx +80 -0
  37. package/deps/couchbase-cxx-client/core/impl/internal_date_range_facet_result.hxx +48 -0
  38. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.cxx +80 -0
  39. package/deps/couchbase-cxx-client/core/impl/internal_numeric_range_facet_result.hxx +48 -0
  40. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.cxx +141 -0
  41. package/deps/couchbase-cxx-client/core/impl/internal_search_error_context.hxx +61 -0
  42. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.cxx +60 -0
  43. package/deps/couchbase-cxx-client/core/impl/internal_search_meta_data.hxx +41 -0
  44. package/deps/couchbase-cxx-client/core/impl/internal_search_result.cxx +84 -0
  45. package/deps/couchbase-cxx-client/core/impl/internal_search_result.hxx +43 -0
  46. package/deps/couchbase-cxx-client/core/impl/internal_search_row.cxx +82 -0
  47. package/deps/couchbase-cxx-client/core/impl/internal_search_row.hxx +56 -0
  48. package/deps/couchbase-cxx-client/core/impl/internal_search_row_location.hxx +32 -0
  49. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.cxx +137 -0
  50. package/deps/couchbase-cxx-client/core/impl/internal_search_row_locations.hxx +45 -0
  51. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.cxx +80 -0
  52. package/deps/couchbase-cxx-client/core/impl/internal_term_facet_result.hxx +48 -0
  53. package/deps/couchbase-cxx-client/core/impl/key_value_error_context.cxx +98 -0
  54. package/deps/couchbase-cxx-client/core/impl/match_all_query.cxx +35 -0
  55. package/deps/couchbase-cxx-client/core/impl/match_none_query.cxx +35 -0
  56. package/deps/couchbase-cxx-client/core/impl/match_phrase_query.cxx +43 -0
  57. package/deps/couchbase-cxx-client/core/impl/match_query.cxx +59 -0
  58. package/deps/couchbase-cxx-client/core/impl/numeric_range.cxx +49 -0
  59. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet.cxx +54 -0
  60. package/deps/couchbase-cxx-client/core/impl/numeric_range_facet_result.cxx +64 -0
  61. package/deps/couchbase-cxx-client/core/impl/numeric_range_query.cxx +56 -0
  62. package/deps/couchbase-cxx-client/core/impl/phrase_query.cxx +42 -0
  63. package/deps/couchbase-cxx-client/core/impl/prefix_query.cxx +40 -0
  64. package/deps/couchbase-cxx-client/core/impl/query_error_context.cxx +75 -0
  65. package/deps/couchbase-cxx-client/core/impl/query_string_query.cxx +37 -0
  66. package/deps/couchbase-cxx-client/core/impl/regexp_query.cxx +40 -0
  67. package/deps/couchbase-cxx-client/core/impl/search.cxx +191 -0
  68. package/deps/couchbase-cxx-client/core/impl/search_error_context.cxx +147 -0
  69. package/deps/couchbase-cxx-client/core/impl/search_meta_data.cxx +46 -0
  70. package/deps/couchbase-cxx-client/core/impl/search_result.cxx +66 -0
  71. package/deps/couchbase-cxx-client/core/impl/search_row.cxx +74 -0
  72. package/deps/couchbase-cxx-client/core/impl/search_row_location.cxx +64 -0
  73. package/deps/couchbase-cxx-client/core/impl/search_row_locations.cxx +66 -0
  74. package/deps/couchbase-cxx-client/core/impl/search_sort_field.cxx +104 -0
  75. package/deps/couchbase-cxx-client/core/impl/search_sort_id.cxx +43 -0
  76. package/deps/couchbase-cxx-client/core/impl/search_sort_score.cxx +43 -0
  77. package/deps/couchbase-cxx-client/core/impl/term_facet.cxx +36 -0
  78. package/deps/couchbase-cxx-client/core/impl/term_facet_result.cxx +64 -0
  79. package/deps/couchbase-cxx-client/core/impl/term_query.cxx +56 -0
  80. package/deps/couchbase-cxx-client/core/impl/term_range_query.cxx +57 -0
  81. package/deps/couchbase-cxx-client/core/impl/wildcard_query.cxx +40 -0
  82. package/deps/couchbase-cxx-client/core/io/mcbp_command.hxx +9 -2
  83. package/deps/couchbase-cxx-client/core/io/mcbp_session.cxx +54 -37
  84. package/deps/couchbase-cxx-client/core/io/mcbp_session.hxx +4 -3
  85. package/deps/couchbase-cxx-client/core/json_string.hxx +5 -0
  86. package/deps/couchbase-cxx-client/core/meta/version.cxx +18 -4
  87. package/deps/couchbase-cxx-client/core/mozilla_ca_bundle.hxx +39 -0
  88. package/deps/couchbase-cxx-client/core/operations/document_search.cxx +3 -1
  89. package/deps/couchbase-cxx-client/core/operations/document_search.hxx +1 -1
  90. package/deps/couchbase-cxx-client/core/protocol/client_request.hxx +11 -2
  91. package/deps/couchbase-cxx-client/core/protocol/client_response.hxx +1 -0
  92. package/deps/couchbase-cxx-client/core/utils/connection_string.cxx +59 -46
  93. package/deps/couchbase-cxx-client/core/utils/connection_string.hxx +1 -0
  94. package/deps/couchbase-cxx-client/couchbase/analytics_error_context.hxx +1 -1
  95. package/deps/couchbase-cxx-client/couchbase/boolean_field_query.hxx +77 -0
  96. package/deps/couchbase-cxx-client/couchbase/boolean_query.hxx +223 -0
  97. package/deps/couchbase-cxx-client/couchbase/cluster.hxx +39 -0
  98. package/deps/couchbase-cxx-client/couchbase/conjunction_query.hxx +88 -0
  99. package/deps/couchbase-cxx-client/couchbase/date_range.hxx +69 -0
  100. package/deps/couchbase-cxx-client/couchbase/date_range_facet.hxx +56 -0
  101. package/deps/couchbase-cxx-client/couchbase/date_range_facet_result.hxx +55 -0
  102. package/deps/couchbase-cxx-client/couchbase/date_range_query.hxx +265 -0
  103. package/deps/couchbase-cxx-client/couchbase/disjunction_query.hxx +109 -0
  104. package/deps/couchbase-cxx-client/couchbase/doc_id_query.hxx +111 -0
  105. package/deps/couchbase-cxx-client/couchbase/error_context.hxx +17 -8
  106. package/deps/couchbase-cxx-client/couchbase/fmt/analytics_scan_consistency.hxx +52 -0
  107. package/deps/couchbase-cxx-client/{core/topology/error_map_fmt.hxx → couchbase/fmt/key_value_error_map_attribute.hxx} +21 -21
  108. package/deps/couchbase-cxx-client/couchbase/fmt/search_scan_consistency.hxx +49 -0
  109. package/deps/couchbase-cxx-client/couchbase/geo_bounding_box_query.hxx +107 -0
  110. package/deps/couchbase-cxx-client/couchbase/geo_distance_query.hxx +109 -0
  111. package/deps/couchbase-cxx-client/couchbase/geo_point.hxx +32 -0
  112. package/deps/couchbase-cxx-client/couchbase/geo_polygon_query.hxx +85 -0
  113. package/deps/couchbase-cxx-client/couchbase/highlight_style.hxx +45 -0
  114. package/deps/couchbase-cxx-client/couchbase/key_value_error_context.hxx +7 -2
  115. package/deps/couchbase-cxx-client/couchbase/manager_error_context.hxx +1 -1
  116. package/deps/couchbase-cxx-client/couchbase/match_all_query.hxx +43 -0
  117. package/deps/couchbase-cxx-client/couchbase/match_none_query.hxx +43 -0
  118. package/deps/couchbase-cxx-client/couchbase/match_operator.hxx +45 -0
  119. package/deps/couchbase-cxx-client/couchbase/match_phrase_query.hxx +108 -0
  120. package/deps/couchbase-cxx-client/couchbase/match_query.hxx +163 -0
  121. package/deps/couchbase-cxx-client/couchbase/numeric_range.hxx +58 -0
  122. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet.hxx +56 -0
  123. package/deps/couchbase-cxx-client/couchbase/numeric_range_facet_result.hxx +55 -0
  124. package/deps/couchbase-cxx-client/couchbase/numeric_range_query.hxx +143 -0
  125. package/deps/couchbase-cxx-client/couchbase/phrase_query.hxx +93 -0
  126. package/deps/couchbase-cxx-client/couchbase/prefix_query.hxx +82 -0
  127. package/deps/couchbase-cxx-client/couchbase/query_error_context.hxx +3 -1
  128. package/deps/couchbase-cxx-client/couchbase/query_string_query.hxx +72 -0
  129. package/deps/couchbase-cxx-client/couchbase/regexp_query.hxx +82 -0
  130. package/deps/couchbase-cxx-client/couchbase/scope.hxx +39 -0
  131. package/deps/couchbase-cxx-client/couchbase/search_date_range.hxx +68 -0
  132. package/deps/couchbase-cxx-client/couchbase/search_error_context.hxx +138 -0
  133. package/deps/couchbase-cxx-client/couchbase/search_facet.hxx +60 -0
  134. package/deps/couchbase-cxx-client/couchbase/search_facet_result.hxx +50 -0
  135. package/deps/couchbase-cxx-client/couchbase/search_meta_data.hxx +85 -0
  136. package/deps/couchbase-cxx-client/couchbase/search_metrics.hxx +127 -0
  137. package/deps/couchbase-cxx-client/couchbase/search_numeric_range.hxx +69 -0
  138. package/deps/couchbase-cxx-client/couchbase/search_options.hxx +509 -0
  139. package/deps/couchbase-cxx-client/couchbase/search_query.hxx +69 -0
  140. package/deps/couchbase-cxx-client/couchbase/search_result.hxx +77 -0
  141. package/deps/couchbase-cxx-client/couchbase/search_row.hxx +104 -0
  142. package/deps/couchbase-cxx-client/couchbase/search_row_location.hxx +55 -0
  143. package/deps/couchbase-cxx-client/couchbase/search_row_locations.hxx +86 -0
  144. package/deps/couchbase-cxx-client/couchbase/search_scan_consistency.hxx +34 -0
  145. package/deps/couchbase-cxx-client/couchbase/search_sort.hxx +58 -0
  146. package/deps/couchbase-cxx-client/couchbase/search_sort_field.hxx +117 -0
  147. package/deps/couchbase-cxx-client/couchbase/search_sort_field_missing.hxx +26 -0
  148. package/deps/couchbase-cxx-client/couchbase/search_sort_field_mode.hxx +27 -0
  149. package/deps/couchbase-cxx-client/couchbase/search_sort_field_type.hxx +28 -0
  150. package/deps/couchbase-cxx-client/couchbase/search_sort_id.hxx +60 -0
  151. package/deps/couchbase-cxx-client/couchbase/search_sort_score.hxx +60 -0
  152. package/deps/couchbase-cxx-client/couchbase/search_term_range.hxx +51 -0
  153. package/deps/couchbase-cxx-client/couchbase/security_options.hxx +3 -0
  154. package/deps/couchbase-cxx-client/couchbase/subdocument_error_context.hxx +4 -2
  155. package/deps/couchbase-cxx-client/couchbase/term_facet.hxx +48 -0
  156. package/deps/couchbase-cxx-client/couchbase/term_facet_result.hxx +55 -0
  157. package/deps/couchbase-cxx-client/couchbase/term_query.hxx +151 -0
  158. package/deps/couchbase-cxx-client/couchbase/term_range_query.hxx +142 -0
  159. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_options.hxx +1 -1
  160. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_query_options.hxx +2 -1
  161. package/deps/couchbase-cxx-client/couchbase/transactions/transaction_result.hxx +1 -1
  162. package/deps/couchbase-cxx-client/couchbase/transactions.hxx +3 -3
  163. package/deps/couchbase-cxx-client/couchbase/wildcard_query.hxx +83 -0
  164. package/deps/couchbase-cxx-client/docs/Doxyfile.in +1 -1
  165. package/deps/couchbase-cxx-client/docs/cbc-analytics.md +2 -2
  166. package/deps/couchbase-cxx-client/docs/cbc-get.md +3 -2
  167. package/deps/couchbase-cxx-client/docs/cbc-pillowfight.md +7 -2
  168. package/deps/couchbase-cxx-client/docs/cbc-query.md +2 -2
  169. package/deps/couchbase-cxx-client/docs/cbc.md +3 -3
  170. package/deps/couchbase-cxx-client/docs/cli.hxx +5 -5
  171. package/deps/couchbase-cxx-client/docs/mainpage.hxx +42 -5
  172. package/deps/couchbase-cxx-client/test/CMakeLists.txt +1 -0
  173. package/deps/couchbase-cxx-client/test/test_integration_analytics.cxx +28 -6
  174. package/deps/couchbase-cxx-client/test/test_integration_collections.cxx +7 -3
  175. package/deps/couchbase-cxx-client/test/test_integration_connect.cxx +7 -3
  176. package/deps/couchbase-cxx-client/test/test_integration_crud.cxx +13 -3
  177. package/deps/couchbase-cxx-client/test/test_integration_diagnostics.cxx +8 -2
  178. package/deps/couchbase-cxx-client/test/test_integration_durability.cxx +12 -7
  179. package/deps/couchbase-cxx-client/test/test_integration_examples.cxx +283 -11
  180. package/deps/couchbase-cxx-client/test/test_integration_management.cxx +140 -88
  181. package/deps/couchbase-cxx-client/test/test_integration_query.cxx +67 -9
  182. package/deps/couchbase-cxx-client/test/test_integration_range_scan.cxx +12 -12
  183. package/deps/couchbase-cxx-client/test/test_integration_read_replica.cxx +48 -11
  184. package/deps/couchbase-cxx-client/test/test_integration_search.cxx +19 -1
  185. package/deps/couchbase-cxx-client/test/test_integration_subdoc.cxx +60 -9
  186. package/deps/couchbase-cxx-client/test/test_integration_tracer.cxx +3 -0
  187. package/deps/couchbase-cxx-client/test/test_integration_transcoders.cxx +4 -0
  188. package/deps/couchbase-cxx-client/test/test_transaction_examples.cxx +100 -85
  189. package/deps/couchbase-cxx-client/test/test_unit_connection_string.cxx +29 -0
  190. package/deps/couchbase-cxx-client/test/test_unit_search.cxx +427 -0
  191. package/deps/couchbase-cxx-client/test/utils/integration_test_guard.cxx +2 -1
  192. package/deps/couchbase-cxx-client/test/utils/logger.cxx +3 -1
  193. package/deps/couchbase-cxx-client/test/utils/server_version.hxx +31 -15
  194. package/deps/couchbase-cxx-client/test/utils/test_context.cxx +8 -0
  195. package/deps/couchbase-cxx-client/tools/get.cxx +9 -8
  196. package/deps/couchbase-cxx-client/tools/pillowfight.cxx +175 -75
  197. package/deps/couchbase-cxx-client/tools/version.cxx +4 -2
  198. package/dist/binding.d.ts +1 -1
  199. package/dist/binding.js +3 -2
  200. package/package.json +96 -1
  201. package/scripts/createPlatformPackages.js +108 -0
  202. package/scripts/install.js +45 -0
  203. package/scripts/prebuilds.js +249 -0
  204. package/scripts/prune.js +124 -0
  205. package/src/jstocbpp_autogen.hpp +3 -2
@@ -33,6 +33,7 @@
33
33
  #include <csignal>
34
34
  #include <numeric>
35
35
  #include <random>
36
+ #include <thread>
36
37
 
37
38
  namespace cbc
38
39
  {
@@ -46,11 +47,14 @@ usage() -> std::string
46
47
  static const std::size_t default_number_of_worker_threads{ 1 };
47
48
  static const double default_chance_of_get{ 0.6 };
48
49
  static const double default_hit_chance_for_get{ 1.0 };
49
- static const double default_hit_chance_for_upsert{ 0.5 };
50
+ static const double default_hit_chance_for_upsert{ 1 };
50
51
  static const double default_chance_of_query{ 0.0 };
51
52
  static const std::string default_query_statement{ "SELECT COUNT(*) FROM `{bucket_name}` WHERE type = \"fake_profile\"" };
52
53
  static const std::size_t default_document_body_size{ 0 };
53
54
  static const std::size_t default_operation_limit{ 0 };
55
+ static const std::size_t default_batch_size{ 100 };
56
+ static const std::chrono::milliseconds default_batch_wait{ 0 };
57
+ static const std::size_t default_number_of_keys_to_populate{ 1'000 };
54
58
 
55
59
  static const std::string usage_string = fmt::format(
56
60
  R"(Run workload generator.
@@ -60,20 +64,24 @@ Usage:
60
64
  cbc pillowfight (-h|--help)
61
65
 
62
66
  Options:
63
- -h --help Show this screen.
64
- --bucket-name=STRING Name of the bucket. [default: {bucket_name}]
65
- --scope-name=STRING Name of the scope. [default: {scope_name}]
66
- --collection-name=STRING Name of the collection. [default: {collection_name}]
67
- --number-of-io-threads=INTEGER Number of the IO threads. [default: {number_of_io_threads}]
68
- --number-of-worker-threads=INTEGER Number of the IO threads. [default: {number_of_worker_threads}]
69
- --chance-of-get=FLOAT The probability of get operation (where 1 means only get, and 0 - only upsert). [default: {chance_of_get}]
70
- --hit-chance-for-get=FLOAT The probability of using existing ID for get operation. [default: {hit_chance_for_get}]
71
- --hit-chance-for-upsert=FLOAT The probability of using existing ID for upsert operation. [default: {hit_chance_for_upsert}]
72
- --chance-of-query=FLOAT The probability of N1QL query will be send on after get/upsert. [default: {chance_of_query}]
73
- --query-statement=STRING The N1QL query statement to use ({{bucket_name}}, {{scope_name}} and {{collection_name}} will be substituted). [default: {query_statement}]
74
- --incompressible-body Use random characters to fill generated document value (by default uses 'x' to fill the body).
75
- --document-body-size=INTEGER Size of the body (if zero, it will use predefined document). [default: {document_body_size}]
76
- --operations-limit=INTEGER Stop and exit after the number of the operations reaches this limit. (zero for running indefinitely) [default: {operation_limit}]
67
+ -h --help Show this screen.
68
+ --verbose Include more context and information where it is applicable.
69
+ --bucket-name=STRING Name of the bucket. [default: {bucket_name}]
70
+ --scope-name=STRING Name of the scope. [default: {scope_name}]
71
+ --collection-name=STRING Name of the collection. [default: {collection_name}]
72
+ --batch-size=INTEGER Number of the operations in single batch. [default: {batch_size}]
73
+ --batch-wait=DURATION Time to wait after the batch. [default: {batch_wait}]
74
+ --number-of-io-threads=INTEGER Number of the IO threads. [default: {number_of_io_threads}]
75
+ --number-of-worker-threads=INTEGER Number of the IO threads. [default: {number_of_worker_threads}]
76
+ --chance-of-get=FLOAT The probability of get operation (where 1 means only get, and 0 - only upsert). [default: {chance_of_get}]
77
+ --hit-chance-for-get=FLOAT The probability of using existing ID for get operation. [default: {hit_chance_for_get}]
78
+ --hit-chance-for-upsert=FLOAT The probability of using existing ID for upsert operation. [default: {hit_chance_for_upsert}]
79
+ --chance-of-query=FLOAT The probability of N1QL query will be send on after get/upsert. [default: {chance_of_query}]
80
+ --query-statement=STRING The N1QL query statement to use ({{bucket_name}}, {{scope_name}} and {{collection_name}} will be substituted). [default: {query_statement}]
81
+ --incompressible-body Use random characters to fill generated document value (by default uses 'x' to fill the body).
82
+ --document-body-size=INTEGER Size of the body (if zero, it will use predefined document). [default: {document_body_size}]
83
+ --number-of-keys-to-populate=INTEGER Preload keys before running workload, so that the worker will not generate new keys afterwards. [default: {number_of_keys_to_populate}]
84
+ --operations-limit=INTEGER Stop and exit after the number of the operations reaches this limit. (zero for running indefinitely) [default: {operation_limit}]
77
85
 
78
86
  {logger_options}{cluster_options}
79
87
  )",
@@ -89,6 +97,9 @@ Options:
89
97
  fmt::arg("query_statement", default_query_statement),
90
98
  fmt::arg("document_body_size", default_document_body_size),
91
99
  fmt::arg("operation_limit", default_operation_limit),
100
+ fmt::arg("batch_size", default_batch_size),
101
+ fmt::arg("batch_wait", default_batch_wait),
102
+ fmt::arg("number_of_keys_to_populate", default_number_of_keys_to_populate),
92
103
  fmt::arg("logger_options", usage_block_for_logger()),
93
104
  fmt::arg("cluster_options", usage_block_for_cluster_options()));
94
105
 
@@ -140,8 +151,11 @@ struct command_options {
140
151
  std::string bucket_name;
141
152
  std::string scope_name;
142
153
  std::string collection_name;
154
+ std::size_t batch_size;
155
+ std::chrono::milliseconds batch_wait;
143
156
  std::size_t number_of_io_threads;
144
157
  std::size_t number_of_worker_threads;
158
+ std::size_t number_of_keys_to_populate;
145
159
  double chance_of_get;
146
160
  double hit_chance_for_get;
147
161
  double hit_chance_for_upsert;
@@ -149,6 +163,12 @@ struct command_options {
149
163
  std::string query_statement;
150
164
  bool incompressible_body;
151
165
  std::size_t document_body_size;
166
+ bool verbose{ false };
167
+
168
+ void set_batch_wait(std::chrono::milliseconds val)
169
+ {
170
+ batch_wait = val;
171
+ }
152
172
  };
153
173
 
154
174
  enum class operation {
@@ -166,8 +186,9 @@ std::map<std::error_code, std::size_t> errors{};
166
186
  std::mutex errors_mutex{};
167
187
 
168
188
  void
169
- sigint_handler(int /* signal */)
189
+ sigint_handler(int signal)
170
190
  {
191
+ fmt::print(stderr, "\nrequested stop, signal={}\n", signal);
171
192
  running.clear();
172
193
  }
173
194
 
@@ -179,9 +200,11 @@ dump_stats(asio::steady_timer& timer, std::chrono::system_clock::time_point star
179
200
  if (ec == asio::error::operation_aborted) {
180
201
  return;
181
202
  }
182
- auto diff = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_time).count();
203
+ auto uptime = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - start_time);
204
+ auto diff = uptime.count();
183
205
  const std::uint64_t ops = total;
184
- fmt::print(stderr, "\rrate: {} ops/s, total: {}", diff == 0 ? ops : ops / static_cast<std::uint64_t>(diff), ops);
206
+ fmt::print(
207
+ stderr, "\r\033[Kuptime: {}, rate: {} ops/s, total: {}\r", uptime, diff == 0 ? ops : ops / static_cast<std::uint64_t>(diff), ops);
185
208
  return dump_stats(timer, start_time);
186
209
  });
187
210
  }
@@ -205,6 +228,19 @@ random_text(std::size_t length)
205
228
  return text;
206
229
  }
207
230
 
231
+ auto
232
+ generate_document_body(const command_options& options)
233
+ {
234
+ if (options.document_body_size > 0) {
235
+ return couchbase::core::utils::json::generate_binary({
236
+ { "size", options.document_body_size },
237
+ { "text", options.incompressible_body ? random_text(options.document_body_size) : std::string(options.document_body_size, 'x') },
238
+ });
239
+ } else {
240
+ return couchbase::core::utils::to_binary(default_json_doc);
241
+ }
242
+ }
243
+
208
244
  void
209
245
  worker(couchbase::cluster connected_cluster, command_options cmd_options, std::vector<std::string>& known_keys)
210
246
  {
@@ -216,71 +252,128 @@ worker(couchbase::cluster connected_cluster, command_options cmd_options, std::v
216
252
 
217
253
  auto collection = cluster.bucket(options.bucket_name).scope(options.scope_name).collection(options.collection_name);
218
254
 
219
- std::vector<std::byte> json_doc{};
220
- if (options.document_body_size > 0) {
221
- json_doc = couchbase::core::utils::json::generate_binary({
222
- { "size", options.document_body_size },
223
- { "text", options.incompressible_body ? random_text(options.document_body_size) : std::string(options.document_body_size, 'x') },
224
- });
225
- } else {
226
- json_doc = couchbase::core::utils::to_binary(default_json_doc);
227
- }
255
+ std::vector<std::byte> json_doc = generate_document_body(options);
228
256
 
229
257
  while (running.test_and_set()) {
230
- auto opcode = (dist(gen) <= options.chance_of_get) ? operation::get : operation::upsert;
231
- if (opcode == operation::get && known_keys.empty()) {
232
- opcode = operation::upsert;
258
+ std::list<std::variant<std::future<std::pair<couchbase::key_value_error_context, couchbase::mutation_result>>,
259
+ std::future<std::pair<couchbase::key_value_error_context, couchbase::get_result>>,
260
+ std::future<std::pair<couchbase::query_error_context, couchbase::query_result>>>>
261
+ futures;
262
+ for (std::size_t i = 0; i < options.batch_size; ++i) {
263
+ auto opcode = (dist(gen) <= options.chance_of_get) ? operation::get : operation::upsert;
264
+ if (opcode == operation::get && known_keys.empty()) {
265
+ opcode = operation::upsert;
266
+ }
267
+ bool should_check_known_keys{ false };
268
+ switch (opcode) {
269
+ case operation::get:
270
+ should_check_known_keys = options.hit_chance_for_get > dist(gen);
271
+ break;
272
+ case operation::upsert:
273
+ should_check_known_keys = options.hit_chance_for_upsert > dist(gen);
274
+ break;
275
+ }
276
+ std::string document_id = uniq_id("id");
277
+ if (should_check_known_keys && !known_keys.empty()) {
278
+ auto key_index = std::uniform_int_distribution<std::size_t>(0, known_keys.size() - 1)(gen);
279
+ document_id = known_keys[key_index];
280
+ }
281
+
282
+ switch (opcode) {
283
+ case operation::upsert:
284
+ futures.emplace_back(collection.upsert<raw_json_transcoder>(document_id, json_doc));
285
+ break;
286
+ case operation::get:
287
+ futures.emplace_back(collection.get(document_id));
288
+ break;
289
+ }
290
+ if (options.chance_of_query > 0 && dist(gen) <= options.chance_of_query) {
291
+ futures.emplace_back(cluster.query(options.query_statement, couchbase::query_options{}));
292
+ }
293
+ if (operations_limit > 0 && total >= operations_limit) {
294
+ running.clear();
295
+ }
233
296
  }
234
- bool should_check_known_keys{ false };
235
- switch (opcode) {
236
- case operation::get:
237
- should_check_known_keys = options.hit_chance_for_get > dist(gen);
238
- break;
239
- case operation::upsert:
240
- should_check_known_keys = options.hit_chance_for_upsert > dist(gen);
241
- break;
297
+
298
+ for (auto&& future : futures) {
299
+ std::visit(
300
+ [&options, &known_keys](auto f) mutable {
301
+ using T = std::decay_t<decltype(f)>;
302
+
303
+ auto [ctx, resp] = f.get();
304
+ ++total;
305
+ if (ctx.ec()) {
306
+ const std::scoped_lock lock(errors_mutex);
307
+ ++errors[ctx.ec()];
308
+ if (options.verbose) {
309
+ fmt::print(stderr, "\r\033[K{}\n", ctx.to_json());
310
+ }
311
+ } else if constexpr (std::is_same_v<
312
+ T,
313
+ std::future<std::pair<couchbase::key_value_error_context, couchbase::mutation_result>>>) {
314
+ known_keys.emplace_back(ctx.id());
315
+ }
316
+ },
317
+ std::move(future));
242
318
  }
243
- std::string document_id = uniq_id("id");
244
- if (should_check_known_keys && !known_keys.empty()) {
245
- auto key_index = std::uniform_int_distribution<std::size_t>(0, known_keys.size() - 1)(gen);
246
- document_id = known_keys[key_index];
247
- } else {
248
- known_keys.emplace_back(document_id);
319
+ if (options.batch_wait != std::chrono::milliseconds::zero()) {
320
+ std::this_thread::sleep_for(options.batch_wait);
249
321
  }
322
+ }
323
+ }
250
324
 
251
- switch (opcode) {
252
- case operation::upsert: {
253
- const couchbase::upsert_options operation_options{};
254
- auto [ctx, resp] = collection.upsert<raw_json_transcoder>(document_id, json_doc, operation_options).get();
255
- ++total;
256
- if (ctx.ec()) {
257
- const std::scoped_lock lock(errors_mutex);
258
- ++errors[ctx.ec()];
259
- }
260
- } break;
261
- case operation::get: {
262
- const couchbase::get_options operation_options{};
263
- auto [ctx, resp] = collection.get(document_id, operation_options).get();
264
- ++total;
325
+ void
326
+ populate_keys(const couchbase::cluster& cluster, const command_options& options, std::vector<std::vector<std::string>>& known_keys)
327
+ {
328
+ const std::size_t total_keys{ options.number_of_worker_threads * options.number_of_keys_to_populate };
329
+
330
+ auto collection = cluster.bucket(options.bucket_name).scope(options.scope_name).collection(options.collection_name);
331
+
332
+ const auto json_doc = generate_document_body(options);
333
+ const auto start_time = std::chrono::system_clock::now();
334
+
335
+ std::size_t stored_keys{ 0 };
336
+ std::size_t retried_keys{ 0 };
337
+ for (std::size_t i = 0; i < options.number_of_worker_threads; ++i) {
338
+ auto keys_left = options.number_of_keys_to_populate;
339
+
340
+ while (keys_left > 0) {
341
+ fmt::print(stderr,
342
+ "\r\033[K{:02.2f}% {} of {}, {}\r",
343
+ static_cast<double>(stored_keys) / gsl::narrow_cast<double>(total_keys) * 100,
344
+ stored_keys,
345
+ total_keys,
346
+ std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start_time));
347
+
348
+ auto batch_size = std::min(keys_left, options.batch_size);
349
+
350
+ std::vector<std::future<std::pair<couchbase::key_value_error_context, couchbase::mutation_result>>> futures;
351
+ futures.reserve(batch_size);
352
+ for (std::size_t k = 0; k < batch_size; ++k) {
353
+ const std::string document_id = uniq_id("id");
354
+ futures.emplace_back(collection.upsert<raw_json_transcoder>(document_id, json_doc));
355
+ }
356
+
357
+ for (auto&& future : futures) {
358
+ auto [ctx, res] = future.get();
265
359
  if (ctx.ec()) {
266
- const std::scoped_lock lock(errors_mutex);
267
- ++errors[ctx.ec()];
360
+ ++retried_keys;
361
+ } else {
362
+ ++stored_keys;
363
+ --keys_left;
268
364
  }
269
- } break;
270
- }
271
- if (options.chance_of_query > 0 && dist(gen) <= options.chance_of_query) {
272
- const couchbase::query_options operation_options{};
273
- auto [ctx, resp] = cluster.query(options.query_statement, operation_options).get();
274
- ++total;
275
- if (ctx.ec()) {
276
- const std::scoped_lock lock(errors_mutex);
277
- ++errors[ctx.ec()];
278
365
  }
279
366
  }
280
- if (operations_limit > 0 && total >= operations_limit) {
281
- running.clear();
282
- }
283
367
  }
368
+ const auto finish_time = std::chrono::system_clock::now();
369
+ const auto total_time = finish_time - start_time;
370
+
371
+ fmt::print(stderr,
372
+ "\r\033[K{} keys populated in {}s ({}ms) with {} retries\n",
373
+ stored_keys,
374
+ std::chrono::duration_cast<std::chrono::seconds>(total_time).count(),
375
+ std::chrono::duration_cast<std::chrono::milliseconds>(total_time).count(),
376
+ retried_keys);
284
377
  }
285
378
 
286
379
  void
@@ -309,13 +402,16 @@ do_work(const std::string& connection_string, const couchbase::cluster_options&
309
402
  throw std::system_error(ec, "unable to connect to the cluster in time");
310
403
  }
311
404
 
405
+ std::vector<std::vector<std::string>> known_keys(cmd_options.number_of_worker_threads);
406
+ if (cmd_options.number_of_keys_to_populate > 0) {
407
+ populate_keys(cluster, cmd_options, known_keys);
408
+ }
409
+
312
410
  const auto start_time = std::chrono::system_clock::now();
313
411
 
314
412
  asio::steady_timer stats_timer(io);
315
413
  dump_stats(stats_timer, start_time);
316
414
 
317
- std::vector<std::vector<std::string>> known_keys(cmd_options.number_of_worker_threads);
318
-
319
415
  std::vector<std::thread> worker_pool{};
320
416
  worker_pool.reserve(cmd_options.number_of_worker_threads);
321
417
  for (std::size_t i = 0; i < cmd_options.number_of_worker_threads; ++i) {
@@ -343,7 +439,7 @@ do_work(const std::string& connection_string, const couchbase::cluster_options&
343
439
  if (!errors.empty()) {
344
440
  fmt::print("error stats:\n");
345
441
  for (auto [e, count] : errors) {
346
- fmt::print(" {}: {}\n", ec.message(), count);
442
+ fmt::print(" {}: {}\n", e.message(), count);
347
443
  }
348
444
  }
349
445
  }
@@ -373,9 +469,13 @@ cbc::pillowfight::execute(const std::vector<std::string>& argv)
373
469
  cbc::fill_cluster_options(options, cluster_options, connection_string);
374
470
 
375
471
  command_options cmd_options{};
472
+ cmd_options.verbose = options["--verbose"].asBool();
376
473
  cmd_options.bucket_name = options["--bucket-name"].asString();
377
474
  cmd_options.scope_name = options["--scope-name"].asString();
378
475
  cmd_options.collection_name = options["--collection-name"].asString();
476
+ cmd_options.batch_size = options["--batch-size"].asLong();
477
+ parse_duration_option(cmd_options.set_batch_wait, "--batch-wait");
478
+ cmd_options.number_of_keys_to_populate = options["--number-of-keys-to-populate"].asLong();
379
479
  cmd_options.number_of_io_threads = options["--number-of-io-threads"].asLong();
380
480
  cmd_options.number_of_worker_threads = options["--number-of-worker-threads"].asLong();
381
481
  cmd_options.chance_of_get = get_double_option(options, "--chance-of-get");
@@ -49,9 +49,11 @@ cbc::version::execute(const std::vector<std::string>& argv)
49
49
  if (options["--json"].asBool()) {
50
50
  tao::json::value info;
51
51
  for (const auto& [name, value] : couchbase::core::meta::sdk_build_info()) {
52
- if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build") {
52
+ if (name == "version_major" || name == "version_minor" || name == "version_patch" || name == "version_build" ||
53
+ name == "mozilla_ca_bundle_size") {
53
54
  info[name] = std::stoi(value);
54
- } else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl") {
55
+ } else if (name == "snapshot" || name == "static_stdlib" || name == "static_openssl" ||
56
+ name == "mozilla_ca_bundle_embedded") {
55
57
  info[name] = value == "true";
56
58
  } else {
57
59
  info[name] = value;
package/dist/binding.d.ts CHANGED
@@ -831,7 +831,7 @@ export interface CppSearchRequest {
831
831
  query: CppJsonString;
832
832
  limit?: number;
833
833
  skip?: number;
834
- explain: boolean;
834
+ explain?: boolean;
835
835
  disable_scoring: boolean;
836
836
  include_locations: boolean;
837
837
  highlight_style?: CppSearchHighlightStyle;
package/dist/binding.js CHANGED
@@ -9,7 +9,7 @@ eslint
9
9
  jsdoc/require-jsdoc: off,
10
10
  @typescript-eslint/no-empty-interface: off
11
11
  */
12
- const bindings_1 = __importDefault(require("bindings"));
12
+ const path_1 = __importDefault(require("path"));
13
13
  exports.zeroCas = 0;
14
14
  //#region Autogenerated Bindings
15
15
  var CppManagementAnalyticsCouchbaseLinkEncryptionLevel;
@@ -157,5 +157,6 @@ var CppTxnExternalException;
157
157
  (function (CppTxnExternalException) {
158
158
  })(CppTxnExternalException = exports.CppTxnExternalException || (exports.CppTxnExternalException = {}));
159
159
  // Load it with require
160
- const binding = (0, bindings_1.default)('couchbase_impl');
160
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
161
+ const binding = require('../scripts/prebuilds').loadPrebuild(path_1.default.resolve(__dirname, '..'));
161
162
  exports.default = binding;
package/package.json CHANGED
@@ -1 +1,96 @@
1
- {"bugs":{"url":"http://www.couchbase.com/issues/browse/JSCBC"},"description":"The official Couchbase Node.js Client Library.","engines":{"node":">=12.0.0"},"homepage":"http://www.couchbase.com/communities/nodejs","keywords":["couchbase","libcouchbase","memcached","nosql","json","document"],"main":"dist/couchbase.js","types":"dist/couchbase.d.ts","license":"Apache-2.0","name":"couchbase","dependencies":{"bindings":"^1.5.0","cmake-js":"^6.3.2","node-addon-api":"^5.0.0","prebuild-install":"^7.1.1"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^4.1.0","@tsconfig/node12":"^1.0.11","@types/bindings":"^1.5.1","@types/debug":"^4.1.7","@types/node":"^20.1.0","@typescript-eslint/eslint-plugin":"^5.32.0","@typescript-eslint/parser":"^5.32.0","chai":"^4.3.6","eslint":"^8.21.0","eslint-config-prettier":"^8.5.0","eslint-plugin-jsdoc":"^41.1.0","eslint-plugin-mocha":"^10.1.0","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^10.0.0","npm-check-updates":"^16.0.5","nyc":"^15.1.0","prebuild":"^11.0.4","prettier":"^2.7.1","segfault-handler":"^1.3.0","semver":"^7.3.7","ts-mocha":"^10.0.0","ts-node":"^10.9.1","typedoc":"^0.24.1","typescript":"^4.7.4","uuid":"^9.0.0"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"4.2.3","config":{"native":false},"scripts":{"install":"prebuild-install -r napi || cmake-js compile","build":"cmake-js build && tsc","rebuild":"cmake-js rebuild && tsc","prebuild":"prebuild --backend cmake-js --verbose --strip","prepare":"tsc","build-docs":"typedoc","test":"ts-mocha test/*.test.*","test-fast":"ts-mocha test/*.test.* -ig '(slow)'","cover":"nyc ts-mocha test/*.test.*","cover-fast":"nyc ts-mocha test/*.test.* -ig '(slow)'","lint":"eslint ./lib/ ./test/","check-deps":"ncu"},"binary":{"napi_versions":[6]}}
1
+ {
2
+ "bugs": {
3
+ "url": "http://www.couchbase.com/issues/browse/JSCBC"
4
+ },
5
+ "description": "The official Couchbase Node.js Client Library.",
6
+ "engines": {
7
+ "node": ">=12.0.0"
8
+ },
9
+ "homepage": "http://www.couchbase.com/communities/nodejs",
10
+ "keywords": [
11
+ "couchbase",
12
+ "libcouchbase",
13
+ "memcached",
14
+ "nosql",
15
+ "json",
16
+ "document"
17
+ ],
18
+ "main": "dist/couchbase.js",
19
+ "types": "dist/couchbase.d.ts",
20
+ "license": "Apache-2.0",
21
+ "name": "couchbase",
22
+ "dependencies": {
23
+ "cmake-js": "^7.2.0",
24
+ "node-addon-api": "^5.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@trivago/prettier-plugin-sort-imports": "^4.1.0",
28
+ "@types/bindings": "^1.5.1",
29
+ "@types/debug": "^4.1.7",
30
+ "@types/node": "^20.1.0",
31
+ "@tsconfig/node12": "^1.0.11",
32
+ "@typescript-eslint/eslint-plugin": "^5.32.0",
33
+ "@typescript-eslint/parser": "^5.32.0",
34
+ "chai": "^4.3.6",
35
+ "eslint": "^8.21.0",
36
+ "eslint-config-prettier": "^8.5.0",
37
+ "eslint-plugin-jsdoc": "^41.1.0",
38
+ "eslint-plugin-mocha": "^10.1.0",
39
+ "eslint-plugin-node": "^11.1.0",
40
+ "expose-gc": "^1.0.0",
41
+ "mocha": "^10.0.0",
42
+ "npm-check-updates": "^16.0.5",
43
+ "nyc": "^15.1.0",
44
+ "prebuild": "^11.0.4",
45
+ "prettier": "^2.7.1",
46
+ "segfault-handler": "^1.3.0",
47
+ "semver": "^7.3.7",
48
+ "ts-mocha": "^10.0.0",
49
+ "ts-node": "^10.9.1",
50
+ "typedoc": "^0.24.1",
51
+ "typescript": "^4.7.4",
52
+ "uuid": "^9.0.0"
53
+ },
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "http://github.com/couchbase/couchnode.git"
57
+ },
58
+ "version": "4.2.5-dev.1",
59
+ "config": {
60
+ "native": false
61
+ },
62
+ "scripts": {
63
+ "install": "node ./scripts/install.js",
64
+ "build": "cmake-js build && tsc",
65
+ "rebuild": "cmake-js rebuild && tsc",
66
+ "prebuild": "prebuild --backend cmake-js --verbose --strip",
67
+ "prepare": "tsc",
68
+ "help-prune": "node ./scripts/prune.js",
69
+ "build-docs": "typedoc",
70
+ "test": "ts-mocha test/*.test.*",
71
+ "test-fast": "ts-mocha test/*.test.* -ig '(slow)'",
72
+ "cover": "nyc ts-mocha test/*.test.*",
73
+ "cover-fast": "nyc ts-mocha test/*.test.* -ig '(slow)'",
74
+ "lint": "eslint ./lib/ ./test/",
75
+ "check-deps": "ncu"
76
+ },
77
+ "binary": {
78
+ "napi_versions": [
79
+ 6
80
+ ]
81
+ },
82
+ "optionalDependencies": {
83
+ "@couchbase/couchbase-darwin-arm64-openssl1": "4.2.5-dev.1",
84
+ "@couchbase/couchbase-darwin-arm64-openssl3": "4.2.5-dev.1",
85
+ "@couchbase/couchbase-darwin-x64-openssl1": "4.2.5-dev.1",
86
+ "@couchbase/couchbase-darwin-x64-openssl3": "4.2.5-dev.1",
87
+ "@couchbase/couchbase-linux-arm64-openssl1": "4.2.5-dev.1",
88
+ "@couchbase/couchbase-linux-arm64-openssl3": "4.2.5-dev.1",
89
+ "@couchbase/couchbase-linux-x64-openssl1": "4.2.5-dev.1",
90
+ "@couchbase/couchbase-linux-x64-openssl3": "4.2.5-dev.1",
91
+ "@couchbase/couchbase-linuxmusl-x64-openssl1": "4.2.5-dev.1",
92
+ "@couchbase/couchbase-linuxmusl-x64-openssl3": "4.2.5-dev.1",
93
+ "@couchbase/couchbase-win32-x64-openssl1": "4.2.5-dev.1",
94
+ "@couchbase/couchbase-win32-x64-openssl3": "4.2.5-dev.1"
95
+ }
96
+ }
@@ -0,0 +1,108 @@
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const { getSupportedPlatformPackages } = require('./prebuilds')
4
+
5
+ try {
6
+ // we run this script w/in a Jenkins dir("couchnode"){} block
7
+ const couchbasePkgData = JSON.parse(fs.readFileSync('package.json'))
8
+ const packageName = couchbasePkgData.name
9
+ const packageVersion = couchbasePkgData.version
10
+ let platformPackages = (couchbasePkgData.optionalDependencies = {})
11
+ const prebuildsPath = path.join(process.cwd(), 'prebuilds')
12
+ const prebuilds = fs.readdirSync(prebuildsPath)
13
+ const supportedPlatPkgs = getSupportedPlatformPackages(couchbasePkgData.name)
14
+ for (const prebuild of prebuilds) {
15
+ if (fs.lstatSync(path.join(prebuildsPath, prebuild)).isDirectory()) continue
16
+ // prebuild format:
17
+ // couchbase-v<pkg-version>-<runtime>-v<runtime-version>-<platform>-<arch>-<SSL type>.node.tar.gz
18
+ const tokens = prebuild.split('-')
19
+ if (tokens.length < 7) continue
20
+ if (tokens[tokens.length - 1].startsWith('debug')) {
21
+ fs.renameSync(`prebuilds/${prebuild}`, `prebuilds_debug/${prebuild}`)
22
+ continue
23
+ }
24
+ const nodeVersion = parseInt(
25
+ tokens[tokens.length - 1].replace('.node', '').replace('node', '')
26
+ )
27
+ const arch = tokens[tokens.length - 2]
28
+ const platform = tokens[tokens.length - 3]
29
+ const runtime = tokens[tokens.length - 5]
30
+ const sslType =
31
+ runtime === 'napi'
32
+ ? nodeVersion >= 18
33
+ ? 'openssl3'
34
+ : 'openssl1'
35
+ : 'boringssl'
36
+ const platPkg = `${tokens[0]}-${platform}-${arch}-${sslType}`
37
+ let description = `Couchbase Node.js SDK platform specific binary for ${runtime} runtime on ${platform} OS with ${arch} architecture`
38
+ if (runtime === 'napi') {
39
+ description += ` and OpenSSL ${nodeVersion >= 18 ? '3.x' : '1.x'}.`
40
+ } else {
41
+ description += ' and BoringSSL.'
42
+ }
43
+ console.log(`platformPackage=${platPkg}`)
44
+ if (supportedPlatPkgs.includes(platPkg)) {
45
+ console.log(`Building requirements for platform package: ${platPkg}`)
46
+ if (!fs.existsSync(`prebuilds/${platPkg}`)) {
47
+ fs.mkdirSync(`prebuilds/${platPkg}`)
48
+ }
49
+ tokens[tokens.length - 1] = `${sslType}.node`
50
+ const newPrebuildName = tokens.join('-')
51
+ const oldPath = path.join('prebuilds', prebuild)
52
+ const newPath = path.join('prebuilds', platPkg)
53
+ fs.renameSync(oldPath, path.join(newPath, newPrebuildName))
54
+ const platformPackage = `@${packageName}/${platPkg}`
55
+ // build the platform package files: package.json, README and index.js
56
+ const engines = { node: `>=16.0.0` }
57
+ if (runtime === 'napi') {
58
+ engines.node = nodeVersion >= 18 ? '>=18.0.0' : '<18'
59
+ }
60
+ fs.writeFileSync(
61
+ path.join(newPath, 'package.json'),
62
+ JSON.stringify(
63
+ {
64
+ name: platformPackage,
65
+ version: packageVersion,
66
+ engines: engines,
67
+ os: [platform.includes('linux') ? 'linux' : platform],
68
+ cpu: [arch],
69
+ bugs: couchbasePkgData.bugs,
70
+ homepage: couchbasePkgData.homepage,
71
+ license: couchbasePkgData.license,
72
+ repository: couchbasePkgData.repository,
73
+ description: description,
74
+ },
75
+ null,
76
+ 2
77
+ )
78
+ )
79
+ fs.writeFileSync(path.join(newPath, 'index.js'), '')
80
+ fs.writeFileSync(path.join(newPath, 'README.md'), description)
81
+ platformPackages[platformPackage] = packageVersion
82
+ }
83
+ }
84
+
85
+ if (
86
+ !process.env.ALLOW_MISMATCH &&
87
+ Object.keys(platformPackages).length != supportedPlatPkgs.length
88
+ ) {
89
+ const builtPlatformPkgs = Object.keys(platformPackages).map((pkg) => {
90
+ const tokens = pkg.split('/')
91
+ return tokens[1]
92
+ })
93
+ const missingPkgs = supportedPlatPkgs.filter(
94
+ (pkg) => !builtPlatformPkgs.includes(pkg)
95
+ )
96
+ const extraPkgs = builtPlatformPkgs.filter(
97
+ (pkg) => !supportedPlatPkgs.includes(pkg)
98
+ )
99
+ let msg = 'Mismatch in built platform packages.\n'
100
+ msg += 'Missing: ' + JSON.stringify(missingPkgs) + '.\n'
101
+ msg += 'Extra: ' + JSON.stringify(extraPkgs) + '.'
102
+ throw new Error(msg)
103
+ }
104
+ fs.writeFileSync('package.json', JSON.stringify(couchbasePkgData, null, 2))
105
+ } catch (err) {
106
+ console.log('An error occurred:', err)
107
+ process.exitCode = 1
108
+ }