File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -965,6 +965,17 @@ class Client extends EventEmitter {
965965 addAlgorithm ( type , fn ) {
966966 return internal ( this ) . influx . addAlgorithm ( type , fn ) ;
967967 }
968+ /**
969+ * Add plugin function
970+ * @param {Function } fn - plugin function
971+ * @since 2.11.0
972+ * @example
973+ * const noCache = require('superagent-no-cache')
974+ * client.addPlugin(noCache);
975+ */
976+ addPlugin ( fn ) {
977+ return internal ( this ) . influx . addPlugin ( fn ) ;
978+ }
968979}
969980
970981module . exports = Client ;
Original file line number Diff line number Diff line change @@ -200,6 +200,14 @@ class Influx {
200200 addAlgorithm ( type , fn ) {
201201 return internal ( this ) . client . addAlgorithm ( type , fn ) ;
202202 }
203+
204+ /**
205+ * Add plugin function
206+ * @param {Function } fn plugin function
207+ */
208+ addPlugin ( fn ) {
209+ return internal ( this ) . client . addPlugin ( fn ) ;
210+ }
203211}
204212
205213module . exports = Influx ;
Original file line number Diff line number Diff line change @@ -506,6 +506,26 @@ describe('Client', () => {
506506 } ) . catch ( done ) ;
507507 } ) ;
508508
509+ it ( 'get measurement' , done => {
510+ let called = false ;
511+ client . addPlugin ( ( req ) => {
512+ if ( called ) {
513+ return ;
514+ }
515+ if ( ! req . backendServer ) {
516+ done ( new Error ( 'the backend field is null' ) ) ;
517+ }
518+ called = true ;
519+ } ) ;
520+ client . query ( 'http' )
521+ . then ( ( ) => {
522+ if ( ! called ) {
523+ done ( new Error ( 'not called' ) ) ;
524+ }
525+ } )
526+ . catch ( done ) ;
527+ } ) ;
528+
509529 it ( 'drop database' , function ( done ) {
510530 this . timeout ( 5000 ) ;
511531 client . stopHealthCheck ( ) ;
You can’t perform that action at this time.
0 commit comments