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

Commitda902a8

Browse files
committed
allow blocking rollup init to handle data insertion
1 parent60d812d commitda902a8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

‎coderd/database/dbrollup/dbrollup.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const (
2121
)
2222

2323
typeEventstruct {
24-
TemplateUsageStatsbool
24+
Initbool`json:"-"`
25+
TemplateUsageStatsbool`json:"template_usage_stats"`
2526
}
2627

2728
typeRolluperstruct {
@@ -138,6 +139,15 @@ func (r *Rolluper) start(ctx context.Context) {
138139
}
139140
}
140141

142+
// For testing.
143+
ifr.event!=nil {
144+
select {
145+
case<-ctx.Done():
146+
return
147+
caser.event<-Event{Init:true}:
148+
}
149+
}
150+
141151
// Perform do immediately and on every tick of the ticker,
142152
// disregarding the execution time of do. This ensure that
143153
// the rollup is performed every interval assuming do does

‎coderd/database/dbrollup/dbrollup_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ func TestRollup_TwoInstancesUseLocking(t *testing.T) {
110110
)
111111
defercloseRolluper(rolluper2,resume2)
112112

113+
_,_=<-events1,<-events2// Deplete init event, resume operation.
114+
113115
ctx:=testutil.Context(t,testutil.WaitMedium)
114116

115117
// One of the rollup instances should roll up and the other should not.
@@ -222,6 +224,8 @@ func TestRollupTemplateUsageStats(t *testing.T) {
222224
rolluper:=dbrollup.New(logger,db,dbrollup.WithInterval(250*time.Millisecond),dbrollup.WithEventChannel(events))
223225
deferrolluper.Close()
224226

227+
<-events// Deplete init event, resume operation.
228+
225229
ctx:=testutil.Context(t,testutil.WaitMedium)
226230

227231
select {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp