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
1 /sbin/init | |
+-- 196 /usr/sbin/syslogd -s | |
+-- 354 /usr/sbin/cron -s | |
+-- 391 login | |
+-- 400 bash | |
+-- 701 /usr/local/bin/pstree |
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
FROM openjdk:8u212-jdk-slim | |
RUN apt-get update \ | |
&& apt-get install -y --no-install-recommends \ | |
Python3=3.5.3-1 \ | |
Python3-pip=9.0.1-2+deb9u1 \ | |
&& rm -rf /var/lib/apt/lists/* | |
COPY requirements.txt requirements.txt | |
RUN pip3 install --upgrade -r requirements.txt |
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
suspend fun <T> awaitEvent(block: (h: Handler<T>) -> Unit): T { | |
return suspendCancellableCoroutine { cont: CancellableContinuation<T> -> | |
try { | |
block.invoke(Handler { t -> | |
cont.resume(t) | |
}) | |
} catch (e: Exception) { | |
cont.resumeWithException(e) | |
} | |
} |
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
suspend fun HttpServer.listenAwait(port: Int, host: String): HttpServer |
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
fun listen(port: Int, host: String, listenHandler: Handler<AsyncResult<HttpServer>>): HttpServer |
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
suspend fun placeOrder(userData: UserData, orderData: OrderData): Order { | |
val user = createUser(userData) // asynchronous call to user service | |
val order = createOrder(user, orderData) // asynchronous call to order service | |
return order | |
} | |
suspend fun createUser(userData: UserData): User { ... } | |
suspend fun createOrder(user: User, orderData: OrderData): Order { ... } |
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
fun placeOrder(userData: UserData, orderData: OrderData): Order { | |
val user = createUser(userData) // synchronous call to user service | |
val order = createOrder(user, orderData) // synchronous call to order service | |
return order | |
} | |
fun createUser(userData: UserData): User { ... } | |
fun createOrder(user: User, orderData: OrderData): Order { ... } |
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
import kotlinx.coroutines.* | |
fun main() { | |
GlobalScope.launch { // launch new coroutine in background and continue | |
delay(1000L) // non-blocking delay for 1 second (default time unit is ms) | |
println("World!") // print after delay | |
} | |
println("Hello,") // main thread continues while coroutine is delayed | |
Thread.sleep(2000L) // block main thread for 2 seconds to keep JVM alive | |
} |
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
val server = vertx.createHttpServer().listenAwait() | |
val response = WebClient.create(vertx) | |
.get(server.actualPort(), "localhost", "").sendAwait() | |
println(response.bodyAsString()) |
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
vertx.createHttpServer().listen { | |
if (it.succeeded()) { | |
val server = it.result() | |
WebClient.create(vertx).get(server.actualPort(), "localhost", "").send { | |
if (it.succeeded()) { | |
val response = it.result() | |
println(response.bodyAsString()) | |
} | |
} | |
} |