glisten/internal/acceptor

Types

pub type AcceptorError {
  AcceptError
  HandlerError
  ControlError
}

Constructors

  • AcceptError
  • HandlerError
  • ControlError
pub type AcceptorMessage {
  AcceptConnection(ListenSocket)
}

Constructors

  • AcceptConnection(ListenSocket)
pub type AcceptorState {
  AcceptorState(
    sender: Subject(AcceptorMessage),
    socket: Option(Socket),
    transport: Transport,
  )
}

Constructors

  • AcceptorState(
      sender: Subject(AcceptorMessage),
      socket: Option(Socket),
      transport: Transport,
    )
pub type Pool(user_message, data) {
  Pool(
    handler: Loop(user_message, data),
    pool_count: Int,
    on_init: fn(Connection(user_message)) ->
      #(data, Option(Selector(user_message))),
    on_close: Option(fn(data) -> Nil),
    transport: Transport,
  )
}

Constructors

  • Pool(
      handler: Loop(user_message, data),
      pool_count: Int,
      on_init: fn(Connection(user_message)) ->
        #(data, Option(Selector(user_message))),
      on_close: Option(fn(data) -> Nil),
      transport: Transport,
    )

Functions

pub fn start(
  pool: Pool(a, b),
  listener: Subject(Message),
) -> Result(Subject(AcceptorMessage), StartError)

Worker process that handles accepting connections and starts a new process which receives the messages from the socket

pub fn start_pool(
  pool: Pool(a, b),
  transport: Transport,
  port: Int,
  options: List(TcpOption),
  return: Subject(Subject(Message)),
) -> Result(Subject(gleam/otp/supervisor.Message), StartError)

Starts a pool of acceptors of size pool_count.

Runs loop_fn on ever message received

Search Document