couchbase 3.2.5 → 3.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2023,6 +2023,35 @@ void AdminHandler::run()
2023
2023
  printf("%s\n", resbuf.c_str());
2024
2024
  }
2025
2025
 
2026
+ void BucketListHandler::run()
2027
+ {
2028
+ fprintf(stderr, "Requesting %s\n", getURI().c_str());
2029
+ HttpBaseHandler::run();
2030
+ if (o_raw.result()) {
2031
+ printf("%s\n", resbuf.c_str());
2032
+ } else {
2033
+ format();
2034
+ }
2035
+ }
2036
+
2037
+ void BucketListHandler::format()
2038
+ {
2039
+ Json::Value json;
2040
+ if (!Json::Reader().parse(resbuf, json)) {
2041
+ fprintf(stderr, "Failed to parse response as JSON, falling back to raw mode\n");
2042
+ printf("%s\n", resbuf.c_str());
2043
+ }
2044
+
2045
+ printf("%-20s%-10s%s\n", "Name", "Type", "Items");
2046
+
2047
+ for (Json::Value::ArrayIndex i = 0; i < json.size(); ++i) {
2048
+ const char *name = json[i]["name"].asString().c_str();
2049
+ const char *bucketType = json[i]["bucketType"].asString().c_str();
2050
+ const int itemCount = json[i]["basicStats"]["itemCount"].asInt();
2051
+ printf("%-20s%-10s%i\n", name, bucketType, itemCount);
2052
+ }
2053
+ }
2054
+
2026
2055
  void BucketCreateHandler::run()
2027
2056
  {
2028
2057
  const string &name = getRequiredArg();
@@ -2278,6 +2307,7 @@ static const char *optionsOrder[] = {"help",
2278
2307
  "analytics",
2279
2308
  "search",
2280
2309
  "admin",
2310
+ "bucket-list",
2281
2311
  "bucket-create",
2282
2312
  "bucket-delete",
2283
2313
  "bucket-flush",
@@ -2369,6 +2399,7 @@ static void setupHandlers()
2369
2399
  handlers_s["incr"] = new IncrHandler();
2370
2400
  handlers_s["decr"] = new DecrHandler();
2371
2401
  handlers_s["admin"] = new AdminHandler();
2402
+ handlers_s["bucket-list"] = new BucketListHandler();
2372
2403
  handlers_s["bucket-create"] = new BucketCreateHandler();
2373
2404
  handlers_s["bucket-delete"] = new BucketDeleteHandler();
2374
2405
  handlers_s["bucket-flush"] = new BucketFlushHandler();
@@ -18,6 +18,7 @@
18
18
  #include "contrib/lcb-jsoncpp/lcb-jsoncpp.h"
19
19
  #include "placeholders.h"
20
20
  #include <algorithm>
21
+ #include <memory>
21
22
  #include <stdexcept>
22
23
 
23
24
  namespace Pillowfight
@@ -78,8 +79,8 @@ class DocGeneratorBase
78
79
  * @param cur_gen The index of the current generator thread
79
80
  * @return An opaque state object. This should be deleted by the caller
80
81
  */
81
- virtual GeneratorState *createState(int total_gens, int cur_gen) const = 0;
82
- virtual SubdocGeneratorState *createSubdocState(int, int) const
82
+ virtual std::unique_ptr<GeneratorState> createState(int total_gens, int cur_gen) const = 0;
83
+ virtual std::unique_ptr<SubdocGeneratorState> createSubdocState(int, int) const
83
84
  {
84
85
  return NULL;
85
86
  }
@@ -164,9 +165,9 @@ class RawDocGenerator : public DocGeneratorBase
164
165
  }
165
166
  };
166
167
 
167
- GeneratorState *createState(int, int) const
168
+ std::unique_ptr<GeneratorState> createState(int, int) const
168
169
  {
169
- return new MyState(this);
170
+ return std::unique_ptr<GeneratorState>(new MyState(this));
170
171
  }
171
172
 
172
173
  private:
@@ -207,9 +208,9 @@ class PresetDocGenerator : public DocGeneratorBase
207
208
  const PresetDocGenerator *m_parent;
208
209
  };
209
210
 
210
- GeneratorState *createState(int, int) const
211
+ std::unique_ptr<GeneratorState> createState(int, int) const
211
212
  {
212
- return new MyState(this);
213
+ return std::unique_ptr<GeneratorState>(new MyState(this));
213
214
  }
