Tunnel discover/announce/open/session/close

This commit is contained in:
Asim Aslam
2019-09-04 09:48:05 +01:00
parent eb4a709195
commit b9c437fbfe
7 changed files with 565 additions and 43 deletions

View File

@@ -2,6 +2,9 @@
package tunnel
import (
"errors"
"time"
"github.com/micro/go-micro/transport"
)
@@ -18,7 +21,7 @@ type Tunnel interface {
// Close closes the tunnel
Close() error
// Connect to a channel
Dial(channel string) (Session, error)
Dial(channel string, opts ...DialOption) (Session, error)
// Accept connections on a channel
Listen(channel string) (Listener, error)
// Name of the tunnel implementation
@@ -42,6 +45,12 @@ type Session interface {
transport.Socket
}
var (
ErrDialTimeout = errors.New("dial timeout")
DefaultDialTimeout = time.Second * 5
)
// NewTunnel creates a new tunnel
func NewTunnel(opts ...Option) Tunnel {
return newTunnel(opts...)