@tachyon-rs/server 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -67
- package/package.json +10 -4
package/README.md
CHANGED
|
@@ -1,87 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @tachyon-rs/server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bindings NAPI nativos do tachyon-rs para Node.js e Bun. Este pacote e a ponte entre o servidor HTTP em Rust e o runtime JavaScript.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> **Nota:** Este pacote e usado internamente pelo [`tachyon-rs`](https://www.npmjs.com/package/tachyon-rs). Para a maioria dos casos, use `tachyon-rs` diretamente.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
1. Click **Use this template**.
|
|
10
|
-
2. **Clone** your project.
|
|
11
|
-
3. Run `yarn install` to install dependencies.
|
|
12
|
-
4. Run `yarn napi rename -n [@your-scope/package-name] -b [binary-name]` command under the project folder to rename your package.
|
|
13
|
-
|
|
14
|
-
## Install this test package
|
|
7
|
+
## Instalacao
|
|
15
8
|
|
|
16
9
|
```bash
|
|
17
|
-
|
|
10
|
+
npm install @tachyon-rs/server
|
|
18
11
|
```
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Build
|
|
23
|
-
|
|
24
|
-
After `yarn build/npm run build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs).
|
|
25
|
-
|
|
26
|
-
### Test
|
|
27
|
-
|
|
28
|
-
With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want.
|
|
29
|
-
|
|
30
|
-
### CI
|
|
31
|
-
|
|
32
|
-
With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@20`, `@node22`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms.
|
|
33
|
-
|
|
34
|
-
### Release
|
|
35
|
-
|
|
36
|
-
Release native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more.
|
|
37
|
-
|
|
38
|
-
With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**.
|
|
13
|
+
O binario nativo correto para sua plataforma e instalado automaticamente via `optionalDependencies`.
|
|
39
14
|
|
|
40
|
-
|
|
15
|
+
### Plataformas suportadas
|
|
41
16
|
|
|
42
|
-
|
|
17
|
+
| Plataforma | Arquitetura | Pacote |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| Linux | x64 | `@tachyon-rs/server-linux-x64-gnu` |
|
|
20
|
+
| macOS | x64 | `@tachyon-rs/server-darwin-x64` |
|
|
21
|
+
| macOS | ARM64 | `@tachyon-rs/server-darwin-arm64` |
|
|
22
|
+
| Windows | x64 | `@tachyon-rs/server-win32-x64-msvc` |
|
|
43
23
|
|
|
44
|
-
|
|
24
|
+
## Uso direto (baixo nivel)
|
|
45
25
|
|
|
46
|
-
|
|
26
|
+
```typescript
|
|
27
|
+
import { TachyonRawServer } from '@tachyon-rs/server'
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
const server = new TachyonRawServer({
|
|
30
|
+
bindAddr: '0.0.0.0:3000',
|
|
31
|
+
workers: 4,
|
|
32
|
+
security: 'basic',
|
|
33
|
+
compressionThreshold: 1024,
|
|
34
|
+
})
|
|
51
35
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
$ ava --verbose
|
|
62
|
-
|
|
63
|
-
✔ sync function from native code
|
|
64
|
-
✔ sleep function from native code (201ms)
|
|
65
|
-
─
|
|
66
|
-
|
|
67
|
-
2 tests passed
|
|
68
|
-
✨ Done in 1.12s.
|
|
36
|
+
server.start((request) => {
|
|
37
|
+
return {
|
|
38
|
+
status: 200,
|
|
39
|
+
body: JSON.stringify({ hello: 'world' }),
|
|
40
|
+
headers: [{ name: 'Content-Type', value: 'application/json' }],
|
|
41
|
+
}
|
|
42
|
+
})
|
|
69
43
|
```
|
|
70
44
|
|
|
71
|
-
##
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
45
|
+
## Configuracao
|
|
46
|
+
|
|
47
|
+
| Opcao | Tipo | Default | Descricao |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `bindAddr` | `string` | `"0.0.0.0:3000"` | Endereco e porta |
|
|
50
|
+
| `workers` | `number` | CPU count | Threads de worker |
|
|
51
|
+
| `stackSizeKb` | `number` | `64` | Stack size das coroutines (KB) |
|
|
52
|
+
| `buffersPerWorker` | `number` | `128` | Buffers no pool por worker |
|
|
53
|
+
| `bufferSize` | `number` | `8192` | Tamanho de cada buffer (bytes) |
|
|
54
|
+
| `timeoutSecs` | `number` | `30` | Timeout do handler (segundos) |
|
|
55
|
+
| `tcpNodelay` | `boolean` | `true` | TCP_NODELAY |
|
|
56
|
+
| `reusePort` | `boolean` | `true` | SO_REUSEPORT (Linux/BSD) |
|
|
57
|
+
| `tcpFastopen` | `boolean` | `true` | TCP Fast Open (Linux) |
|
|
58
|
+
| `busyPollUs` | `number` | `0` | SO_BUSY_POLL microseconds |
|
|
59
|
+
| `recvBufSize` | `number` | `0` | SO_RCVBUF (0 = OS default) |
|
|
60
|
+
| `sendBufSize` | `number` | `0` | SO_SNDBUF (0 = OS default) |
|
|
61
|
+
| `security` | `string` | `"basic"` | `"none"` \| `"basic"` \| `"strict"` |
|
|
62
|
+
| `compressionThreshold` | `number` | `1024` | 0 = comprime tudo, -1 = desabilitado |
|
|
63
|
+
|
|
64
|
+
## Build local
|
|
78
65
|
|
|
79
66
|
```bash
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
bun install
|
|
68
|
+
bun run build # release
|
|
69
|
+
bun run build:debug # debug
|
|
83
70
|
```
|
|
84
71
|
|
|
85
|
-
|
|
72
|
+
## Licenca
|
|
86
73
|
|
|
87
|
-
|
|
74
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachyon-rs/server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "Template project for writing node package with napi-rs",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"format:toml": "taplo format",
|
|
49
49
|
"format:rs": "cargo fmt",
|
|
50
50
|
"lint": "oxlint .",
|
|
51
|
-
"
|
|
51
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
52
52
|
"test": "ava",
|
|
53
53
|
"preversion": "napi build --platform && git add .",
|
|
54
54
|
"version": "napi version",
|
|
@@ -102,5 +102,11 @@
|
|
|
102
102
|
"singleQuote": true,
|
|
103
103
|
"arrowParens": "always"
|
|
104
104
|
},
|
|
105
|
-
"packageManager": "bun@1.2.5"
|
|
106
|
-
|
|
105
|
+
"packageManager": "bun@1.2.5",
|
|
106
|
+
"optionalDependencies": {
|
|
107
|
+
"@tachyon-rs/server-win32-x64-msvc": "0.2.10",
|
|
108
|
+
"@tachyon-rs/server-darwin-x64": "0.2.10",
|
|
109
|
+
"@tachyon-rs/server-linux-x64-gnu": "0.2.10",
|
|
110
|
+
"@tachyon-rs/server-darwin-arm64": "0.2.10"
|
|
111
|
+
}
|
|
112
|
+
}
|