-
Notifications
You must be signed in to change notification settings - Fork 414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix (api): all goroutines are managed with context #678
Conversation
engine/api/event/event.go
Outdated
for { | ||
e := sdk.Event{} | ||
cache.Dequeue("events", &e) | ||
cache.DequeueWithContext(c, "events", &e) | ||
err := c.Err() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one line
engine/api/hatchery/heartbeat.go
Outdated
log.Debug("HatcheryHeartbeat> Hatchery %s removed.\n", w[i].Name) | ||
|
||
for i := range w { | ||
err = DeleteHatchery(db, w[i].ID, w[i].Model.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one line
engine/api/hook.go
Outdated
case <-tick: | ||
h := hook.ReceivedHook{} | ||
cache.DequeueWithContext(c, "hook:recovery", &h) | ||
err := c.Err() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one line
engine/api/pipeline/awol.go
Outdated
defer log.Fatalf("Goroutine of pipeline.AWOLPipelineKiller exited - Exit CDS Engine") | ||
|
||
func AWOLPipelineKiller(c context.Context, DBFunc func() *gorp.DbMap) { | ||
tick := time.NewTicker(5 * time.Minute).C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not 1 minut?
engine/api/sessionstore/redis.go
Outdated
func (s *Redis) vacuumCleaner() { | ||
log.Info("Redis> Starting Session Vacuum Cleaner") | ||
func (s *Redis) vacuumCleaner(c context.Context) { | ||
tick := time.NewTicker(5 * time.Second).C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minut?
engine/api/cache/redis.go
Outdated
@@ -174,7 +188,7 @@ func (s *RedisStore) DequeueWithContext(c context.Context, queueName string, val | |||
elemChan := make(chan string) | |||
var once sync.Once | |||
go func() { | |||
ticker := time.NewTicker(50 * time.Millisecond).C | |||
ticker := time.NewTicker(400 * time.Millisecond).C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't do less?
@@ -34,13 +34,12 @@ func (s *InMemory) New(k SessionKey) (SessionKey, error) { | |||
s.data[k] = cache | |||
s.lock.Unlock() | |||
|
|||
go func(k SessionKey) { | |||
time.Sleep(time.Duration(s.ttl) * time.Minute) | |||
time.AfterFunc(time.Duration(s.ttl)*time.Minute, func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt
"github.com/ovh/cds/sdk" | ||
"github.com/ovh/cds/sdk/log" | ||
) | ||
|
||
//ModelCapabilititiesCacheLoader set all model Capabilities in the cache | ||
func ModelCapabilititiesCacheLoader(delay time.Duration) { | ||
func ModelCapabilititiesCacheLoader(c context.Context, delay time.Duration, DBFunc func() *gorp.DbMap) { | ||
tick := time.NewTicker(delay).C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- time.Second
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed on caller side
@@ -119,3 +120,10 @@ func DequeueWithContext(c context.Context, queueName string, value interface{}) | |||
} | |||
s.DequeueWithContext(c, queueName, value) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed, but comment is on the wrong line
No description provided.