Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/massivefermion/puddle
A resource pool manager for gleam
https://github.com/massivefermion/puddle
Last synced: 3 months ago
JSON representation
A resource pool manager for gleam
- Host: GitHub
- URL: https://github.com/massivefermion/puddle
- Owner: massivefermion
- Created: 2023-04-05T05:06:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-17T15:00:21.000Z (11 months ago)
- Last Synced: 2024-07-16T15:41:48.560Z (4 months ago)
- Language: Gleam
- Homepage: https://hex.pm/packages/puddle
- Size: 2.71 MB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-gleam - puddle - [📚](https://hexdocs.pm/puddle/) - A resource pool manager for gleam (Packages / Erlang and OTP)
README
![puddle](https://raw.githubusercontent.com/massivefermion/puddle/main/banner.jpg)
[![Package Version](https://img.shields.io/hexpm/v/puddle)](https://hex.pm/packages/puddle)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/puddle/)# puddle
A resource pool manager for gleam
## Quick start
```sh
gleam test # Run the tests
gleam shell # Run an Erlang shell
```## Installation
This package can be added to your Gleam project:
```sh
gleam add puddle
```and its documentation can be found at .
## Usage
```gleam
import gleam/int
import gleam/otp/task
import puddlepub fn main() {
let assert Ok(manager) = puddle.start(4, fn() { Ok(int.random(1024, 8192)) })let fun = fn(n) { n * 2 }
let t1 =
task.async(fn() {
use r <- puddle.apply(manager, fun, 32)
r
})let t2 =
task.async(fn() {
use r <- puddle.apply(manager, fun, 32)
r
})task.await(t1, 32)
task.await(t2, 32)
}
```