Skip to content
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

Merged
merged 11 commits into from
Jun 6, 2017
Merged

Conversation

fsamin
Copy link
Member

@fsamin fsamin commented Jun 5, 2017

No description provided.

@fsamin fsamin requested review from yesnault and sguiheux June 5, 2017 16:54
for {
e := sdk.Event{}
cache.Dequeue("events", &e)
cache.DequeueWithContext(c, "events", &e)
err := c.Err()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line

log.Debug("HatcheryHeartbeat> Hatchery %s removed.\n", w[i].Name)

for i := range w {
err = DeleteHatchery(db, w[i].ID, w[i].Model.ID)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line

case <-tick:
h := hook.ReceivedHook{}
cache.DequeueWithContext(c, "hook:recovery", &h)
err := c.Err()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one line

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 1 minut?

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minut?

@@ -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
Copy link
Collaborator

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() {
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • time.Second

Copy link
Member Author

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)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc

Copy link
Member Author

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

@yesnault yesnault merged commit b292a4f into master Jun 6, 2017
@fsamin fsamin deleted the fsamin/fix-cache branch June 9, 2017 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants