-module(radish@utils). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]). -export([prepare/1, execute/3]). -spec prepare(list(binary())) -> bitstring(). prepare(Parts) -> _pipe = Parts, _pipe@1 = gleam@list:map(_pipe, fun(Field@0) -> {bulk_string, Field@0} end), _pipe@2 = {array, _pipe@1}, radish@encoder:encode(_pipe@2). -spec execute( gleam@erlang@process:subject(radish@client:message()), bitstring(), integer() ) -> {ok, radish@resp:value()} | {error, radish@error:error()}. execute(Client, Cmd, Timeout) -> gleam@result:then( begin _pipe = gleam@erlang@process:try_call( Client, fun(_capture) -> {command, Cmd, _capture, Timeout} end, Timeout ), gleam@result:replace_error(_pipe, actor_error) end, fun(Reply) -> gleam@result:then( begin _pipe@1 = Reply, gleam@result:map_error( _pipe@1, fun(Tcp_error) -> {tcp_error, Tcp_error} end ) end, fun(Reply@1) -> gleam@result:then( radish@decoder:decode(Reply@1), fun(Reply@2) -> case Reply@2 of Value -> {ok, Value}; {simple_error, Error} -> {error, {server_error, Error}}; {bulk_error, Error} -> {error, {server_error, Error}} end end ) end ) end ).