mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-06 17:51:28 +00:00
feat: async calls (#311)
* feat: async calls Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * feat: added concurrency settings Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * feat: added in ability to set max concurrency Signed-off-by: Alex Jones <alexsimonjones@gmail.com> --------- Signed-off-by: Alex Jones <alexsimonjones@gmail.com> Co-authored-by: Matthis <99146727+matthisholleville@users.noreply.github.com>
This commit is contained in:
@@ -26,11 +26,12 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Port string
|
||||
Backend string
|
||||
Key string
|
||||
Token string
|
||||
Output string
|
||||
Port string
|
||||
Backend string
|
||||
Key string
|
||||
Token string
|
||||
Output string
|
||||
maxConcurrency int
|
||||
}
|
||||
|
||||
type Health struct {
|
||||
@@ -55,13 +56,19 @@ func (s *Config) analyzeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
anonymize := getBoolParam(r.URL.Query().Get("anonymize"))
|
||||
nocache := getBoolParam(r.URL.Query().Get("nocache"))
|
||||
language := r.URL.Query().Get("language")
|
||||
|
||||
var err error
|
||||
s.maxConcurrency, err = strconv.Atoi(r.URL.Query().Get("maxConcurrency"))
|
||||
if err != nil {
|
||||
s.maxConcurrency = 10
|
||||
}
|
||||
s.Output = r.URL.Query().Get("output")
|
||||
|
||||
if s.Output == "" {
|
||||
s.Output = "json"
|
||||
}
|
||||
|
||||
config, err := analysis.NewAnalysis(s.Backend, language, []string{}, namespace, nocache, explain)
|
||||
config, err := analysis.NewAnalysis(s.Backend, language, []string{}, namespace, nocache, explain, s.maxConcurrency)
|
||||
if err != nil {
|
||||
health.Failure++
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
Reference in New Issue
Block a user