Add Options for CreateClient func
This commit is contained in:
parent
374e3984ce
commit
6bb8dc19b1
|
@ -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
|
||||
|
|
15
tcpclient/options.go
Normal file
15
tcpclient/options.go
Normal file
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user