Uh oh!
There was an error while loading. Please reload this page.
feat: Ability to pass in odbc connection to transport - #320
Conversation
abmusse
commented
Jan 19, 2021
As written now closing of the odbc connection is based on if the |
Examples Using Existing ODBC ConnectionCallbacksconst{ Connection, CommandCall }=require('itoolkit');const{ parseString }=require('xml2js');constodbc=require('odbc');odbc.connect('DSN=*LOCAL',(connectError,connection)=>{if(connectError){throwconnectError;}consttoolkit=newConnection({transport: 'odbc',transportOptions: {odbcConnection: connection,},});constcommand=newCommandCall({type: 'cl',command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)'});toolkit.add(command);toolkit.run((error,xmlOutput)=>{if(error){throwerror;}parseString(xmlOutput,(parseError,result)=>{if(parseError){throwparseError;}console.log(result);// close odbc connectionconnection.close((closeError)=>{if(closeError){throwcloseError;}});});});});Promisesconst{ Connection, CommandCall }=require('itoolkit');const{ parseString }=require('xml2js');constodbc=require('odbc');asyncfunctionmain(){constconnection=awaitodbc.connect('DSN=*LOCAL');consttoolkit=newConnection({transport: 'odbc',transportOptions: {odbcConnection: connection,},});constcommand=newCommandCall({type: 'cl',command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)'});toolkit.add(command);// toolkit.run is asynchronous and invokes callback on completion// therefore need to wrap this is call with a new promise when working with async/await constp=newPromise((resolve,reject)=>{toolkit.run((error,xmlOutput)=>{if(error){reject(error);}parseString(xmlOutput,(parseError,result)=>{if(parseError){reject(parseError);}resolve(result);});});});constresult=awaitp;awaitconnection.close();// close odbc connectionreturnresult;}main().then((result)=>{console.log(result);}).catch((error)=>{console.error(error);}); |
👋 Hi! This pull request has been marked stale due to inactivity. If no further activity occurs, it will automatically be closed. |
alanseiden
commented
Oct 17, 2022
Is this PR still being worked on? It would help us encourage use of the odbc transport if the open/close performance penalty were no longer a concern. |
abmusse
commented
Oct 20, 2022
Its been a minute since we worked on this. I still would like to get this merged as it would enhance performance. |
brandonp42
commented
Oct 19, 2023
Hi @abmusse, did you ever discuss this with the team? The concept of this change seems like a no-brainer to me but I haven't tested it yet. |
abmusse
commented
Oct 19, 2023
Hi @brandonp42 , Thanks for the ping Its been a year and his change has been left on the shelf unattended. IIRC, some the points I wanted to discuss with the team was:
Could you help test things out and give feedback if you encounter "dead" connections or other issues? This would help move forward to getting this change merged in. mkdir ~/test-itoolkit-keep-odbc-open
cd~/test-itoolkit-keep-odbc-open
npm init -y
npm install "https://github.com/abmusse/nodejs-itoolkit#odbc-transport-use-existing-connection" --saveHere is an example passing in the odbc connection: #320 (comment) |
brandonp42
commented
Oct 19, 2023
Sure, I will try to do some testing with this. My use case is for incoming API connections via Express where we call our internal service programs to do things and then return data back to the caller. So for that we generally want to use connection pools that stay alive for performance. As part of that we're also running a custom version of XMLSERVICE that I've fixed some bugs in. |
FYI I've re-based this PR with the latest changes on the main branch. |
Resolves#279
Resolves#282