Hi,
I am wondering if it would be reasonable to parallelize some or all fosite handler iteration. For example, fosite currently generates an access token and an ID token sequentially as we iterate through the relevant handlers here in access_response_writer.go
func (f *Fosite) NewAccessResponse(ctx context.Context, requester AccessRequester) (AccessResponder, error) {
var err error
var tk TokenEndpointHandler
response := NewAccessResponse()
for _, tk = range f.TokenEndpointHandlers {
if err = tk.PopulateTokenEndpointResponse(ctx, requester, response); err == nil {
// do nothing
} else if errors.Is(err, ErrUnknownRequest) {
// do nothing
} else if err != nil {
return nil, err
}
}
if response.GetAccessToken() == "" || response.GetTokenType() == "" {
return nil, errorsx.WithStack(ErrServerError.WithHint("An internal server occurred while trying to complete the request.").WithDebug("Access token or token type not set by TokenEndpointHandlers."))
}
return response, nil
}
Would there be an issue with spinning up a new goroutine to process each handler and wait until all are done before returning? Are some handlers dependent on others being done first?
Thanks