Skip to content

Commit

Permalink
ch10 progress
Browse files Browse the repository at this point in the history
  • Loading branch information
spamegg1 committed Sep 12, 2024
1 parent 0dc4488 commit af77d5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ object LmdbImpl:
On Ubuntu I had to install these (I think `libcurl` might have been pre-installed already?):
```bash
sudo apt install clang libuv1-dev libcurl4-gnutls-dev liblmdb-dev
sudo apt install clang libuv1-dev libcurl4-gnutls-dev liblmdb-dev libhttp-parser-dev
```
The author did all of this work. But if we wanted to do this on our own,
Expand All @@ -154,6 +154,20 @@ and use [`sn-bindgen`](https://github.com/indoorvivants/sn-bindgen) to generate
I haven't tried that myself, but that's the way to go.
#### Unmaintained Node HTTP parser library (WIP)
The [`http-parse` library of Chapter 10](https://github.com/nodejs/http-parser) is no longer maintained.
It was ported to [llhttp](https://github.com/nodejs/llhttp).
It is possible to install this on Ubuntu with
```bash
sudo apt install node-llhttp
```
But I don't know how to link it with Scala Native.
It's written in Typescript, which generates C output.
The output then has to be compiled, and then linked to SN.
### Running the Gatling load simulation
I modified the `install_gatling.sh` script from the book, now it's a Scala-cli
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/ch10/parsing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ trait Parsing:
0

@link("http_parser")
// @link("llhttp")
@extern
object HttpParser:
type Parser = CStruct8[
Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/ch10/service.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import util.boundary, boundary.break
import concurrent.{Future, ExecutionContext}
import argonaut.{Argonaut, EncodeJson, DecodeJson, Parse}
import Argonaut.ToJsonIdentity

import ch07.LibUVConstants.*, ch07.LibUV.uv_run, ServiceHelpers.*

given ec: ExecutionContext = EventLoop // changed implicit val
given ec: ExecutionContext = EventLoop

@main
def libuvService(args: String*): Unit =
def libuvService: Unit =
Service()
.getAsync("/async/"): r =>
Future(OK(Map("asyncMessage" -> s"got (async routed) request $r")))
Expand Down

0 comments on commit af77d5e

Please sign in to comment.