MCPcopy
hub / github.com/crowdsecurity/crowdsec / ReleaseLockWithTimeout

Method ReleaseLockWithTimeout

pkg/database/lock.go:47–59  ·  view source on GitHub ↗
(ctx context.Context, name string, timeout int)

Source from the content-addressed store, hash-verified

45}
46
47func (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
61func (*Client) IsLocked(err error) bool {
62 return ent.IsConstraintError(err)

Callers 1

AcquirePullCAPILockMethod · 0.95

Calls 6

NameEQFunction · 0.92
CreatedAtLTFunction · 0.92
ExecMethod · 0.45
WhereMethod · 0.45
DeleteMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected