()
| 138 | } |
| 139 | |
| 140 | private flush() { |
| 141 | const toFlush = this._statsQueue; |
| 142 | this._statsQueue = []; |
| 143 | if (toFlush) { |
| 144 | // async write to S3 |
| 145 | const key = makeKey(new Date(Date.now())); |
| 146 | this._s3 |
| 147 | .put(key, Buffer.from(toFlush.map(x => JSON.stringify(x)).join('\n')), this._path, { |
| 148 | redundancy: StorageClass.REDUCED_REDUNDANCY, |
| 149 | }) |
| 150 | .then(() => {}) |
| 151 | .catch(e => { |
| 152 | logger.warn(`Caught exception trying to log compilations to ${key}: ${e}`); |
| 153 | }); |
| 154 | } |
| 155 | if (this._flushJob !== undefined) { |
| 156 | clearTimeout(this._flushJob); |
| 157 | this._flushJob = undefined; |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | noteCompilation(compilerId: string, request: ParsedRequest, files: FiledataPair[], buildMethod: string): void { |
| 162 | this._statsQueue.push(makeSafe(new Date(), compilerId, request, files, buildMethod)); |
no test coverage detected