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
8899b0c0
Commit
8899b0c0
authored
Aug 16, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mod: add pool's watcher filter
parent
9ba61f3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
change_log.md
change_log.md
+4
-0
client.go
micro/client.go
+21
-3
No files found.
change_log.md
View file @
8899b0c0
...
...
@@ -14,6 +14,10 @@
## develop history ##
---
-
2018/08/16
> Feature
*
Add gxpool.watcher filter
-
2018/08/13
> Feature
*
Add Micro
...
...
micro/client.go
View file @
8899b0c0
...
...
@@ -7,7 +7,7 @@ import (
)
import
(
"github.com/AlexStocks/g
etty/rpc
"
"github.com/AlexStocks/g
oext/context
"
"github.com/AlexStocks/goext/database/filter"
"github.com/AlexStocks/goext/database/filter/pool"
"github.com/AlexStocks/goext/database/registry"
...
...
@@ -18,6 +18,10 @@ import (
jerrors
"github.com/juju/errors"
)
import
(
"github.com/AlexStocks/getty/rpc"
)
type
ClientOption
func
(
*
ClientOptions
)
type
ClientOptions
struct
{
...
...
@@ -78,8 +82,16 @@ func NewClient(conf *rpc.ClientConfig, regConf *RegistryConfig, opts ...ClientOp
return
nil
,
jerrors
.
Trace
(
err
)
}
serviceAttrFilter
:=
gxregistry
.
ServiceAttr
{
Group
:
regConf
.
IDC
,
Role
:
gxregistry
.
SRT_Provider
,
}
gxctx
:=
gxcontext
.
NewValuesContext
(
nil
)
gxctx
.
Set
(
gxpool
.
GxfilterServiceAttrKey
,
serviceAttrFilter
)
if
filter
,
err
=
gxpool
.
NewFilter
(
gxfilter
.
WithRegistry
(
registry
),
gxfilter
.
WithContext
(
gxctx
),
gxpool
.
WithTTL
(
time
.
Duration
(
1e9
*
regConf
.
KeepaliveTimeout
)),
);
err
!=
nil
{
return
nil
,
jerrors
.
Trace
(
err
)
...
...
@@ -106,7 +118,11 @@ func NewClient(conf *rpc.ClientConfig, regConf *RegistryConfig, opts ...ClientOp
clt
:=
&
Client
{
Client
:
rpcClient
,
registry
:
registry
,
filter
:
filter
,
attr
:
gxregistry
.
ServiceAttr
{
Group
:
regConf
.
IDC
,
},
filter
:
filter
,
svcMap
:
make
(
map
[
gxregistry
.
ServiceAttr
]
*
gxfilter
.
ServiceArray
),
}
for
_
,
o
:=
range
opts
{
...
...
@@ -117,11 +133,13 @@ func NewClient(conf *rpc.ClientConfig, regConf *RegistryConfig, opts ...ClientOp
}
func
(
c
*
Client
)
Call
(
ctx
context
.
Context
,
typ
rpc
.
CodecType
,
service
,
method
string
,
args
interface
{},
reply
interface
{})
error
{
service
,
version
,
method
string
,
args
interface
{},
reply
interface
{})
error
{
attr
:=
c
.
attr
attr
.
Service
=
service
attr
.
Protocol
=
typ
.
String
()
attr
.
Role
=
gxregistry
.
SRT_Provider
attr
.
Version
=
version
flag
:=
false
svcArray
,
ok
:=
c
.
svcMap
[
attr
]
...
...
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