Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Dec 10, 2024
1 parent 62c8697 commit 405bec5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/datastore/postgres/locks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package postgres

import (
"context"
"fmt"
)

type lockID uint32
Expand All @@ -19,15 +20,18 @@ func (pgd *pgDatastore) tryAcquireLock(ctx context.Context, lockID lockID) (bool

var lockAcquired bool
if err := row.Scan(&lockAcquired); err != nil {
fmt.Printf("Error acquiring lock: %v\n", err)
return false, err
}

fmt.Printf("Lock acquired: %v\n", lockAcquired)
return lockAcquired, nil
}

func (pgd *pgDatastore) releaseLock(ctx context.Context, lockID lockID) error {
_, err := pgd.writePool.Exec(ctx, `
SELECT pg_advisory_unlock($1)
`, lockID)
fmt.Printf("Lock released: %v\n", err)
return err
}

0 comments on commit 405bec5

Please sign in to comment.