satellite/metabase/segmentloop: start immediately on manual trigger

Currently loops wait for the coalesce duration for TriggerWait.
Let's skip the coalesce when we trigger it manually.

Change-Id: If5bacd4e263d233f1f3ea41b989922d2ed5a48d4
This commit is contained in:
Egon Elbre 2021-09-28 16:10:11 +03:00
parent 4db80773ef
commit 6d3fd33ca3
5 changed files with 17 additions and 9 deletions

2
go.mod
View File

@ -61,7 +61,7 @@ require (
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/segmentio/analytics-go.v3 v3.1.0
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
storj.io/common v0.0.0-20210916151047-6aaeb34bb916
storj.io/common v0.0.0-20210928125533-ecbc7f49b8a4
storj.io/drpc v0.0.26
storj.io/monkit-jaeger v0.0.0-20210426161729-debb1cbcbbd7
storj.io/private v0.0.0-20210810102517-434aeab3f17d

4
go.sum
View File

@ -879,8 +879,8 @@ sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3
storj.io/common v0.0.0-20200424175742-65ac59022f4f/go.mod h1:pZyXiIE7bGETIRXtfs0nICqMwp7PM8HqnDuyUeldNA0=
storj.io/common v0.0.0-20210805073808-8e0feb09e92a/go.mod h1:mhZYWpTojKsACxWE66RfXNz19zbyr/uEDVWHJH8dHog=
storj.io/common v0.0.0-20210915201516-56ad343b6a7e/go.mod h1:i35B7Zr9WpXWSePOUAQXffRgvt0fWKpdfiB5mtbBbaA=
storj.io/common v0.0.0-20210916151047-6aaeb34bb916 h1:G+EqGYEbW4lUBSkdt2uQE2BRc2ZvnhJSj0czlqL3SuA=
storj.io/common v0.0.0-20210916151047-6aaeb34bb916/go.mod h1:objobGrIWQwhmTSpSm6Y7ykd40wZjB7CezNfic5YLKg=
storj.io/common v0.0.0-20210928125533-ecbc7f49b8a4 h1:G0ePy32obot7DamdE/KcwwKcquE2r6T2pG0G6qyhr6Y=
storj.io/common v0.0.0-20210928125533-ecbc7f49b8a4/go.mod h1:objobGrIWQwhmTSpSm6Y7ykd40wZjB7CezNfic5YLKg=
storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw=
storj.io/drpc v0.0.24/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
storj.io/drpc v0.0.25/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=

View File

@ -15,6 +15,7 @@ import (
"golang.org/x/time/rate"
"storj.io/common/errs2"
"storj.io/common/sync2"
"storj.io/storj/satellite/metabase"
)
@ -76,8 +77,9 @@ func (NullObserver) InlineSegment(context.Context, *Segment) error {
}
type observerContext struct {
trigger bool
observer Observer
immediate bool
trigger bool
observer Observer
ctx context.Context
done chan error
@ -206,7 +208,8 @@ func (loop *Service) joinObserver(ctx context.Context, trigger bool, obs Observe
defer mon.Task()(&ctx)(&err)
obsctx := newObserverContext(ctx, obs)
obsctx.trigger = trigger
obsctx.immediate = sync2.IsManuallyTriggeredCycle(ctx)
obsctx.trigger = trigger || obsctx.immediate
select {
case loop.join <- obsctx:
@ -290,9 +293,14 @@ waitformore:
timerStarted = true
}
}
observers = append(observers, obsctx)
go monitorEarlyExit(obsctx)
if obsctx.immediate {
break waitformore
}
// remove an observer from waiting when it's canceled before the loop starts.
case obsctx := <-earlyExit:
for i, obs := range observers {

View File

@ -8,6 +8,6 @@ require (
github.com/go-rod/rod v0.100.0
github.com/stretchr/testify v1.7.0
go.uber.org/zap v1.17.0
storj.io/common v0.0.0-20210916151047-6aaeb34bb916
storj.io/common v0.0.0-20210928125533-ecbc7f49b8a4
storj.io/storj v0.12.1-0.20210916114455-b2d724962c24
)

View File

@ -841,8 +841,8 @@ sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3
storj.io/common v0.0.0-20200424175742-65ac59022f4f/go.mod h1:pZyXiIE7bGETIRXtfs0nICqMwp7PM8HqnDuyUeldNA0=
storj.io/common v0.0.0-20210805073808-8e0feb09e92a/go.mod h1:mhZYWpTojKsACxWE66RfXNz19zbyr/uEDVWHJH8dHog=
storj.io/common v0.0.0-20210915201516-56ad343b6a7e/go.mod h1:i35B7Zr9WpXWSePOUAQXffRgvt0fWKpdfiB5mtbBbaA=
storj.io/common v0.0.0-20210916151047-6aaeb34bb916 h1:G+EqGYEbW4lUBSkdt2uQE2BRc2ZvnhJSj0czlqL3SuA=
storj.io/common v0.0.0-20210916151047-6aaeb34bb916/go.mod h1:objobGrIWQwhmTSpSm6Y7ykd40wZjB7CezNfic5YLKg=
storj.io/common v0.0.0-20210928125533-ecbc7f49b8a4 h1:G0ePy32obot7DamdE/KcwwKcquE2r6T2pG0G6qyhr6Y=
storj.io/common v0.0.0-20210928125533-ecbc7f49b8a4/go.mod h1:objobGrIWQwhmTSpSm6Y7ykd40wZjB7CezNfic5YLKg=
storj.io/drpc v0.0.11/go.mod h1:TiFc2obNjL9/3isMW1Rpxjy8V9uE0B2HMeMFGiiI7Iw=
storj.io/drpc v0.0.24/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
storj.io/drpc v0.0.25/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=