nanne007 / lakeland

a copycat(elixir version) of ranch
MIT License
1 stars 0 forks source link

Lakeland

Description

Lakeland is an copycat of Ranch(connection pool of tcp for erlang). This repo is just for the purpose of learning elixir and erlang. Many tests are missing, so do not use it in production.

What's the difference.

How to use

$ git clone https://github.com/lerencao/lakeland.git && cd lakeland
$ mix deps.get && mix compile
$ iex -S mix

Then in the iex shell, enter the following code to starts a echo server in port 8080.

{:ok, _listener} = Lakeland.start_listener(:echo, Lakeland.Handler.Echo, [], [num_acceptors: 3, port: 8080])
:echo |> Lakeland.get_addr # => {{0, 0, 0, 0}, 8080}
:echo |> Lakeland.get_max_connections # => 1024
:echo |> Lakeland.set_max_connections(2048) # => :ok
:echo |> Lakeland.get_max_connections # => 2048

Use telnet localhost 8080 to echo yourself.

To see the docs, use mix docs.

License

See LICENSE file.