import { join } from "path" ; import TableConfiguration from "../table/TableConfiguration" ; import TableServer from "../table/TableServer" ; import { DEFAULT_TABLE_LOKI_DB_PATH } from "../table/utils/constants" ; import * as Logger from "./Logger" ; import NoLoggerStrategy from "./NoLoggerStrategy" ; import VSCChannelLoggerStrategy from "./VSCChannelLoggerStrategy" ; import VSCChannelWriteStream from "./VSCChannelWriteStream" ; import VSCEnvironment from "./VSCEnvironment" ; import VSCServerManagerBase from "./VSCServerManagerBase" ; import VSCServerManagerClosedState from "./VSCServerManagerClosedState" ; export default class VSCServerManagerTable extends VSCServerManagerBase { public readonly accessChannelStream = new VSCChannelWriteStream ( "Azurite Table" ) ; private debuggerLoggerStrategy = new VSCChannelLoggerStrategy ( "Azurite Table Debug" ) ; public constructor ( ) { super ( "Azurite Table Service" , new VSCServerManagerClosedState ( ) ) ; } public getStartCommand ( ) { return "azurite.start_table" ; } public getCloseCommand ( ) { return "azurite.close_table" ; } public getCleanCommand ( ) { return "azurite.clean_table" ; } public async createImpl ( ) { const config = await this . getConfiguration ( ) ; Logger . default . strategy = config . enableDebugLog ? this . debuggerLoggerStrategy : new NoLoggerStrategy ( ) ; this . server = new TableServer ( config ) ; } public async startImpl ( ) { await this . server ! . start ( ) ; } public async closeImpl ( ) { this . server ! . close ( ) ; } public async cleanImpl ( ) { await this . createImpl ( ) ; await this . server ! . clean ( ) ; } private async getConfiguration ( ) { const env = new VSCEnvironment ( ) ; const location = await env . location ( ) ; const config = new TableConfiguration ( env . tableHost ( ) , env . tablePort ( ) , join ( location , DEFAULT_TABLE_LOKI_DB_PATH ) , ( await env . debug ( ) ) === true , ! env . silent ( ) , this . accessChannelStream , undefined , env . loose ( ) , env . skipApiVersionCheck ( ) , env . cert ( ) , env . key ( ) , env . pwd ( ) , env . oauth ( ) , env . disableProductStyleUrl ( ) ) ; return config ; } }