Connecting to Crate with Erlang

The Crate Erlang client is built using rebar3 and we recommend you use it in your project for compiling and testing.

Add Crate to your Project

To add Crate as a dependency, add the following to your rebar.config file.


And run:

rebar update

Connect to Crate

To connect to a cluster, create a client instance in your application:

ClientSpec = {local, process_name}.
Servers = [{<<"SERVER_IP">>, 4200}, "SERVER_IP:4201"].
Options = [{poolsize, 1000}, {timeout, 5000}].
ClientRef = craterl:new(ClientSpec, Servers, Options).

In the Servers tuple you can specify just one IP address in the Crate cluster, but including more than one will provide fallbacks if nodes become unavailable.

It's possible to create multiple clients on one erlang node, these are registered using a client spec tuple, such as {local, process_name}. The process name must be unique on each node.

Want to Know More?

Next Steps