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

Commit73e4a8a

Browse files
committed
implement dual barrier for notifications command
1 parente731d0e commit73e4a8a

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
@@ -1778,8 +1778,10 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
17781778

17791779
_,_=fmt.Fprintln(inv.Stderr,"Creating users...")
17801780

1781-
dialBarrier:=&sync.WaitGroup{}
1782-
dialBarrier.Add(int(userCount))
1781+
ownerDialBarrier:=&sync.WaitGroup{}
1782+
regularDialBarrier:=&sync.WaitGroup{}
1783+
ownerDialBarrier.Add(int(ownerUserCount))
1784+
regularDialBarrier.Add(int(regularUserCount))
17831785

17841786
configs:=make([]notifications.Config,0,userCount)
17851787
forrangeownerUserCount {
@@ -1790,7 +1792,7 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
17901792
IsOwner:true,
17911793
NotificationTimeout:notificationTimeout,
17921794
DialTimeout:dialTimeout,
1793-
DialBarrier:dialBarrier,
1795+
DialBarrier:ownerDialBarrier,
17941796
Metrics:metrics,
17951797
}
17961798
iferr:=config.Validate();err!=nil {
@@ -1806,7 +1808,8 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
18061808
IsOwner:false,
18071809
NotificationTimeout:notificationTimeout,
18081810
DialTimeout:dialTimeout,
1809-
DialBarrier:dialBarrier,
1811+
DialBarrier:regularDialBarrier,
1812+
OwnerDialBarrier:ownerDialBarrier,
18101813
Metrics:metrics,
18111814
}
18121815
iferr:=config.Validate();err!=nil {
@@ -1816,31 +1819,55 @@ func (r *RootCmd) scaletestNotifications() *serpent.Command {
18161819
}
18171820

18181821
gofunc() {
1819-
logger.Info(ctx,"waiting forall users to connect")
1822+
logger.Info(ctx,"waiting forowner users to connect")
18201823

1821-
//Create timeout contextforthe entire trigger operation
1822-
waitCtx,cancel:=context.WithTimeout(ctx,dialTimeout+30*time.Second)
1824+
//Waitforowner users to connect
1825+
ownerWaitCtx,cancel:=context.WithTimeout(ctx,dialTimeout+30*time.Second)
18231826
defercancel()
18241827

1825-
// Wait for all runners to reach the barrier
1826-
done:=make(chanstruct{})
1828+
ownerDone:=make(chanstruct{})
18271829
gofunc() {
1828-
dialBarrier.Wait()
1829-
close(done)
1830+
ownerDialBarrier.Wait()
1831+
close(ownerDone)
18301832
}()
18311833

18321834
select {
1833-
case<-done:
1834-
logger.Info(ctx,"all users connected")
1835-
case<-waitCtx.Done():
1836-
ifwaitCtx.Err()==context.DeadlineExceeded {
1837-
logger.Error(ctx,"timeout waiting forall users to connect")
1835+
case<-ownerDone:
1836+
logger.Info(ctx,"allownerusers connected")
1837+
case<-ownerWaitCtx.Done():
1838+
ifownerWaitCtx.Err()==context.DeadlineExceeded {
1839+
logger.Error(ctx,"timeout waiting forowner users to connect")
18381840
}else {
1839-
logger.Info(ctx,"context canceled while waiting for users")
1841+
logger.Info(ctx,"context canceled while waiting forownerusers")
18401842
}
18411843
return
18421844
}
18431845

1846+
// Wait for regular users to connect
1847+
logger.Info(ctx,"waiting for regular users to connect")
1848+
regularWaitCtx,cancel:=context.WithTimeout(ctx,dialTimeout+30*time.Second)
1849+
defercancel()
1850+
1851+
regularDone:=make(chanstruct{})
1852+
gofunc() {
1853+
regularDialBarrier.Wait()
1854+
close(regularDone)
1855+
}()
1856+
1857+
select {
1858+
case<-regularDone:
1859+
logger.Info(ctx,"all regular users connected")
1860+
case<-regularWaitCtx.Done():
1861+
ifregularWaitCtx.Err()==context.DeadlineExceeded {
1862+
logger.Error(ctx,"timeout waiting for regular users to connect")
1863+
}else {
1864+
logger.Info(ctx,"context canceled while waiting for regular users")
1865+
}
1866+
return
1867+
}
1868+
1869+
logger.Info(ctx,"all users connected, triggering notifications")
1870+
18441871
const (
18451872
triggerUsername="scaletest-trigger-user"
18461873
triggerEmail="scaletest-trigger@example.com"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp