first implementation of search feature

This commit is contained in:
tsmethurst
2021-05-29 19:36:54 +02:00
parent cb54324430
commit 0fe853b1ee
20 changed files with 763 additions and 19 deletions

View File

@ -42,6 +42,10 @@ func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
// Strategy: create a new lock, if stored, continue. Otherwise, lock the
// existing mutex.
if id == nil {
return errors.New("Lock: id was nil")
}
mu := &sync.Mutex{}
mu.Lock() // Optimistically lock if we do store it.
i, loaded := f.locks.LoadOrStore(id.String(), mu)
@ -59,6 +63,9 @@ func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
func (f *federatingDB) Unlock(c context.Context, id *url.URL) error {
// Once Go-Fed is done calling Database methods, the relevant `id`
// entries are unlocked.
if id == nil {
return errors.New("Unlock: id was nil")
}
i, ok := f.locks.Load(id.String())
if !ok {