Optimize evaluator

This optimizes the Evaluator in the Authorize service to scale to very
large numbers of routes. Additional caching was also added when building
rego policy query evaluators in parallel to allow sharing work and to
avoid building evaluators for scripts with the same contents.
This commit is contained in:
Joe Kralicky 2024-07-22 16:39:26 -04:00
parent 526e2a58d6
commit a396c2eab3
No known key found for this signature in database
GPG key ID: 75C4875F34A9FB79
16 changed files with 1539 additions and 483 deletions

View file

@ -65,12 +65,13 @@ func TestAuthorize_getDataBrokerSessionOrServiceAccount(t *testing.T) {
t.Cleanup(clearTimeout)
opt := config.NewDefaultOptions()
a, err := New(context.Background(), &config.Config{Options: opt})
require.NoError(t, err)
a := New()
a.OnConfigChange(context.Background(), &config.Config{Options: opt})
require.True(t, a.HasValidState())
s1 := &session.Session{Id: "s1", ExpiresAt: timestamppb.New(time.Now().Add(-time.Second))}
sq := storage.NewStaticQuerier(s1)
qctx := storage.WithQuerier(ctx, sq)
_, err = a.getDataBrokerSessionOrServiceAccount(qctx, "s1", 0)
_, err := a.getDataBrokerSessionOrServiceAccount(qctx, "s1", 0)
assert.ErrorIs(t, err, session.ErrSessionExpired)
}