Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KTOR-7359 Implement a suspending version of EmbeddedServer.start and EmbeddedServer.stop #4481

Open
wants to merge 16 commits into
base: 3.1.0-eap
Choose a base branch
from

Conversation

whyoleg
Copy link
Contributor

@whyoleg whyoleg commented Nov 14, 2024

Subsystem
Server

Motivation

Solution

Only startSuspend and stopSuspend functions were added with minimal bridge for JVM and Native implementations.
That was done like this, because in most cases users will anyway call start and stop, and it's not clear, which engines could support suspend start/stop (e.g CIO can, for sure, but for others it's not that clear).
That's why minimally invasive changes were implemented to support wasm-js and js case, where runBlocking is not available.

PR also contains changes to EngineTestBase for js and wasm-js as this is the main consumer for those new APIs.

Note: probably some commonization is possible for both EmbeddedServer and EngineTestBase, it should be investigated.

osipxd and others added 16 commits November 14, 2024 11:25
* Use stdlib `use` extension-function
* Update type checks
…torio#4411)

* Drop `jvmAndNix` shared source set
* Commonize `ktor-network` and `ktor-network-tls`
* Support TCP and Unix sockets for wasm-js and js on Node
* Move `supportsUnixDomainSockets` to posix and use Platform instead of expect/actual
* Support multiple client engines for JS/WasmJs
* CIO client Js/WasmJs support
* Enable CIO tests in client tests
* Make client engines `data object` to have `toString`
* Make ClientLoader work with multiple engines on js/wasmJs and so test CIO engine on nodejs(js+wasmJs)
)

* KTOR-6632 Support receiving multipart data with Ktor client
Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please check the CI?

* That's why we assign port after the server is started in [startServer]
* Note: this means, that [port] can be used only after calling [createAndStartServer] or [startServer].
*/
private var _port: Int = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please consider extracting a constant for non initialized value and use a different value (other than default port)

@@ -101,7 +125,8 @@ actual constructor(
// we start it on the global scope because we don't want it to fail the whole test
// as far as we have retry loop on call side
val starting = GlobalScope.async {
server.start(wait = false)
server.startSuspend(wait = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make an extension function here like server.listeningPorts()

@e5l
Copy link
Member

e5l commented Nov 15, 2024

Please check the code style problems

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants