Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit57f619c

Browse files
committed
implement dual barrier for notifications command
1 parent3410c76 commit57f619c

File tree

1 file changed

+44
-17
lines changed

1 file changed

+44
-17
lines changed

‎cli/exp_scaletest.go‎

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,8 +2013,10 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
20132013

20142014
_,_=fmt.Fprintln(inv.Stderr,"Creating users...")
20152015

2016-
dialBarrier:=&sync.WaitGroup{}
2017-
dialBarrier.Add(int(userCount))
2016+
ownerDialBarrier:=&sync.WaitGroup{}
2017+
regularDialBarrier:=&sync.WaitGroup{}
2018+
ownerDialBarrier.Add(int(ownerUserCount))
2019+
regularDialBarrier.Add(int(regularUserCount))
20182020

20192021
configs:=make([]notifications.Config,0,userCount)
20202022
forrangeownerUserCount {
@@ -2025,7 +2027,7 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
20252027
IsOwner:true,
20262028
NotificationTimeout:notificationTimeout,
20272029
DialTimeout:dialTimeout,
2028-
DialBarrier:dialBarrier,
2030+
DialBarrier:ownerDialBarrier,
20292031
Metrics:metrics,
20302032
}
20312033
iferr:=config.Validate();err!=nil {
@@ -2041,7 +2043,8 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
20412043
IsOwner:false,
20422044
NotificationTimeout:notificationTimeout,
20432045
DialTimeout:dialTimeout,
2044-
DialBarrier:dialBarrier,
2046+
DialBarrier:regularDialBarrier,
2047+
OwnerDialBarrier:ownerDialBarrier,
20452048
Metrics:metrics,
20462049
}
20472050
iferr:=config.Validate();err!=nil {
@@ -2051,31 +2054,55 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
20512054
}
20522055

20532056
gofunc() {
2054-
logger.Info(ctx,"waiting forall users to connect")
2057+
logger.Info(ctx,"waiting forowner users to connect")
20552058

2056-
//Create timeout contextforthe entire trigger operation
2057-
waitCtx,cancel:=context.WithTimeout(ctx,dialTimeout+30*time.Second)
2059+
//Waitforowner users to connect
2060+
ownerWaitCtx,cancel:=context.WithTimeout(ctx,dialTimeout+30*time.Second)
20582061
defercancel()
20592062

2060-
// Wait for all runners to reach the barrier
2061-
done:=make(chanstruct{})
2063+
ownerDone:=make(chanstruct{})
20622064
gofunc() {
2063-
dialBarrier.Wait()
2064-
close(done)
2065+
ownerDialBarrier.Wait()
2066+
close(ownerDone)
20652067
}()
20662068

20672069
select {
2068-
case<-done:
2069-
logger.Info(ctx,"all users connected")
2070-
case<-waitCtx.Done():
2071-
ifwaitCtx.Err()==context.DeadlineExceeded {
2072-
logger.Error(ctx,"timeout waiting forall users to connect")
2070+
case<-ownerDone:
2071+
logger.Info(ctx,"allownerusers connected")
2072+
case<-ownerWaitCtx.Done():
2073+
ifownerWaitCtx.Err()==context.DeadlineExceeded {
2074+
logger.Error(ctx,"timeout waiting forowner users to connect")
20732075
}else {
2074-
logger.Info(ctx,"context canceled while waiting for users")
2076+
logger.Info(ctx,"context canceled while waiting forownerusers")
20752077
}
20762078
return
20772079
}
20782080

2081+
// Wait for regular users to connect
2082+
logger.Info(ctx,"waiting for regular users to connect")
2083+
regularWaitCtx,cancel:=context.WithTimeout(ctx,dialTimeout+30*time.Second)
2084+
defercancel()
2085+
2086+
regularDone:=make(chanstruct{})
2087+
gofunc() {
2088+
regularDialBarrier.Wait()
2089+
close(regularDone)
2090+
}()
2091+
2092+
select {
2093+
case<-regularDone:
2094+
logger.Info(ctx,"all regular users connected")
2095+
case<-regularWaitCtx.Done():
2096+
ifregularWaitCtx.Err()==context.DeadlineExceeded {
2097+
logger.Error(ctx,"timeout waiting for regular users to connect")
2098+
}else {
2099+
logger.Info(ctx,"context canceled while waiting for regular users")
2100+
}
2101+
return
2102+
}
2103+
2104+
logger.Info(ctx,"all users connected, triggering notifications")
2105+
20792106
const (
20802107
triggerUsername="scaletest-trigger-user"
20812108
triggerEmail="scaletest-trigger@example.com"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp