Skip to content

Conversation

@jolhoeft
Copy link
Contributor

@jolhoeft jolhoeft commented Dec 26, 2017

Here is an example of serving files in a separate thread. It should cover most cases where a separate thread is required, such as accessing a database.

There are actually two approaches illustrated here. One reads the whole file into memory, the other streams the file in chunks, but requires a second thread for the Response body. I don't like this two threaded approach, but haven't been able to figure out a way around it. Suggestions for a better approach would be appreciated.

I am working on an update to the guide pages to go with this example (which I will submit along with the Request body processing guide pages I'm working on.)

@jolhoeft jolhoeft changed the title Add an example of serving files dosc(server): Add an example of serving files Dec 26, 2017
@jolhoeft jolhoeft changed the title dosc(server): Add an example of serving files docs(server): Add an example of serving files Dec 26, 2017
@jolhoeft jolhoeft force-pushed the file_example branch 3 times, most recently from 737e2e9 to 68030c9 Compare December 27, 2017 23:55
@jolhoeft
Copy link
Contributor Author

Two threads are not needed. I had a mental block, thinking I could only have one channel per thread, which isn't true. I've updated this example. There are still two versions, because the non-streaming version is simpler for small amounts of data/processing.

@seanmonstar seanmonstar merged commit 6ab4895 into hyperium:master Dec 28, 2017
@seanmonstar
Copy link
Member

Awesome work!

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.

2 participants