authorize: refactor store locking (#2151)

* authorize: refactor store locking

* fix nil reference panic
This commit is contained in:
Caleb Doxsey 2021-04-29 08:37:27 -06:00 committed by GitHub
parent 9215833a0b
commit c85c8b0778
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 82 additions and 55 deletions

View file

@ -6,6 +6,7 @@ import (
"context"
"fmt"
"html/template"
"sync"
"github.com/pomerium/pomerium/authorize/evaluator"
"github.com/pomerium/pomerium/config"
@ -24,6 +25,11 @@ type Authorize struct {
templates *template.Template
dataBrokerInitialSync chan struct{}
// The stateLock prevents updating the evaluator store simultaneously with an evaluation.
// This should provide a consistent view of the data at a given server/record version and
// avoid partial updates.
stateLock sync.RWMutex
}
// New validates and creates a new Authorize service from a set of config options.