options fix
This commit is contained in:
parent
db82e3d03c
commit
894d79eed3
|
@ -36,6 +36,12 @@ func WithUpdatesTimeout(timeout time.Duration) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithProxy(req *AddProxyRequest) Option {
|
||||||
|
return func(client *Client) {
|
||||||
|
client.AddProxy(req)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NewClient(authorizationStateHandler AuthorizationStateHandler, options ...Option) (*Client, error) {
|
func NewClient(authorizationStateHandler AuthorizationStateHandler, options ...Option) (*Client, error) {
|
||||||
catchersListener := make(chan *Response, 1000)
|
catchersListener := make(chan *Response, 1000)
|
||||||
|
|
||||||
|
@ -46,22 +52,14 @@ func NewClient(authorizationStateHandler AuthorizationStateHandler, options ...O
|
||||||
catchersStore: &sync.Map{},
|
catchersStore: &sync.Map{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.extraGenerator = UuidV4Generator()
|
||||||
|
client.catchTimeout = 60 * time.Second
|
||||||
|
client.updatesTimeout = 60 * time.Second
|
||||||
|
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
option(client)
|
option(client)
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.extraGenerator == nil {
|
|
||||||
client.extraGenerator = UuidV4Generator()
|
|
||||||
}
|
|
||||||
|
|
||||||
if client.catchTimeout == 0 {
|
|
||||||
client.catchTimeout = 60 * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
if client.updatesTimeout == 0 {
|
|
||||||
client.updatesTimeout = 60 * time.Second
|
|
||||||
}
|
|
||||||
|
|
||||||
go client.receive()
|
go client.receive()
|
||||||
go client.catch(catchersListener)
|
go client.catch(catchersListener)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue