diff --git a/tcpclient/client.go b/tcpclient/client.go index ca6d044..461fc3e 100644 --- a/tcpclient/client.go +++ b/tcpclient/client.go @@ -9,6 +9,7 @@ import ( ) type ClientConfiguration struct { + Status uint32 ErrorResolver func(chan error) } @@ -26,6 +27,7 @@ type ErrorResolverFunc func(errors chan error) type Client struct { addr string + Status uint32 exit chan bool Server net.Conn IsConnected bool diff --git a/tcpclient/options.go b/tcpclient/options.go new file mode 100644 index 0000000..88b607a --- /dev/null +++ b/tcpclient/options.go @@ -0,0 +1,15 @@ +package tcpclient + +type ClientOption func(conf *ClientConfiguration) + +const ( + statusBitNothing = 0 + statusBitCustomErrorHandling = 1 << iota +) + +func WithCustomErrorHandling(fun ErrorResolverFunc) ClientOption { + return func(conf *ClientConfiguration) { + conf.Status |= statusBitCustomErrorHandling + conf.ErrorResolver = fun + } +}