Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
9ba61f3f
Commit
9ba61f3f
authored
Aug 15, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: add host:port as part of nodeID to defeat a service listens on more than one ports
parent
2c8048f9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
13 deletions
+19
-13
client.go
micro/client.go
+11
-5
server.go
micro/server.go
+3
-3
version.go
version.go
+5
-5
No files found.
micro/client.go
View file @
9ba61f3f
...
...
@@ -116,7 +116,9 @@ func NewClient(conf *rpc.ClientConfig, regConf *RegistryConfig, opts ...ClientOp
return
clt
,
nil
}
func
(
c
*
Client
)
Call
(
ctx
context
.
Context
,
typ
rpc
.
CodecType
,
service
,
method
string
,
args
interface
{},
reply
interface
{})
error
{
func
(
c
*
Client
)
Call
(
ctx
context
.
Context
,
typ
rpc
.
CodecType
,
service
,
method
string
,
args
interface
{},
reply
interface
{})
error
{
attr
:=
c
.
attr
attr
.
Service
=
service
attr
.
Protocol
=
typ
.
String
()
...
...
@@ -130,8 +132,8 @@ func (c *Client) Call(ctx context.Context, typ rpc.CodecType, service, method st
flag
=
true
}
}
var
err
error
if
flag
{
var
err
error
if
svcArray
,
err
=
c
.
filter
.
Filter
(
attr
);
err
!=
nil
{
return
jerrors
.
Trace
(
err
)
}
...
...
@@ -144,9 +146,13 @@ func (c *Client) Call(ctx context.Context, typ rpc.CodecType, service, method st
return
jerrors
.
Trace
(
err
)
}
return
jerrors
.
Trace
(
c
.
Client
.
Call
(
typ
,
gxnet
.
HostAddress
(
svc
.
Nodes
[
0
]
.
Address
,
int
(
svc
.
Nodes
[
0
]
.
Port
)),
service
,
method
,
args
,
reply
))
if
len
(
svc
.
Nodes
)
!=
1
{
return
jerrors
.
Errorf
(
"illegal service %#v"
,
svc
)
}
addr
:=
gxnet
.
HostAddress
(
svc
.
Nodes
[
0
]
.
Address
,
int
(
svc
.
Nodes
[
0
]
.
Port
))
return
jerrors
.
Trace
(
c
.
Client
.
Call
(
typ
,
addr
,
service
,
method
,
args
,
reply
))
}
func
(
c
*
Client
)
Close
()
{
...
...
micro/server.go
View file @
9ba61f3f
package
micro
import
(
"github.com/AlexStocks/goext/net"
"strconv"
"strings"
"time"
...
...
@@ -70,7 +71,8 @@ func NewServer(conf *rpc.ServerConfig, regConf *RegistryConfig) (*Server, error)
nodes
=
append
(
nodes
,
&
gxregistry
.
Node
{
ID
:
regConf
.
NodeID
,
// use host port as part of NodeID to defeat the case: on process listens on many ports
ID
:
regConf
.
NodeID
+
"@"
+
gxnet
.
HostAddress
(
conf
.
Host
,
port
),
Address
:
conf
.
Host
,
Port
:
int32
(
port
),
},
...
...
@@ -105,8 +107,6 @@ func (s *Server) Register(rcvr rpc.GettyRPCService) error {
return
jerrors
.
Trace
(
err
)
}
s
.
Stop
()
return
nil
}
...
...
version.go
View file @
9ba61f3f
...
...
@@ -10,9 +10,9 @@
package
getty
const
(
Version
=
"
0.9.3
"
DATE
=
"2018/08/
07
"
GETTY_MAJOR
=
0
GETTY_MINOR
=
9
GETTY_BUILD
=
2
Version
=
"
1.0.1
"
DATE
=
"2018/08/
13
"
GETTY_MAJOR
=
1
GETTY_MINOR
=
0
GETTY_BUILD
=
1
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment