shackle_client behaviour (shackle v0.7.1)

View Source

Summary

Types

option/0

-type option() ::
          {address, shackle:inet_address()} |
          {init_options, shackle_server:init_options()} |
          {ip, shackle:inet_address()} |
          {port, shackle:inet_port()} |
          {protocol, shackle:protocol()} |
          {reconnect, boolean()} |
          {reconnect_time_max, shackle:time() | infinity} |
          {reconnect_time_min, shackle:time()} |
          {socket_options, shackle:socket_options()}.

options/0

-type options() :: [option()].

Callbacks

handle_data/2

-callback handle_data(Data :: binary(), State :: term()) ->
                         {ok, [Response :: shackle:response()], State :: term()} |
                         {error, Reason :: term(), State :: term()}.

handle_request/2

-callback handle_request(Request :: term(), State :: term()) ->
                            {ok,
                             RequestId :: shackle:external_request_id(),
                             Data :: iodata(),
                             State :: term()}.

handle_timeout/2

(optional)
-callback handle_timeout(RequestId :: shackle:external_request_id(), State :: term()) ->
                            {ok, Response :: shackle:response(), State :: term()} |
                            {error, Reason :: term(), State :: term()}.

init/1

-callback init(Options :: term()) -> {ok, State :: term()} | {error, Reason :: term()}.

setup/2

-callback setup(Socket :: inet:socket(), State :: term()) ->
                   {ok, State :: term()} | {error, Reason :: term(), State :: term()}.

terminate/1

-callback terminate(State :: term()) -> ok.