ing
This commit is contained in:
parent
68341e3eb5
commit
d2e6df0fbf
|
@ -1,12 +1,18 @@
|
|||
package client
|
||||
|
||||
import "sync/atomic"
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type OnDisconnectedFunc func(connector Connector)
|
||||
|
||||
type Connector interface {
|
||||
Connect() (readChan <-chan []byte, writeChan chan<- []byte, err error)
|
||||
Disconnect() error
|
||||
|
||||
GetName() string
|
||||
GetOnDisconnected() OnDisconnectedFunc
|
||||
SetOnDisconnected(fnc OnDisconnectedFunc)
|
||||
|
||||
Clone() Connector
|
||||
Validate() error
|
||||
|
@ -14,6 +20,7 @@ type Connector interface {
|
|||
|
||||
type Connectors struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
OnDisconnected OnDisconnectedFunc `json:"-"`
|
||||
|
||||
validated atomic.Value
|
||||
}
|
||||
|
@ -22,6 +29,14 @@ func (c *Connectors) GetName() string {
|
|||
return c.Name
|
||||
}
|
||||
|
||||
func (c *Connectors) GetOnDisconnected() OnDisconnectedFunc {
|
||||
return c.OnDisconnected
|
||||
}
|
||||
|
||||
func (c *Connectors) SetOnDisconnected(fnc OnDisconnectedFunc) {
|
||||
c.OnDisconnected = fnc
|
||||
}
|
||||
|
||||
func (c *Connectors) Clone() *Connectors {
|
||||
return &Connectors{
|
||||
Name: c.Name,
|
||||
|
|
|
@ -22,8 +22,6 @@ type Connectors struct {
|
|||
Address string `json:"address,omitempty"`
|
||||
LocalAddress net.Addr `json:"-"`
|
||||
|
||||
OnDisconnected func(connector client.Connector) `json:"-"`
|
||||
|
||||
stopChan chan struct{}
|
||||
stopWg sync.WaitGroup
|
||||
|
||||
|
|
|
@ -52,8 +52,6 @@ type Connectors struct {
|
|||
// If Proxy is nil or returns a nil *URL, no proxy is used.
|
||||
Proxy func(*http.Request) (*url.URL, error) `json:"-"`
|
||||
|
||||
OnDisconnected func(connector client.Connector) `json:"-"`
|
||||
|
||||
serverURL *url.URL
|
||||
|
||||
stopChan chan struct{}
|
||||
|
|
Loading…
Reference in New Issue
Block a user