MCPcopy Create free account
hub / github.com/antvis/AVA / load

Method load

src/remote/sqlserver/engine.ts:64–86  ·  view source on GitHub ↗
(configs: DataSourceConfig | DataSourceConfig[])

Source from the content-addressed store, hash-verified

62 }
63
64 async load(configs: DataSourceConfig | DataSourceConfig[]): Promise<void> {
65 const sources = Array.isArray(configs) ? configs : [configs];
66 if (sources.length !== 1) {
67 throw new Error(`SQLServerEngine currently supports exactly one data source, received ${sources.length}`);
68 }
69 const config = sources[0];
70 await this.dispose();
71 if (config.type !== 'sqlserver') {
72 throw new Error(`SQLServerEngine only supports 'sqlserver' data sources, got '${config.type}'`);
73 }
74 // eslint-disable-next-line import/no-named-as-default-member -- see the comment on the mssql import
75 this.pool = new mssql.ConnectionPool(connectionConfig(config.options));
76 // Request promises report transport errors. A pool-level listener also prevents
77 // idle-connection errors from becoming unhandled EventEmitter exceptions.
78 this.pool.on('error', () => undefined);
79 try {
80 await this.pool.connect();
81 this.sourceSchema = config.options.schema;
82 } catch (error) {
83 await this.dispose();
84 throw error;
85 }
86 }
87
88 async schema(signal?: AbortSignal): Promise<Schema> {
89 if (!this.pool) throw new Error('No data loaded. Please call source() first.');

Callers 1

loadFunction · 0.95

Calls 2

disposeMethod · 0.95
connectionConfigFunction · 0.85

Tested by 1

loadFunction · 0.76