go-enry / go-license-detector

Reliable project licenses detector.
Other
127 stars 36 forks source link

Long initialization on first detect #13

Closed g4s8 closed 3 years ago

g4s8 commented 3 years ago

When the Detect() function called the first time, it loads license database from internal files via internal.globalLicenseDatabase(). There are no problems when calling it once from CLI. But it could be an issue when called from HTTP endpoint on a service with limited resource, since the request may be dropped due to connection timeout.

E.g. see this comment: https://gitlab.com/gitlab-org/gitaly/-/merge_requests/3313#note_561680449

I'm proposing to add a new method to load the database before Detect, e.g. from main() of web-app before starting web-service.