1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-12 08:23:58 +02:00
go-micro/tunnel/options.go

64 lines
1.1 KiB
Go
Raw Normal View History

package tunnel
import (
"github.com/google/uuid"
"github.com/micro/go-micro/transport"
2019-08-07 19:44:33 +02:00
"github.com/micro/go-micro/transport/quic"
)
var (
// DefaultAddress is default tunnel bind address
2019-08-21 13:55:10 +02:00
DefaultAddress = ":0"
)
type Option func(*Options)
// Options provides network configuration options
type Options struct {
// Id is tunnel id
Id string
// Address is tunnel address
Address string
// Nodes are remote nodes
Nodes []string
// Transport listens to incoming connections
Transport transport.Transport
}
// The tunnel id
func Id(id string) Option {
return func(o *Options) {
o.Id = id
}
}
// The tunnel address
func Address(a string) Option {
return func(o *Options) {
o.Address = a
}
}
// Nodes specify remote network nodes
2019-08-07 19:44:33 +02:00
func Nodes(n ...string) Option {
return func(o *Options) {
o.Nodes = n
}
}
// Transport listens for incoming connections
func Transport(t transport.Transport) Option {
return func(o *Options) {
o.Transport = t
}
}
// DefaultOptions returns router default options
func DefaultOptions() Options {
return Options{
Id: uuid.New().String(),
Address: DefaultAddress,
2019-08-07 19:44:33 +02:00
Transport: quic.NewTransport(),
}
}