Skip to content

Asynchronous request handling #77

@ShaunMaher

Description

@ShaunMaher

Hello.

Would it be possible to make RestPS handle requests asynchronously?

Imagine I have a dummy endpoint script that just does the following:

Start-Sleep -Seconds 30
Return "Wake Up"

If this endpoint is triggered, the /endpoint/status endpoint (and all other endpoints) also stop responding until the 30 second sleep is complete.

I'm no powershell expert like you kind folks but I did a little reading.

There is a "HttpListener.GetContextAsync" method but that just let's do do other things until the request context is ready. Apply timeouts, etc. It doesn't run the response generation logic Async.

Maybe, once you have a Context (Start-RestPSListener.ps1:80) you could pass off to a Job that does everything from Start-RestPSListener.ps1:85 to 163 so the loop that starts on Start-RestPSListener.ps1:75 could immediately get ready to "Invoke-GetContext" the next incoming (parallel) request. I dunno. I'm just guessing.

Cheers.
Shaun.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions