Skip to content

massivefermion/puddle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

puddle

Package Version Hex Docs

puddle

A resource pool manager for gleam

Quick start

gleam test  # Run the tests
gleam shell # Run an Erlang shell

Installation

This package can be added to your Gleam project:

gleam add puddle

and its documentation can be found at https://hexdocs.pm/puddle.

Usage

import gleam/int
import gleam/otp/task
import puddle

pub 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)
}

About

A resource pool manager for gleam

Resources

Stars

Watchers

Forks

Languages