Skip to content

Commit

Permalink
fixes #6: update the packages to luvit/ org
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal2453 committed Jan 10, 2025
1 parent 857d417 commit a1c28b3
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 43 deletions.
9 changes: 5 additions & 4 deletions docs/coro-channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ layout: doc

# coro-channel

Documentation for the [coro-channel](https://github.com/luvit/lit/blob/master/deps/coro-channel.lua) module, version 3.0.3.
Documentation for the [coro-channel](https://github.com/luvit/lit/blob/master/deps/coro-channel.lua) library, version 3.0.3.

[coro-channel](https://github.com/luvit/lit/blob/master/deps/coro-channel.lua) is a wrapper module that wraps [stream handles](https://github.com/luvit/luv/blob/master/docs.md#uv_stream_t--stream-handle) (or any other handle that inherits stream) to provide a sync style read/write interface making use of Lua coroutines, and without blocking the event loop.
[coro-channel](https://github.com/luvit/lit/blob/master/deps/coro-channel.lua) is a wrapper library that wraps [stream handles](https://github.com/luvit/luv/blob/master/docs.md#uv_stream_t--stream-handle) (or any other handle that inherits stream) to provide a sync style read/write interface making use of Lua coroutines, and without blocking the event loop.

### Installation

```sh
lit install creationix/coro-channel
lit install luvit/coro-channel
```
[On Lit search.](https://luvit.io/lit.html#coro-channel)

[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-channel)

----

Expand Down
44 changes: 24 additions & 20 deletions docs/coro-fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,42 @@ layout: doc

# coro-fs

Documentation for the module [coro-fs](https://github.com/luvit/lit/blob/master/deps/coro-fs.lua), version 2.2.4.
Documentation for the [coro-fs](https://github.com/luvit/lit/blob/master/deps/coro-fs.lua) library, version 2.2.4.

[coro-fs](https://github.com/luvit/lit/blob/master/deps/coro-fs.lua) is a library for asynchronous non-blocking filesystem operations that keeps the synchronous code style, making use of Lua coroutines.

Luvit's built-in `fs` module already has asynchronous non-blocking operations (the calls not suffixed with `Sync`, as `Sync` calls *will* block a thread in the threadpool!) but they use the ugly callbacks!

This allows you to perform all the FS operations Luvit built-in `fs` has, but with a synchronous code style making use of Lua coroutines.

Note: By choosing to do asynchronous FS, you are making a tradeoff.
First off, Luvit (and coro-fs) uses Libuv for filesystem IO, while the synchronous blocking calls in the Luvit `fs` API (e.x. `fs.writeFileSync`) will block a thread, they *still* allow other I/O operations to happen, and the event loop can still tick just fine, this is because Libuv has a threadpool which all I/O happens in (by default 4 threads and can be changed with the `UV_THREADPOOL_SIZE` environment variable), one of those threads is blocked instead. So you can aboslutely be doing 4 blocking reads/writes (by default) before you actually run into issues where you need asynchronous FS. For example, if you are running a web server where you read a file and send it back, it is possible that you could receive 4 connections at the same time, they all concurrently read some file and send the responses back without interrupting each other.
The tradeoff you make by using asynchronous FS is performance, synchronous I/O is much faster but it blocks a thread in the threadpool, while asynchronous I/O is much slower but won't block any threads. Unless you are running a very busy server, I can't imagine you need asynchronous FS!

Another Note: Luvit built-in async fs *ALREADY* has coroutine support which achieve a similar purpose to this module:
```lua
local fs = require('fs')
local co = coroutine.running()
local contents = fs.readFile('./my_file.txt', co)
print("The file contains: ", contents)
```
vs
```lua
local coro_fs = require('coro-fs')
local contents = coro_fs.readFile('./my_file.txt')
print("The file contains: ", contents)
```
> Note: By choosing to do asynchronous FS, you are making a tradeoff.
> First off, Luvit (and coro-fs) uses Libuv for filesystem IO, while the synchronous blocking calls in the Luvit `fs` API (e.x. `fs.writeFileSync`) will block a thread, they *still* allow other I/O operations to happen, and the event loop can still tick just fine, this is because Libuv has a threadpool which all I/O happens in (by default 4 threads and can be changed with the `UV_THREADPOOL_SIZE` environment variable), so one of those threads is blocked instead of the main thread.
>
> In other words you may execute up to 4 blocking reads/writes (by default) concurrently before you actually run into issues where you need asynchronous FS. For example, if you are running a web server where you read a file and send it back, it is possible that you could receive 4 connections at the same time, they all concurrently read some file and send the responses back without interrupting each other.
>
> The tradeoff you make by using asynchronous FS is performance, synchronous I/O is much faster but it blocks a thread in the threadpool, while asynchronous I/O is much slower but won't block any threads. Unless you are running a very busy server, I can't imagine you need asynchronous FS!
> Note: Luvit built-in async fs *ALREADY* has coroutine support which achieve a similar purpose to this module:
> ```lua
> local fs = require('fs')
> local co = coroutine.running()
> local contents = fs.readFile('./> my_file.txt', co)
> print("The file contains: ", contents)
> ```
> vs
> ```lua
> local coro_fs = require('coro-fs')
> local contents = coro_fs.readFile('./my_file.txt')
> print("The file contains: ", contents)
> ```
### Installation
```sh
lit install creationix/coro-fs
lit install luvit/coro-fs
```
[On Lit search.](https://luvit.io/lit.html#coro-fs)
[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-fs)

----

Expand Down
5 changes: 3 additions & 2 deletions docs/coro-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ Many thanks for [@trumedian](https://github.com/truemedian) for helping out with
### Installation

```sh
lit install creationix/coro-http
lit install luvit/coro-http
```
[On Lit search.](https://luvit.io/lit.html#coro-http)

[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-http)

----

Expand Down
7 changes: 4 additions & 3 deletions docs/coro-net.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ layout: doc

# coro-net

Documentation for the module [coro-net](https://github.com/luvit/lit/blob/master/deps/coro-net.lua), version 3.2.1.
Documentation for the [coro-net](https://github.com/luvit/lit/blob/master/deps/coro-net.lua) library, version 3.2.1.

[coro-net](https://github.com/luvit/lit/blob/master/deps/coro-net.lua) is a library for handling TCP and generally pipes, with an optional secure-layer support using a synchronous style interface.

### Installation

```sh
lit install creationix/coro-net
lit install luvit/coro-net
```
[On Lit search.](https://luvit.io/lit.html#coro-net)

[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-net)

----

Expand Down
11 changes: 6 additions & 5 deletions docs/coro-spawn.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ layout: doc

# coro-spawn

Documentation for the [coro-spawn](https://github.com/luvit/lit/blob/master/deps/coro-spawn.lua) module, version 3.0.3.
Documentation for the [coro-spawn](https://github.com/luvit/lit/blob/master/deps/coro-spawn.lua) library, version 3.0.3.

[coro-spawn](https://github.com/luvit/lit/blob/master/deps/coro-spawn.lua) is single-function module that provides spawning child-processes with a synchronous interface making use of Lua coroutines.
[coro-spawn](https://github.com/luvit/lit/blob/master/deps/coro-spawn.lua) is single-function library that provides spawning child-processes with a synchronous interface making use of Lua coroutines.

Throughout the documentation, we will refer to the function return of this module as `spawn`. And it is obtained by calling `require("coro-spawn")`.
Throughout the documentation, we will refer to the function return of this library as `spawn`. It is accessed by calling `require("coro-spawn")`.

### Installation

```sh
lit install creationix/coro-spawn
lit install luvit/coro-spawn
```
[On Lit search.](https://luvit.io/lit.html#coro-spawn)

[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-spawn)

----

Expand Down
5 changes: 3 additions & 2 deletions docs/coro-split.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ layout: doc

# coro-split

Documentation for the [coro-split](https://github.com/luvit/lit/blob/master/deps/coro-split.lua) module, version 2.0.2.
Documentation for the [coro-split](https://github.com/luvit/lit/blob/master/deps/coro-split.lua) library, version 2.0.2.

[coro-split](https://github.com/luvit/lit/blob/master/deps/coro-split.lua) is single-function module that takes multiple functions as input, wraps each of them in a coroutine and runs it, and yields until all of the provided tasks are completed.

Throughout the documentation, we will refer to the function return of this module as `split`. And it is obtained by calling `require("coro-split")`.
Throughout the documentation, we will refer to the function return of this module as `split`. It is accessed by calling `require("coro-split")`.

### Installation

```sh
lit install creationix/coro-split
```

[On Lit search.](https://luvit.io/lit.html#coro-split)

----
Expand Down
9 changes: 5 additions & 4 deletions docs/coro-websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ layout: doc

# coro-websocket

Documentation for the module [coro-websocket](https://github.com/luvit/lit/blob/master/deps/coro-websocket.lua), version 3.1.0.
Documentation for the [coro-websocket](https://github.com/luvit/lit/blob/master/deps/coro-websocket.lua) library, version 3.1.0.

[coro-websocket](https://github.com/luvit/lit/blob/master/deps/coro-websocket.lua) is a library that implements the WebSocket WS(s) protocol with a synchronous style interface making use of Lua coroutines.
[coro-websocket](https://github.com/luvit/lit/blob/master/deps/coro-websocket.lua) is a library that implements the [WebSocket](https://en.wikipedia.org/wiki/WebSocket) WS(s) protocol with a synchronous style interface making use of Lua coroutines.

### Installation

```sh
lit install creationix/coro-websocket
lit install luvit/coro-websocket
```
[On Lit search.](https://luvit.io/lit.html#coro-websocket)

[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-websocket)

----

Expand Down
6 changes: 3 additions & 3 deletions docs/coro-wrapper.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layout: doc

# coro-wrapper

Documentation for the [coro-wrapper](https://github.com/luvit/lit/blob/master/deps/coro-wrapper.lua) module, version 3.1.0.
Documentation for the [coro-wrapper](https://github.com/luvit/lit/blob/master/deps/coro-wrapper.lua) library, version 3.1.0.

[coro-wrapper](https://github.com/luvit/lit/blob/master/deps/coro-wrapper.lua) is an adapter module for applying decoders/encoders/merger adapters to [coro-channel](https://bilal2453.github.io/coro-docs/docs/coro-channel.html) readers and writers.

Expand All @@ -14,9 +14,9 @@ The rest of the adapters have a similar concept.
### Installation

```sh
lit install creationix/coro-wrapper
lit install luvit/coro-wrapper
```
[On Lit search.](https://luvit.io/lit.html#coro-wrapper)
[On Lit search.](https://luvit.io/lit.html#author:luvit%20coro-wrapper)

----

Expand Down

0 comments on commit a1c28b3

Please sign in to comment.