214
215
 
215
216
  protected:
@@ -371,9 +372,9 @@ class JsonDocGenerator : public PresetDocGenerator
371
372
  };
372
373
 
373
374
  public:
374
- virtual SubdocGeneratorState *createSubdocState(int, int) const
375
+ virtual std::unique_ptr<SubdocGeneratorState> createSubdocState(int, int) const
375
376
  {
376
- return new SDGenstate(m_docs);
377
+ return std::unique_ptr<SubdocGeneratorState>(new SDGenstate(m_docs));
377
378
  }
378
379
  };
379
380
 
@@ -424,9 +425,9 @@ class PlaceholderDocGenerator : public DocGeneratorBase
424
425
  }
425
426
 
426
427
  public:
427
- GeneratorState *createState(int total, int cur) const
428
+ std::unique_ptr<GeneratorState> createState(int total, int cur) const
428
429
  {
429
- return new MyState(this, total, cur);
430
+ return std::unique_ptr<GeneratorState>(new MyState(this, total, cur));
430
431
  }
431
432
 
432
433
  private:
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { Connection } from './connection';
3
4
  import { HttpErrorContext } from './errorcontexts';
4
5
  import { RequestSpan } from './tracing';
package/package.json CHANGED
@@ -1 +1 @@
1
- {"bugs":{"url":"http://www.couchbase.com/issues/browse/JSCBC"},"description":"The official Couchbase Node.js Client Library.","engines":{"node":">=10.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","debug":"^4.3.4","nan":"^2.15.0","parse-duration":"^1.0.2","prebuild-install":"^7.0.1"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^3.2.0","@tsconfig/node10":"^1.0.8","@types/bindings":"^1.5.1","@types/debug":"^4.1.7","@types/node":"^17.0.23","@typescript-eslint/eslint-plugin":"^5.18.0","@typescript-eslint/parser":"^5.18.0","chai":"^4.3.6","eslint":"^8.12.0","eslint-config-prettier":"^8.5.0","eslint-plugin-jsdoc":"^38.1.6","eslint-plugin-mocha":"^10.0.3","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^9.2.2","npm-check-updates":"^12.5.8","nyc":"^15.1.0","prebuild":"^11.0.3","prettier":"^2.6.2","segfault-handler":"^1.3.0","semver":"^7.3.6","ts-mocha":"^9.0.2","ts-node":"^10.7.0","typedoc":"^0.22.13","typescript":"^4.6.3","uuid":"^8.3.2"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"3.2.5","config":{"native":false},"scripts":{"install":"prebuild-install || node-gyp rebuild","build":"node-gyp build && tsc","rebuild":"node-gyp rebuild && tsc","prebuild":"prebuild --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"}}
1
+ {"bugs":{"url":"http://www.couchbase.com/issues/browse/JSCBC"},"description":"The official Couchbase Node.js Client Library.","engines":{"node":">=10.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","debug":"^4.3.4","nan":"^2.17.0","parse-duration":"^1.0.2","prebuild-install":"^7.1.1"},"devDependencies":{"@trivago/prettier-plugin-sort-imports":"^3.4.0","@tsconfig/node10":"^1.0.9","@types/bindings":"^1.5.1","@types/debug":"^4.1.7","@types/node":"^18.11.9","@typescript-eslint/eslint-plugin":"^5.42.0","@typescript-eslint/parser":"^5.42.0","chai":"^4.3.6","eslint":"^8.26.0","eslint-config-prettier":"^8.5.0","eslint-plugin-jsdoc":"^39.6.2","eslint-plugin-mocha":"^10.1.0","eslint-plugin-node":"^11.1.0","expose-gc":"^1.0.0","mocha":"^10.1.0","npm-check-updates":"^16.3.16","nyc":"^15.1.0","prebuild":"^11.0.4","prettier":"^2.7.1","segfault-handler":"^1.3.0","semver":"^7.3.8","ts-mocha":"^10.0.0","ts-node":"^10.9.1","typedoc":"^0.23.20","typescript":"^4.8.4","uuid":"^9.0.0"},"repository":{"type":"git","url":"http://github.com/couchbase/couchnode.git"},"version":"3.2.6","config":{"native":false},"scripts":{"install":"prebuild-install || node-gyp rebuild","build":"node-gyp build && tsc","rebuild":"node-gyp rebuild && tsc","prebuild":"prebuild --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"}}