fixup opts
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
a72ed0f651
commit
6372b7b3fa
2
go.mod
2
go.mod
@ -5,6 +5,6 @@ go 1.13
|
||||
require (
|
||||
github.com/unistack-org/micro-broker-memory v0.0.0-20200905101815-4594aa2807e9
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200905064113-34be66be749f
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200907122943-f1fde75567f0
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200909212533-9ea3149b606e
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73
|
||||
)
|
||||
|
8
go.sum
8
go.sum
@ -284,12 +284,16 @@ github.com/unistack-org/micro-broker-memory v0.0.0-20200905101815-4594aa2807e9/g
|
||||
github.com/unistack-org/micro-codec-bytes v0.0.0-20200828083432-4e49e953d844/go.mod h1:g5sOI8TWgGZiVHe8zoUPdtz7+0oLnqTnfBoai6Qb7jE=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200828075439-d859b9d7265b h1:v5Ak+Sr780jZclFDnx82g5biF0N5HRVKphEpJhbnVUs=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200828075439-d859b9d7265b/go.mod h1:6pm1cadbwsFcEW1ZbV5Fp0i3goR3TNfROMNSPih3I8k=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200909210346-ec89783dc46c/go.mod h1:6pm1cadbwsFcEW1ZbV5Fp0i3goR3TNfROMNSPih3I8k=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200909210755-6e7e85eeab34 h1:VHc98t4SoiCF/jbkFu2e/j+IyJ/+MFQ1T+INNL7LubU=
|
||||
github.com/unistack-org/micro-config-cmd v0.0.0-20200909210755-6e7e85eeab34/go.mod h1:fT1gYn+TtfVZZ5tNx56bZIncJjmlji66g7GKdWua5hE=
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200905064113-34be66be749f h1:aJwqchNCtEYpwCi/Y5MDhQuc1d8RQ5CX7ZgdmFhYeIY=
|
||||
github.com/unistack-org/micro-registry-memory v0.0.0-20200905064113-34be66be749f/go.mod h1:eqAeQoWZMLVScoXEurBfkI5I96Gl1MCN2A/cX1JqaOY=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-20200827083227-aa99378adc6e/go.mod h1:rPQbnry3nboAnMczj8B1Gzlcyv/HYoMZLgd3/3nttJ4=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200904234316-e7d418183b62/go.mod h1:mB0h+i3Sa4jD8G2dv97cAAdyh01hVQWKw4xSdmTpyOo=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200907122943-f1fde75567f0 h1:93vySSH9lsBAZLpV9ZaQJJEKGVOBeEmWi24X4BcnmZ0=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200907122943-f1fde75567f0/go.mod h1:mB0h+i3Sa4jD8G2dv97cAAdyh01hVQWKw4xSdmTpyOo=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200909210629-caec730248b1/go.mod h1:mmqHR9WelHUXqg2mELjsQ+FJHcWs6mNmXg+wEYO2T3c=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200909212533-9ea3149b606e h1:6T+R7bopoFMu1nCM9j9iv+Pi0489+nlUzGhJtzpsd40=
|
||||
github.com/unistack-org/micro/v3 v3.0.0-gamma.0.20200909212533-9ea3149b606e/go.mod h1:HUzMG4Mcy97958VxWTg8zuazZgwQ/aoLZ8wtBVONwRE=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
|
42
options.go
42
options.go
@ -1,13 +1,9 @@
|
||||
package tcp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net"
|
||||
|
||||
"github.com/unistack-org/micro/v3/broker"
|
||||
"github.com/unistack-org/micro/v3/codec"
|
||||
"github.com/unistack-org/micro/v3/registry"
|
||||
"github.com/unistack-org/micro/v3/server"
|
||||
)
|
||||
|
||||
@ -44,41 +40,3 @@ func MaxConn(n int) server.Option {
|
||||
func Listener(l net.Listener) server.Option {
|
||||
return setServerOption(netListener{}, l)
|
||||
}
|
||||
|
||||
func newOptions(opt ...server.Option) server.Options {
|
||||
opts := server.Options{
|
||||
Codecs: make(map[string]codec.NewCodec),
|
||||
Metadata: map[string]string{},
|
||||
Context: context.Background(),
|
||||
}
|
||||
|
||||
for _, o := range opt {
|
||||
o(&opts)
|
||||
}
|
||||
|
||||
if opts.Broker == nil {
|
||||
opts.Broker = broker.DefaultBroker
|
||||
}
|
||||
|
||||
if opts.Registry == nil {
|
||||
opts.Registry = registry.DefaultRegistry
|
||||
}
|
||||
|
||||
if len(opts.Address) == 0 {
|
||||
opts.Address = server.DefaultAddress
|
||||
}
|
||||
|
||||
if len(opts.Name) == 0 {
|
||||
opts.Name = server.DefaultName
|
||||
}
|
||||
|
||||
if len(opts.Id) == 0 {
|
||||
opts.Id = server.DefaultId
|
||||
}
|
||||
|
||||
if len(opts.Version) == 0 {
|
||||
opts.Version = server.DefaultVersion
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
|
2
tcp.go
2
tcp.go
@ -380,7 +380,7 @@ func (s *tcpServer) serve(ln net.Listener, h Handler) {
|
||||
|
||||
func newServer(opts ...server.Option) server.Server {
|
||||
return &tcpServer{
|
||||
opts: newOptions(opts...),
|
||||
opts: server.NewOptions(opts...),
|
||||
exit: make(chan chan error),
|
||||
subscribers: make(map[*tcpSubscriber][]broker.Subscriber),
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user