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

why do we need new identifier in mysql locker #839

Open
fudongyingluck opened this issue Mar 17, 2025 · 0 comments
Open

why do we need new identifier in mysql locker #839

fudongyingluck opened this issue Mar 17, 2025 · 0 comments

Comments

@fudongyingluck
Copy link

we already have an identifier for a job.

gocron/job.go

Line 754 in 63f3701

func WithIdentifier(id uuid.UUID) JobOption {

why do we need another one in the locker ? Why don't we just pass that as a parameter ?

lock, err := j.locker.Lock(j.ctx, j.name)

https://github.com/go-co-op/gocron-gorm-lock/blob/c615ac7060c9c09324ea80ed6a68d8c1769e2991/gorm_lock.go#L67

 func (g *GormLocker) Lock(ctx context.Context, key string) (gocron.Lock, error) {
	ji := g.jobIdentifier(ctx, key)  // <- here

	cjb := &CronJobLock{
		JobName:       key,
		JobIdentifier: ji,
		Worker:        g.worker,
		Status:        StatusRunning,
	}
	tx := g.db.WithContext(ctx).Create(cjb)
	if tx.Error != nil {
		return nil, tx.Error
	}
	return &gormLock{db: g.db, id: cjb.GetID()}, nil
}
@fudongyingluck fudongyingluck changed the title why we need new identifier in mysql locker why do we need new identifier in mysql locker Mar 17, 2025
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

No branches or pull requests

1 participant