-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66e6485
commit b99b6fb
Showing
5 changed files
with
66 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM postgres | ||
|
||
USER postgres | ||
WORKDIR /app | ||
|
||
COPY src/sql/create-schema.sql /docker-entrypoint-initdb.d/1_create.sql | ||
COPY src/sql/insert-test-data.sql /docker-entrypoint-initdb.d/2_insert-test-data.sql | ||
|
||
COPY --chown=postgres:postgres ./tests/scripts/wait-for-postgres.sh ./bin/wait-for-postgres.sh | ||
RUN chmod +x ./bin/wait-for-postgres.sh | ||
|
||
EXPOSE 5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
plugins { | ||
kotlin("jvm") version "1.9.25" | ||
} | ||
|
||
group = "pt.isel" | ||
version = "unspecified" | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework:spring-core:6.0.0") | ||
|
||
// To use SLF4J | ||
// For logging purposes | ||
implementation("org.slf4j:slf4j-api:2.0.16") | ||
runtimeOnly("org.slf4j:slf4j-simple:2.0.16") | ||
|
||
testImplementation(kotlin("test")) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
kotlin { | ||
jvmToolchain(21) | ||
} |
23 changes: 23 additions & 0 deletions
23
lesson40-demo-load-balancing/src/main/kotlin/pt/isel/App.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package pt.isel | ||
|
||
import org.slf4j.LoggerFactory | ||
import org.springframework.util.StopWatch | ||
import java.net.URI | ||
import java.net.http.HttpClient | ||
import java.net.http.HttpRequest | ||
import java.net.http.HttpResponse.BodyHandlers | ||
|
||
private val logger = LoggerFactory.getLogger("main") | ||
|
||
fun main() { | ||
val httpClient = HttpClient.newHttpClient() | ||
val request = HttpRequest.newBuilder(URI.create("http://localhost:8088/api/status/ip")).GET().build() | ||
while (true) { | ||
val sw = StopWatch().also { it.start() } | ||
logger.info("Request sent...") | ||
val response = httpClient.send(request, BodyHandlers.ofString()) | ||
sw.stop() | ||
logger.info("...response received: {}, {}, {}", response.statusCode(), sw.totalTimeMillis, response.body()) | ||
Thread.sleep(2000) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters