I have installed Riak via docker:
And I have installed Elixir Riak client:
Connecting worked fine:
{:ok, pid} = Riak.Connection.start_link('192.168.99.100', 32774)
However, putting a user has failed, here is my code:
def store_to_riak do
{:ok, pid} = Riak.Connection.start_link('192.168.99.100', 32774)
IO.inspect pid
o = Riak.Object.create(bucket: "user", key: "my_key", data: "Han Solo")
IO.inspect o
Riak.put(pid, o)
end
The result:
iex(1)> App.LocationController.store_to_riak
#PID<0.314.0>
%Riak.Object{bucket: "user", content_type: 'application/json', data: "Han Solo",
key: "my_key",
metadata: {:dict, 1, 16, 16, 8, 80, 48,
{[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []},
{{[], [], [], [], [], [], [], [], [], [],
[["content-type", 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47,
106, 115, 111, 110]], [], [], [], [], []}}}, type: :undefined,
vclock: :undefined}
nil
** (EXIT from #PID<0.312.0>) :disconnected
Interactive Elixir (1.2.5) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> [error] GenServer #PID<0.314.0> terminating
** (stop) :disconnected
Last message: {:tcp_closed, #Port<0.12186>}
State: {:state, '192.168.99.100', 32774, false, false, :undefined, false, :gen_tcp, :undefined, {[], []}, 1, [], :infinity, :undefined, :undefined, :undefined, :undefined, [], 100}
But, sense I am new to Riak, I don’t know how to handle such errors, if you can help that would be great