quicer_stream behaviour (quicer v0.4.3)

View Source

Summary

Types

cb_ret/0

-type cb_ret() :: quicer_lib:cb_ret().

cb_state/0

-type cb_state() :: term().

conf_handle/0

-type conf_handle() :: reference().

connection_handle/0

-type connection_handle() :: reference().

global_handle/0

-type global_handle() :: quic_global.

handle/0

listener_handle/0

-type listener_handle() :: reference().

new_stream_props/0

-type new_stream_props() :: #{is_orphan := boolean(), flags := stream_open_flags()}.

reg_handle/0

-type reg_handle() :: reference().

state/0

-type state() ::
          #{stream := quicer:stream_handle(),
            conn := quicer:connection_handle(),
            callback := atom(),
            callback_state := term(),
            is_owner := boolean(),
            stream_opts := map()}.

stream_handle/0

-type stream_handle() :: reference().

stream_open_flags/0

-type stream_open_flags() :: 0 | 1 | 2.

Callbacks

handle_call/3

(optional)
-callback handle_call(Req :: term(), gen_server:from(), cb_state()) -> cb_ret().
Handle API call with callback state.

handle_cast/2

(optional)
-callback handle_cast(Req :: term(), cb_state()) -> cb_ret().
Handle cast with callback state.

handle_continue/2

(optional)
-callback handle_continue(Cont :: term(), cb_state()) -> cb_ret().
Handle continue from other callbacks with callback state.

handle_info/2

(optional)
-callback handle_info(Info :: term(), cb_state()) -> cb_ret().
Handle unhandled info with callback state.

handle_stream_data/4

(optional)
-callback handle_stream_data(stream_handle(), binary(), recv_data_props(), cb_state()) -> cb_ret().
Stream handle data

init_handoff/4

-callback init_handoff(stream_handle(), stream_opts(), connection_handle(), new_stream_props()) -> cb_ret().
Prepare callback state before ownership handoff

new_stream/3

-callback new_stream(stream_handle(), new_stream_props(), connection_handle()) -> cb_ret().
Stream accepter is assigned to the owner of the new stream

passive/3

-callback passive(stream_handle(), undefined, cb_state()) -> cb_ret().
Stream now in 'passive' mode.

peer_accepted/3

-callback peer_accepted(connection_handle(), stream_handle(), cb_state()) -> cb_ret().
Handle stream 'peer_accepted'. The stream which **was not accepted** due to peer flow control is now accepted by the peer.

peer_receive_aborted/3

-callback peer_receive_aborted(stream_handle(), error_code(), cb_state()) -> cb_ret().
Handle stream peer_receive_aborted

peer_send_aborted/3

-callback peer_send_aborted(stream_handle(), error_code(), cb_state()) -> cb_ret().
Handle stream peer_send_aborted.

peer_send_shutdown/3

-callback peer_send_shutdown(stream_handle(), undefined, cb_state()) -> cb_ret().
Handle stream peer_send_shutdown.

post_handoff/3

(optional)
-callback post_handoff(stream_handle(), PostInfo :: term(), cb_state()) -> cb_ret().
Post handoff with PostData if any. Most common action is to set the stream mode to active.

send_complete/3

-callback send_complete(stream_handle(), IsCanceled :: boolean(), cb_state()) -> cb_ret().
Handle send completed.

send_shutdown_complete/3

-callback send_shutdown_complete(stream_handle(), IsGraceful :: boolean(), cb_state()) -> cb_ret().
Handle stream send_shutdown_complete. Happen immediately on an abortive send or after a graceful send has been acknowledged by the peer.

start_completed/3

-callback start_completed(stream_handle(), stream_start_completed_props(), cb_state()) -> cb_ret().
Handle local initiated stream start completed

stream_closed/3

-callback stream_closed(stream_handle(), stream_closed_props(), cb_state()) -> cb_ret().
Handle stream closed, Both endpoints of sending and receiving of the stream have been shut down.

Functions

send(StreamProc, Data)

-spec send(pid(), binary()) -> {ok, Length :: non_neg_integer()} | {error, any()}.

send(StreamProc, Data, Flag)

start(Callback, Conn, StreamOpts, GenStartOpts)

start(Callback, Stream, Conn, StreamOpts, Props, GenStartOpts)

start_link(Callback, Conn, StreamOpts)

-spec start_link(Callback :: module(), Conn :: quicer:connection_handle(), StreamOpts :: map()) ->
                    {ok, Pid :: pid()} |
                    {error, Error :: {already_started, pid()}} |
                    {error, Error :: term()} |
                    ignore.

Starts the server

start_link(Callback, Conn, StreamOpts, GenStartOpts)

start_link(Callback, Stream, Conn, StreamOpts, Props)

-spec start_link(Callback :: module(),
                 Stream :: quicer:stream_handle(),
                 Conn :: quicer:connection_handle(),
                 StreamOpts :: map(),
                 Props :: new_stream_props()) ->
                    {ok, Pid :: pid()} |
                    {error, Error :: {already_started, pid()}} |
                    {error, Error :: term()} |
                    ignore.

Start a new stream owner process and then handoff ownership to this process --------------------------------------------------------------------

start_link(Callback, Stream, Conn, StreamOpts, Props, GenStartOpts)

wait_for_handoff(FromOwner, Stream)