outpost/ldap: regularly pre-heat flow executor cache to increase bind performance

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-08-21 16:17:30 +02:00
parent ecf35cfd1d
commit ff24bc8cb8
8 changed files with 59 additions and 7 deletions

View File

@ -56,12 +56,6 @@ func NewAPIController(akURL url.URL, token string) *APIController {
log := log.WithField("logger", "authentik.outpost.ak-api-controller")
akConfig, _, err := apiClient.RootApi.RootConfigRetrieve(context.Background()).Execute()
if err != nil {
log.WithError(err).Error("Failed to fetch global configuration")
return nil
}
// Because we don't know the outpost UUID, we simply do a list and pick the first
// The service account this token belongs to should only have access to a single outpost
outposts, _, err := apiClient.OutpostsApi.OutpostsInstancesList(context.Background()).Execute()
@ -73,6 +67,15 @@ func NewAPIController(akURL url.URL, token string) *APIController {
outpost := outposts.Results[0]
doGlobalSetup(outpost.Config)
log.WithField("name", outpost.Name).Debug("Fetched outpost configuration")
akConfig, _, err := apiClient.RootApi.RootConfigRetrieve(context.Background()).Execute()
if err != nil {
log.WithError(err).Error("Failed to fetch global configuration")
return nil
}
log.Debug("Fetched global configuration")
ac := &APIController{
Client: apiClient,
GlobalConfig: akConfig,
@ -121,5 +124,9 @@ func (a *APIController) StartBackgorundTasks() error {
a.logger.Debug("Starting Interval updater...")
a.startIntervalUpdater()
}()
go func() {
a.logger.Debug("Starting periodical timer...")
a.startPeriodicalTasks()
}()
return nil
}