CrateDB and Erlang

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

Add CrateDB to Your Project

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

{deps,[
  {craterl,"0.2.3"}
]}.

And run:

rebar update

Connect to CrateDB

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 CrateDB 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