Skip to content

why do we need new identifier in mysql locker #839

Open
@fudongyingluck

Description

@fudongyingluck

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions