micro/network/options.go

75 lines
1.2 KiB
Go
Raw Normal View History

2019-07-31 17:22:57 +03:00
package network
import (
"github.com/micro/go-micro/client"
2019-07-31 17:30:51 +03:00
"github.com/micro/go-micro/network/proxy"
"github.com/micro/go-micro/network/router"
2019-07-31 17:22:57 +03:00
"github.com/micro/go-micro/server"
)
type Option func(*Options)
type Options struct {
2019-07-31 17:35:51 +03:00
// Name of the network
Name string
// Address of the node
Address string
// Advertise a different address to the network
Advertise string
Client client.Client
Server server.Server
Proxy proxy.Proxy
Router router.Router
2019-07-31 17:22:57 +03:00
}
// The network name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}
2019-07-31 17:35:51 +03:00
// The network address
func Address(a string) Option {
return func(o *Options) {
o.Address = a
}
}
// The network advertise address
func Advertise(a string) Option {
return func(o *Options) {
o.Advertise = a
}
}
2019-07-31 17:22:57 +03:00
// The network client
func Client(c client.Client) Option {
return func(o *Options) {
o.Client = c
}
}
// The network server
func Server(s server.Server) Option {
return func(o *Options) {
o.Server = s
}
}
2019-07-31 17:30:51 +03:00
// The proxy to use
func Proxy(p proxy.Proxy) Option {
return func(o *Options) {
o.Proxy = p
}
}
// The router to use
func Router(r router.Router) Option {
return func(o *Options) {
o.Router = r
}
}