Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
33746391
Unverified
Commit
33746391
authored
4 years ago
by
capossele
Browse files
Options
Downloads
Patches
Plain Diff
Refactor FPC metric events
parent
563ef0c1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dapps/valuetransfers/fpc.go
+5
-3
5 additions, 3 deletions
dapps/valuetransfers/fpc.go
packages/vote/net/server.go
+22
-24
22 additions, 24 deletions
packages/vote/net/server.go
with
27 additions
and
27 deletions
dapps/valuetransfers/fpc.go
+
5
−
3
View file @
33746391
...
...
@@ -125,7 +125,8 @@ func runFPC() {
return
vote
.
Like
},
config
.
Node
.
GetString
(
CfgFPCBindAddress
),
metrics
.
Events
()
.
FPCInboundBytes
,
metrics
.
Events
()
.
FPCOutboundBytes
)
metrics
.
Events
()
.
FPCOutboundBytes
,
metrics
.
Events
()
.
QueryReceived
)
go
func
()
{
if
err
:=
voterServer
.
Run
();
err
!=
nil
{
...
...
@@ -194,8 +195,9 @@ func (pog *PeerOpinionGiver) Query(ctx context.Context, ids []string) (vote.Opin
return
nil
,
fmt
.
Errorf
(
"unable to query opinions: %w"
,
err
)
}
metrics
.
Events
()
.
FPCInboundBytes
.
Trigger
(
proto
.
Size
(
reply
))
metrics
.
Events
()
.
FPCOutboundBytes
.
Trigger
(
proto
.
Size
(
query
))
metrics
.
Events
()
.
FPCInboundBytes
.
Trigger
(
uint64
(
proto
.
Size
(
reply
)))
metrics
.
Events
()
.
FPCOutboundBytes
.
Trigger
(
uint64
(
proto
.
Size
(
query
)))
// convert int32s in reply to opinions
opinions
:=
make
(
vote
.
Opinions
,
len
(
reply
.
Opinion
))
for
i
,
intOpn
:=
range
reply
.
Opinion
{
...
...
This diff is collapsed.
Click to expand it.
packages/vote/net/server.go
+
22
−
24
View file @
33746391
...
...
@@ -16,30 +16,26 @@ import (
type
OpinionRetriever
func
(
id
string
)
vote
.
Opinion
// New creates a new VoterServer.
func
New
(
voter
vote
.
Voter
,
opnRetriever
OpinionRetriever
,
bindAddr
string
,
netEvents
...*
events
.
Event
)
*
VoterServer
{
vs
:=
&
VoterServer
{
voter
:
voter
,
opnRetriever
:
opnRetriever
,
bindAddr
:
bindAddr
,
func
New
(
voter
vote
.
Voter
,
opnRetriever
OpinionRetriever
,
bindAddr
string
,
netRxEvent
,
netTxEvent
,
queryReceivedEvent
*
events
.
Event
)
*
VoterServer
{
return
&
VoterServer
{
voter
:
voter
,
opnRetriever
:
opnRetriever
,
bindAddr
:
bindAddr
,
netRxEvent
:
netRxEvent
,
netTxEvent
:
netTxEvent
,
queryReceivedEvent
:
queryReceivedEvent
,
}
if
netEvents
==
nil
&&
len
(
netEvents
)
<
2
{
return
vs
}
vs
.
netEventRX
=
netEvents
[
0
]
vs
.
netEventTX
=
netEvents
[
1
]
return
vs
}
// VoterServer is a server which responds to opinion queries.
type
VoterServer
struct
{
voter
vote
.
Voter
opnRetriever
OpinionRetriever
bindAddr
string
grpcServer
*
grpc
.
Server
netEventRX
*
events
.
Event
netEventTX
*
events
.
Event
voter
vote
.
Voter
opnRetriever
OpinionRetriever
bindAddr
string
grpcServer
*
grpc
.
Server
netRxEvent
*
events
.
Event
netTxEvent
*
events
.
Event
queryReceivedEvent
*
events
.
Event
}
func
(
vs
*
VoterServer
)
Opinion
(
ctx
context
.
Context
,
req
*
QueryRequest
)
(
*
QueryReply
,
error
)
{
...
...
@@ -56,14 +52,16 @@ func (vs *VoterServer) Opinion(ctx context.Context, req *QueryRequest) (*QueryRe
reply
.
Opinion
[
i
]
=
int32
(
vs
.
opnRetriever
(
id
))
}
if
vs
.
netEventRX
!=
nil
{
vs
.
netEventRX
.
Trigger
(
proto
.
Size
(
req
))
if
vs
.
netRxEvent
!=
nil
{
vs
.
netRxEvent
.
Trigger
(
uint64
(
proto
.
Size
(
req
)))
}
if
vs
.
netTxEvent
!=
nil
{
vs
.
netTxEvent
.
Trigger
(
uint64
(
proto
.
Size
(
reply
)))
}
if
vs
.
net
Event
TX
!=
nil
{
vs
.
net
Event
TX
.
Trigger
(
proto
.
Size
(
reply
)
)
if
vs
.
queryReceived
Event
!=
nil
{
vs
.
queryReceived
Event
.
Trigger
(
&
metrics
.
QueryReceivedEvent
{
OpinionCount
:
len
(
req
.
Id
)}
)
}
metrics
.
Events
()
.
QueryReceived
.
Trigger
(
&
metrics
.
QueryReceivedEvent
{
OpinionCount
:
len
(
req
.
Id
)})
return
reply
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment