README.md (2208B)
1 Connection 2 ========== 3 4 `Connection` behaviour for connection processes. The API is superset of the 5 GenServer API. There are 2 additional callbacks `connect/2` and `disconnect/2`: 6 7 ```elixir 8 @callback init(any) :: 9 {:ok, any} | {:ok, any, timeout | :hibernate} | 10 {:connect, any, any} | 11 {:backoff, timeout, any} | {:backoff, timeout, any, timeout | :hibernate} | 12 :ignore | {:stop, any} 13 14 @callback connect(any, any) :: 15 {:ok, any} | {:ok, any, timeout | :hibernate} | 16 {:backoff, timeout, any} | {:backoff, timeout, any, timeout | :hibernate} | 17 {:stop, any, any} 18 19 @callback disconnect(any, any) :: 20 {:connect, any, any} | 21 {:backoff, timeout, any} | {:backoff, timeout, any, timeout | :hibernate} | 22 {:noconnect, any} | {:noconnect, any, timeout | :hibernate} 23 {:stop, any, any} 24 25 @callback handle_call(any, {pid, any}, any) :: 26 {:reply, any, any} | {:reply, any, any, timeout | :hibernate} | 27 {:noreply, any} | {:noreply, any, timeout | :hibernate} | 28 {:disconnect | :connect, any, any} | 29 {:disconnect | :connect, any, any, any} | 30 {:stop, any, any} | {:stop, any, any, any} 31 32 @callback handle_cast(any, any) :: 33 {:noreply, any} | {:noreply, any, timeout | :hibernate} | 34 {:disconnect | :connect, any, any} | 35 {:stop, any, any} 36 37 @callback handle_info(any, any) :: 38 {:noreply, any} | {:noreply, any, timeout | :hibernate} | 39 {:disconnect | :connect, any, any} | 40 {:stop, any, any} 41 42 @callback code_change(any, any, any) :: {:ok, any} 43 44 @callback terminate(any, any) :: any 45 ``` 46 There is an example of a simple TCP connection process in 47 `examples/tcp_connection/`. 48 49 50 ## License 51 52 Copyright 2015 James Fish 53 54 Licensed under the Apache License, Version 2.0 (the "License"); 55 you may not use this file except in compliance with the License. 56 You may obtain a copy of the License at 57 58 http://www.apache.org/licenses/LICENSE-2.0 59 60 Unless required by applicable law or agreed to in writing, software 61 distributed under the License is distributed on an "AS IS" BASIS, 62 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 63 See the License for the specific language governing permissions and 64 limitations under the License.