Skip to content

Provide a way to pass parent CoroutineScope to socket builders #169

Closed
@altavir

Description

@altavir

Currently, raw socket builders like

aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().serverTransport(port = rawSocketPort)

are breaking structured concurrency since each socket creates a new stand-alone Job, not connected to a parent coroutine. It causes problems when we need to automatically close a server socket on parent context failure or manual cancelation.

The solution is to add an optional parent scope parameter in one of the builders and possibly add an additional builder like CoroutineScope.aSocketInScope(), which automatically uses parent socket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions