1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-04-17 11:06:19 +02:00
go-micro/network/options.go

56 lines
863 B
Go
Raw Normal View History

2019-07-31 15:22:57 +01:00
package network
import (
"github.com/micro/go-micro/client"
2019-07-31 15:30:51 +01:00
"github.com/micro/go-micro/network/proxy"
"github.com/micro/go-micro/network/router"
2019-07-31 15:22:57 +01:00
"github.com/micro/go-micro/server"
)
type Option func(*Options)
type Options struct {
Name string
Client client.Client
Server server.Server
2019-07-31 15:30:51 +01:00
Proxy proxy.Proxy
Router router.Router
2019-07-31 15:22:57 +01:00
}
// The network name
func Name(n string) Option {
return func(o *Options) {
o.Name = n
}
}
// 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 15:30:51 +01: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
}
}