[K/N] Move aws address for perf infra from code to environment
This commit is contained in:
@@ -1,19 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.jetbrains.network.*
|
||||||
|
|
||||||
external fun require(module: String): dynamic
|
external fun require(module: String): dynamic
|
||||||
|
|
||||||
external val process: dynamic
|
external val process: dynamic
|
||||||
@@ -42,7 +33,20 @@ fun main(args: Array<String>) {
|
|||||||
println("App listening on port " + port + "!")
|
println("App listening on port " + port + "!")
|
||||||
})
|
})
|
||||||
|
|
||||||
app.use("/", router())
|
val connector = if (process.env.LOCAL_AWS != null && process.env.LOCAL_AWS != kotlin.js.undefined) {
|
||||||
|
println("Using local aws instance")
|
||||||
|
UrlNetworkConnector("http://localhost", 9200)
|
||||||
|
} else {
|
||||||
|
val host = process.env.AWS_HOST
|
||||||
|
val region = process.env.AWS_REGION
|
||||||
|
if (host !is String) throw IllegalStateException("AWS_HOST env variable is not defined")
|
||||||
|
if (region !is String) throw IllegalStateException("AWS_REGION env variable is not defined")
|
||||||
|
AWSNetworkConnector(
|
||||||
|
host, region
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.use("/", router(connector))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun normalizePort(port: Int) =
|
fun normalizePort(port: Int) =
|
||||||
|
|||||||
+3
-6
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* that can be found in the LICENSE file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.network
|
package org.jetbrains.network
|
||||||
@@ -57,10 +57,7 @@ external object AWSInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Network connector to work with AWS resources.
|
// Network connector to work with AWS resources.
|
||||||
class AWSNetworkConnector : NetworkConnector() {
|
class AWSNetworkConnector(val AWSDomain: String, val AWSRegion: String) : NetworkConnector() {
|
||||||
val AWSDomain = "vpc-kotlin-perf-service-5e6ldakkdv526ii5hbclzcmpny.eu-west-1.es.amazonaws.com"
|
|
||||||
val AWSRegion = "eu-west-1"
|
|
||||||
|
|
||||||
override fun <T : String?> sendBaseRequest(method: RequestMethod, path: String, user: String?, password: String?,
|
override fun <T : String?> sendBaseRequest(method: RequestMethod, path: String, user: String?, password: String?,
|
||||||
acceptJsonContentType: Boolean, body: String?,
|
acceptJsonContentType: Boolean, body: String?,
|
||||||
errorHandler: (url: String, response: dynamic) -> Nothing?): Promise<T> {
|
errorHandler: (url: String, response: dynamic) -> Nothing?): Promise<T> {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* that can be found in the LICENSE file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.w3c.xhr.*
|
import org.w3c.xhr.*
|
||||||
@@ -216,17 +216,11 @@ internal fun <T> orderedValues(values: List<T>, buildElement: (T) -> CompositeBu
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// ElasticSearch connector for work with custom instance.
|
|
||||||
internal val localHostElasticConnector = UrlNetworkConnector("http://localhost", 9200)
|
|
||||||
// ElasticSearch connector for work with AWS instance.
|
|
||||||
internal val awsElasticConnector = AWSNetworkConnector()
|
|
||||||
internal val networkConnector = awsElasticConnector
|
|
||||||
|
|
||||||
fun urlParameterToBaseFormat(value: dynamic) =
|
fun urlParameterToBaseFormat(value: dynamic) =
|
||||||
value.toString().replace("_", " ")
|
value.toString().replace("_", " ")
|
||||||
|
|
||||||
// Routing of requests to current server.
|
// Routing of requests to current server.
|
||||||
fun router() {
|
fun router(networkConnector: NetworkConnector) {
|
||||||
val express = require("express")
|
val express = require("express")
|
||||||
val router = express.Router()
|
val router = express.Router()
|
||||||
val connector = ElasticSearchConnector(networkConnector)
|
val connector = ElasticSearchConnector(networkConnector)
|
||||||
|
|||||||
Reference in New Issue
Block a user