package atacama

  1. Overview
  2. Docs
Modern, pure OCaml socket pool for Riot

Install

Dune Dependency

Authors

Maintainers

Sources

atacama-0.0.4.tbz
sha256=49ff871a89259c300d22b38b35d0d184a80ffdd808121544f39874264d84e354
sha512=b00e32f9228715d1cbd21d89cd42b35805760cf01ff557d57020b2e9ff101d9a692f71f6b5b7f4f9f13961d989b5e70a42c78bcbb8b96d591615704cdd42e69c

Description

Atacama is a modern, pure OCaml socket pool for Riot inspired by Thousand Island. It aims to be easy to understand and reason about, while also being at least as stable and performant as the alternatives.

Tags

socket socket pool tcp riot

Published: 29 Dec 2023

README

README.md

Atacama

A modern, pure OCaml socket pool for Riot inspired by Thousand Island. It aims to be easy to understand and reason about, while also being at least as stable and performant as the alternatives.

Getting Started

opam install atacama

Usage

To start a Atacama server, you just specify a port to bind to, and a module that will handle the connections.

let (Ok pid) = Atacama.start_link ~port:2112 (module Echo) initial_state in

In this case, our Echo handler looks like this:

module Echo = struct
  open Atacama.Handler
  include Atacama.Handler.Default

  type state = int

  let handle_data data socket state =
    Logger.info (fun f -> f "[%d] echo: %s" state (Bigstringaf.to_string data));
    let (Ok _bytes) = Atacama.Socket.send socket data in
    Continue (state+1)
end

Custom lifecycle functions can be specified, but sensible defaults are available in the Atacama.Handler.Default module that you can include to get started quickly.

Custom Transports

When starting an Atacama server, we can also specify a transport module.

Transport is a module that implements Atacama.Transport.Intf, which defines how to listen, connect, and accept sockets, how to handshake new connections, and how to send and receive data.

Clear TCP sockets are provided and used by default when starting an Atacama server.

Dependencies (4)

  1. telemetry >= "0.0.1"
  2. riot >= "0.0.7"
  3. ocaml >= "5.1"
  4. dune >= "3.12"

Dev Dependencies (2)

  1. odoc with-doc & >= "2.2.2"
  2. mdx with-test & >= "2.3.1"

Used by

None

Conflicts

None