(
showInitialStatus = true
)
| 171 | } |
| 172 | |
| 173 | async getConnectionSettings( |
| 174 | showInitialStatus = true |
| 175 | ): Promise<StorageEngineConnectionConfig> { |
| 176 | const { |
| 177 | flags: { dgraph: dgraphHost, storage = 'dgraph' }, |
| 178 | } = await this.parse( |
| 179 | this.constructor as Interfaces.Input<{ |
| 180 | dev: boolean |
| 181 | dgraph: string |
| 182 | storage: string |
| 183 | }> |
| 184 | ) |
| 185 | // TODO: refactor this to handle multi storage solutions better |
| 186 | if (storage === 'dgraph') { |
| 187 | // first check for passed flag or env variable |
| 188 | if (dgraphHost) { |
| 189 | showInitialStatus && |
| 190 | this.logger.info(`Dgraph host set as: ${dgraphHost}`) |
| 191 | return getStorageEngineConnectionConfig(dgraphHost) |
| 192 | } |
| 193 | // next check for value defined in config file |
| 194 | const config = this.getCGConfig('cloudGraph') |
| 195 | if (config && config.storageConfig) { |
| 196 | showInitialStatus && |
| 197 | this.logger.info( |
| 198 | `Dgraph host set as: ${this.getHost(config.storageConfig)}` |
| 199 | ) |
| 200 | return config.storageConfig |
| 201 | } |
| 202 | // nothing found, return default location |
| 203 | |
| 204 | showInitialStatus && |
| 205 | this.logger.info(`Dgraph host set as: ${getDefaultEndpoint()}`) |
| 206 | return getDefaultStorageEngineConnectionConfig() |
| 207 | } |
| 208 | return getDefaultStorageEngineConnectionConfig() |
| 209 | } |
| 210 | |
| 211 | getHost(config: StorageEngineConnectionConfig): string { |
| 212 | return `${config.scheme}://${config.host}:${config.port}` |
nothing calls this directly
no test coverage detected