micro/tunnel/tunnel.go

40 lines
847 B
Go
Raw Permalink Normal View History

// Package tunnel provides micro network tunnelling
package tunnel
import (
"github.com/micro/go-micro/transport"
)
2019-08-05 21:41:48 +03:00
// Status is tunnel status
type Status int
const (
// Connected means the tunnel is alive
Connected Status = iota
// Closed meands the tunnel has been disconnected
Closed
)
// Tunnel creates a p2p network tunnel.
type Tunnel interface {
2019-08-05 21:41:48 +03:00
// Id returns tunnel id
Id() string
2019-08-06 13:45:25 +03:00
// Options returns the tunnel options
Options() Options
2019-08-05 21:41:48 +03:00
// Address returns tunnel address
Address() string
2019-08-06 13:45:25 +03:00
// Transport to use by tunne clients
2019-08-05 21:41:48 +03:00
Transport() transport.Transport
// Connect connects the tunnel
Connect() error
// Close closes the tunnel
Close() error
2019-08-05 21:41:48 +03:00
// Status returns tunnel status
Status() Status
}
// NewTunnel creates a new tunnel on top of a link
func NewTunnel(opts ...Option) Tunnel {
return newTunnel(opts...)
}