Soon-gateway nodejs client

At present, there are several presto nodejs clients. In order to facilitate the connection of presto-gateway, an existing nodejs client is modified.
It can be easily connected to presto-gateway

Principle

Because it is called through the rest api, it is directly added to the original http header X-Presto-Routing-Group

  • Refer to the modified presto client
https://github.com/tagomoris/presto-client-node

< /div>

  • The modified place
    headers.js
< div class="CodeMirror-scroll">

// Add X-Presto-Routing-Group for support presto gateway
Headers.ROUTING_GROUP  = 'X-Presto-Routing-Group';

< /div>

index.js
Add routingGroup for query support

< div id="wiz_cm_1566615616977_503" class="wiz-code-container" data-mode="JavaScript" d ata-theme="default">

 Client.prototype.statementResource = function(opts) {

 var client = this;

< span> var columns = null ;

?< /span>

 if (!opts.catalog &&  !this.catalog)< /span>

 throw {message: "catalog not specified"};

 if (!opts.schema && !this.schema)< /span>

 throw {message: "schema not specified"}; 

 if (!opts.success && !opts.callback) span>

 throw {message: "callback function'success' (or'callback') not spec ified"};

?

 var header = {};

 header[Headers.CATALOG] = opts.catalog || this.catalog;

 header[Headers.SCHEMA] = opts.schema || this.< span class="cm-property">schema;

?

 if (opts.session)< /span>

 header[Headers.SESSION] =  opts.session;

 if (opts.timezone)

 header[Headers.TIME_ZONE] < span class="cm-operator">= opts.timezone; span>

 if ( opts.routingGroup)

 header[Headers.ROUTING_GROUP] = opts.routingGroup;< /span>

?

  • Description
    Already Push the npm warehouse

How to use

  • Installation dependencies
npm install @dalongrong /presto-client

  • Refer to docker-compose operating environment

< div id="wiz_cm_1566615616953_9627" class="wiz-code-container" data-mode="JavaScript" data-theme="default">

< pre class=" CodeMirror-line ">version: “3”< /pre>
services:
 proxy:

 image: dalongrong/ presto-gateway:1.6.1

  ports:

 - "8888:8888"

 - "8082:8082"
 - "8083:8083"

 build: ./ span>

 volumes:

 - "./config.yml.template: /config.yml.template"

 presto1:

 image: < span class="cm-variable">starburstdata/presto span>

 ports:

 - "8080: 8080"

 presto2: 

 image: starburstdata/presto
 ports:

< div>

 - "8081:8080"< /span>

  • Configuration File
< div class="CodeMirror-scroll">

requestRouter:

 port: 8888

 name: prestoRouter< /pre> 
 cacheDir: /var/ log/prestoproxy/cache

 historySize: 1000

 ?

backends:

span>

 - localPort: 8082

 name: presto1

 proxyTo: http://presto1:8080

 routingGroup: < span class="cm-variable">adhoc

? 

 - localPort: 8083

 name: presto2

< div>

 proxyTo: http:/ /presto2: 8080

 routingGroup: scheduled

 ?

server:

span>

 applicationConnectors: 

 - type: http

 port: 8090

 adminConnectors:

 - type: http< /span>

 port: 8091

? span>

notifier:

 smtpHost: localhost

 sm tpPort: 587

 < span class="cm-variable">sender: presto-gw-monitor-noreply@< span class="cm-variable">lyft.com 

 recipients:

 - < span class="cm-variable">prestodev@yourorg.com span>

?

modules:

 - com.lyft.data.gateway.module.ProxyBackendProviderModule

 - com.lyft.data.gateway.module.GatewayProviderModule
< pre class=" CodeMirror-line "> com.lyft.data.gateway.module.NotifierModule span>

 ?

managedApps:

span>

 - com.lyft.data.gateway.GatewayManagedApp 

< span> - com.lyft.data.gateway.ActiveClusterMonitor

?

# Logging settings.

logging:

 # The default level of all loggers. Can be OFF, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.

 level: INFO

< div>

?

 # Logger-specific levels.

 < span class="cm-variable">loggers:

 com.lyft: DEBUG

?

 appenders:

 - type: console

 - type: file

 < span class="cm-variable">currentLogFilename: /var/log/prestoproxy/prestoproxy-java.log

 archivedLogFilenamePattern: /var/log/prestoproxy/prestoproxy-java-%d{ yyyy-MM-dd}-%i.log.gz

 archivedFileCount: 7

 timeZone: UTC

 maxFileSize: 100MB