Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add more clarity to the handlers docs #80

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Following options are supported:
* PingHandler - called when no message was sent during idle time. It should be safe for concurrent use.
* InboundMessageHandler - called when a message from the server is received or no matching request for the message was found. InboundMessageHandler must be safe to be called concurrenty.
* ReadTimeoutHandler - called when no messages have been received during specified ReadTimeout wait time. It should be safe for concurrent use.
* ConnectionClosedHandler - is called when connection is closed by server or there were errors during network read/write that led to connection closure
* ConnectionClosedHandler - is called when connection is closed by us, by server or there were errors during network read/write that led to connection closure
* ErrorHandler - is called with the error when connection fails to perform some operation. In some cases instance of a `SafeError` will be passed to prevent data leaks ([detalis](https://github.com/moov-io/iso8583/pull/185))

If you want to override default options, you can do this when creating instance of a client or setting it separately using `SetOptions(options...)` method.
Expand Down Expand Up @@ -98,9 +98,9 @@ This section explains the various stages at which different handler functions ar

#### On connection closure:

- **`ConnectionClosedHandlers (async)`**: These asynchronous handlers are invoked when a connection is closed, either by the server or due to a connection error.
- **`ConnectionClosedHandlers (async)`**: These asynchronous handlers are invoked after connection is closed by us, by the server or due to the network errors

- **`OnClose`** or **`OnCloseCtx`**: This handler is activated when we manually close the connection. **NOTE** If both `OnClose` and `OnCloseCtx` are defined, `OnCloseCtx` will be used.
- **`OnClose`** or **`OnCloseCtx`**: This handler is activated before the connection is closed when we manually close the connection. **NOTE** If both `OnClose` and `OnCloseCtx` are defined, `OnCloseCtx` will be used.


### (m)TLS connection
Expand Down
5 changes: 3 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ type Options struct {
// * to handle network management messages (echo, heartbeat, etc.)
InboundMessageHandler func(c *Connection, message *iso8583.Message)

// ConnectionClosedHandlers is called when connection is closed by server or there
// were network errors during network read/write
// ConnectionClosedHandlers is called after connection is closed by us,
// by the server or when there are network errors during network
// read/write
ConnectionClosedHandlers []func(c *Connection)

// ConnectionEstablishedHandler is called when connection is
Expand Down
Loading