package atacama

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

Install

Dune Dependency

Authors

Maintainers

Sources

atacama-0.0.2.tbz
sha256=108bd9ce0bd4121f8c8165a2a7528612cf24480c3060bb57722569b5067934d4
sha512=3bc10bf2cbef5e1e9b211af82dacc4588de50be73ef83241127b87c1f5f387c8863e43c2922390626f0063f0d9b9f2a41ecda4756f928c4fb8b0ee2e2dd4e1af

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

topics socket socket pool riot

Published: 22 Nov 2023

README

Atacama

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.

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 a Atacama server, we can also specify a transport module.

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

A 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 a Atacama server.

Dependencies (4)

  1. dune >= "3.10"
  2. telemetry >= "0.0.1"
  3. riot = "0.0.3"
  4. ocaml >= "5.1"

Dev Dependencies (1)

  1. odoc with-doc

Used by (1)

  1. nomad

Conflicts

None

OCaml

Innovation. Community. Security.