grisp_updater_source behaviour (grisp_updater v2.3.0)

View Source

Summary

Callbacks

Close an opened session.

Handle backend messages. Return pass | {ok,State} | {data|done|stream_error|source_error,...}.

Initialize a source backend with Opts. Return opaque State.

Open a session for Url if supported; return SourceRef used for subsequent streaming.

Start streaming or return full data. For streams, later emit data/done via source_handle/2.

Termination hook for cleanup.

Callbacks

source_cancel(State, SourceRef, StreamRef)

-callback source_cancel(State :: term(), SourceRef :: term(), StreamRef :: term()) -> State :: term().

Cancel an active stream.

source_close(State, SourceRef)

-callback source_close(State :: term(), SourceRef :: term()) -> State :: term().

Close an opened session.

source_handle(State, Msg)

(optional)
-callback source_handle(State :: term(), Msg :: term()) ->
                           pass |
                           {ok, State :: term} |
                           {data, StreamRef :: term(), Data :: binary(), State :: term()} |
                           {done, StreamRef :: term(), Data :: binary(), State :: term()} |
                           {stream_error, [StreamRef :: term()], Reason :: term(), State :: term()} |
                           {source_error, SourceRef :: term(), Reason :: term(), State :: term()}.

Handle backend messages. Return pass | {ok,State} | {data|done|stream_error|source_error,...}.

source_init(Opts)

-callback source_init(Opts :: map()) -> {ok, State :: term()} | {error, term()}.

Initialize a source backend with Opts. Return opaque State.

source_open(State, Url, Opts)

-callback source_open(State :: term(), Url :: binary(), Opts :: map()) ->
                         {ok, SourceRef :: term(), State :: term()} | not_supported | {error, term()}.

Open a session for Url if supported; return SourceRef used for subsequent streaming.

source_stream(State, SourceRef, Path, Opts)

-callback source_stream(State :: term(), SourceRef :: term(), Path :: binary(), Opts :: map()) ->
                           {stream, StreamRef :: term(), State :: term()} |
                           {data, Data :: binary(), State :: term()} |
                           {error, term()}.

Start streaming or return full data. For streams, later emit data/done via source_handle/2.

source_terminate(State, Reason)

-callback source_terminate(State :: term(), Reason :: term()) -> ok.

Termination hook for cleanup.

Functions

cancel(StreamRef)

handle_call/3

handle_cast(Request, State)

handle_info/2

init/1

load(Url, Path)

start_link(Opts)

stream(Url, Path, SinkMod, SinkParams)

terminate/2