Terminus v0.0.2 Terminus.Streamer View Source
A mixin module providing functions for creating streaming HTTP requests.
Examples
defmodule BitFS do
use Terminus.Streamer, host: "x.bitfs.network"
def load_file(path) do
case stream("GET", path, nil) do
{:ok, stream} ->
stream |> Enum.to_list |> Enum.join
{:error, reason} ->
raise reason
end
end
end
Link to this section Summary
Types
On-data callback function.
Functions
Runs the given streaming Enumerable.t/0
and executes the callback
on each element of the stream.
Normalizes the given Bitquery, automatically expanding shorthand queries.
Opens a HTTP connection and begins a request, returning the GenStage pid
of the request.
Opens a HTTP connection and begins a request, returning a streaming Enumerable.t/0
.
Link to this section Types
On-data callback function.
Link to this section Functions
handle_callback(stream, ondata)
View Sourcehandle_callback(Enumerable.t(), callback()) :: {:ok, Enumerable.t()} | :ok | {:error, String.t()}
Runs the given streaming Enumerable.t/0
and executes the callback
on each element of the stream.
If the given callback is nil
then the stream is passed through and returned.
Normalizes the given Bitquery, automatically expanding shorthand queries.
Examples
iex> normalize_query(%{find: %{"tx.h" => "abc"}})
%{
v: 3,
q: %{
find: %{
"tx.h" => "abc"
}
}
}
Opens a HTTP connection and begins a request, returning the GenStage pid
of the request.
Returns the result in an :ok
/ :error
tuple pair.
Opens a HTTP connection and begins a request, returning a streaming Enumerable.t/0
.
Returns the result in an :ok
/ :error
tuple pair.