(ctx context.Context, name string, timeout int)
| 45 | } |
| 46 | |
| 47 | func (c *Client) ReleaseLockWithTimeout(ctx context.Context, name string, timeout int) error { |
| 48 | log.Debugf("releasing lock %s with timeout of %d minutes", name, timeout) |
| 49 | |
| 50 | _, err := c.Ent.Lock.Delete().Where( |
| 51 | lock.NameEQ(name), |
| 52 | lock.CreatedAtLT(time.Now().UTC().Add(-time.Duration(timeout)*time.Minute)), |
| 53 | ).Exec(ctx) |
| 54 | if err != nil { |
| 55 | return fmt.Errorf("delete lock: %w: %w", err, DeleteFail) |
| 56 | } |
| 57 | |
| 58 | return nil |
| 59 | } |
| 60 | |
| 61 | func (*Client) IsLocked(err error) bool { |
| 62 | return ent.IsConstraintError(err) |
no test coverage detected