Move proxy/router

This commit is contained in:
Asim Aslam
2019-08-05 17:44:33 +01:00
parent 2e67e23a23
commit 4030ccc27b
28 changed files with 138 additions and 856 deletions

75
router/options.go Normal file
View File

@@ -0,0 +1,75 @@
package router
import (
"github.com/google/uuid"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/registry"
)
// Options are router options
type Options struct {
// Id is router id
Id string
// Address is router address
Address string
// Gateway is network gateway
Gateway string
// Network is network address
Network string
// Registry is the local registry
Registry registry.Registry
// Client for calling router
Client client.Client
}
// Id sets Router Id
func Id(id string) Option {
return func(o *Options) {
o.Id = id
}
}
// Address sets router service address
func Address(a string) Option {
return func(o *Options) {
o.Address = a
}
}
// Client to call router service
func Client(c client.Client) Option {
return func(o *Options) {
o.Client = c
}
}
// Gateway sets network gateway
func Gateway(g string) Option {
return func(o *Options) {
o.Gateway = g
}
}
// Network sets router network
func Network(n string) Option {
return func(o *Options) {
o.Network = n
}
}
// Registry sets the local registry
func Registry(r registry.Registry) Option {
return func(o *Options) {
o.Registry = r
}
}
// DefaultOptions returns router default options
func DefaultOptions() Options {
return Options{
Id: uuid.New().String(),
Address: DefaultAddress,
Network: DefaultNetwork,
Registry: registry.DefaultRegistry,
}
}