Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
elixxir
client
Commits
07665ab6
Commit
07665ab6
authored
3 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Move OnSend bucket increment to network/message/ package
parent
bf8e025b
No related branches found
No related tags found
2 merge requests
!117
Release
,
!83
Add EKV backed leaky bucket storage
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/send.go
+0
-12
0 additions, 12 deletions
api/send.go
network/message/sendCmix.go
+11
-0
11 additions, 0 deletions
network/message/sendCmix.go
network/message/sendManyCmix.go
+1
-0
1 addition, 0 deletions
network/message/sendManyCmix.go
with
12 additions
and
12 deletions
api/send.go
+
0
−
12
View file @
07665ab6
...
...
@@ -50,7 +50,6 @@ func (c *Client) SendUnsafe(m message.Send, param params.Unsafe) ([]id.Round,
func
(
c
*
Client
)
SendCMIX
(
msg
format
.
Message
,
recipientID
*
id
.
ID
,
param
params
.
CMIX
)
(
id
.
Round
,
ephemeral
.
Id
,
error
)
{
jww
.
INFO
.
Printf
(
"SendCMIX(%s)"
,
string
(
msg
.
GetContents
()))
c
.
OnSend
(
1
)
return
c
.
network
.
SendCMIX
(
msg
,
recipientID
,
param
)
}
...
...
@@ -59,7 +58,6 @@ func (c *Client) SendCMIX(msg format.Message, recipientID *id.ID,
// round ID of the round the payload was sent or an error if it fails.
func
(
c
*
Client
)
SendManyCMIX
(
messages
[]
message
.
TargetedCmixMessage
,
params
params
.
CMIX
)
(
id
.
Round
,
[]
ephemeral
.
Id
,
error
)
{
c
.
OnSend
(
uint32
(
len
(
messages
)))
return
c
.
network
.
SendManyCMIX
(
messages
,
params
)
}
...
...
@@ -75,13 +73,3 @@ func (c *Client) NewCMIXMessage(contents []byte) (format.Message, error) {
msg
.
SetContents
(
contents
)
return
msg
,
nil
}
// OnSend performs a bucket addition on a call to Client.SendCMIX or
// Client.SendManyCMIX, updating the bucket for the amount of messages sent.
func
(
c
*
Client
)
OnSend
(
messages
uint32
)
{
rateLimitingParam
:=
c
.
storage
.
GetBucketParams
()
.
Get
()
c
.
storage
.
GetBucket
()
.
AddWithExternalParams
(
messages
,
rateLimitingParam
.
Capacity
,
rateLimitingParam
.
LeakedTokens
,
rateLimitingParam
.
LeakDuration
)
}
This diff is collapsed.
Click to expand it.
network/message/sendCmix.go
+
11
−
0
View file @
07665ab6
...
...
@@ -187,6 +187,7 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message,
elapsed
,
numRoundTries
)
jww
.
INFO
.
Print
(
m
)
events
.
Report
(
1
,
"MessageSend"
,
"Metric"
,
m
)
onSend
(
1
,
session
)
return
id
.
Round
(
bestRound
.
ID
),
ephID
,
nil
}
else
{
jww
.
FATAL
.
Panicf
(
"Gateway %s returned no error, but failed "
+
...
...
@@ -198,3 +199,13 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message,
return
0
,
ephemeral
.
Id
{},
errors
.
New
(
"failed to send the message, "
+
"unknown error"
)
}
// OnSend performs a bucket addition on a call to Manager.SendCMIX or
// Manager.SendManyCMIX, updating the bucket for the amount of messages sent.
func
onSend
(
messages
uint32
,
session
*
storage
.
Session
)
{
rateLimitingParam
:=
session
.
GetBucketParams
()
.
Get
()
session
.
GetBucket
()
.
AddWithExternalParams
(
messages
,
rateLimitingParam
.
Capacity
,
rateLimitingParam
.
LeakedTokens
,
rateLimitingParam
.
LeakDuration
)
}
This diff is collapsed.
Click to expand it.
network/message/sendManyCmix.go
+
1
−
0
View file @
07665ab6
...
...
@@ -203,6 +203,7 @@ func sendManyCmixHelper(sender *gateway.Sender,
"in round %d"
,
ephemeralIDsString
,
recipientString
,
bestRound
.
ID
)
jww
.
INFO
.
Print
(
m
)
events
.
Report
(
1
,
"MessageSendMany"
,
"Metric"
,
m
)
onSend
(
uint32
(
len
(
msgs
)),
session
)
return
id
.
Round
(
bestRound
.
ID
),
ephemeralIDs
,
nil
}
else
{
jww
.
FATAL
.
Panicf
(
"Gateway %s returned no error, but failed to "
+
...
...
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