New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display HTTP URL in /apps list #325
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,42 @@ func (p *Proxy) GetInstalledApp(_ *incoming.Request, appID apps.AppID) (*apps.Ap | |
return p.store.App.Get(appID) | ||
} | ||
|
||
func (p *Proxy) GetInstalledApps(_ *incoming.Request) []apps.App { | ||
installed := p.store.App.AsMap() | ||
out := []apps.App{} | ||
for _, app := range installed { | ||
out = append(out, app) | ||
func (p *Proxy) GetInstalledApps(r *incoming.Request, ping bool) (installed []apps.App, reachable map[apps.AppID]bool) { | ||
all := p.store.App.AsMap() | ||
|
||
// all ping requests must respond, unreachable respond with "". | ||
reachableCh := make(chan apps.AppID) | ||
for _, app := range all { | ||
rr, cancel := p.timeoutRequest(r, pingAppTimeout) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we utilize this timeout logic when fetching bindings from all apps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, when the time for it comes? I am not sure we want to be timing out more aggressively than the default, yet, since the binding fetch should be in theory async to the user, right? |
||
go func(a apps.App) { | ||
var response apps.AppID | ||
if !a.Disabled { | ||
if p.pingApp(rr, a) { | ||
response = a.AppID | ||
} | ||
} | ||
reachableCh <- response | ||
cancel() | ||
}(app) | ||
} | ||
|
||
for _, app := range all { | ||
installed = append(installed, app) | ||
appID := <-reachableCh | ||
if appID != "" { | ||
if reachable == nil { | ||
reachable = map[apps.AppID]bool{} | ||
} | ||
reachable[appID] = true | ||
} | ||
} | ||
|
||
// Sort result alphabetically, by display name. | ||
sort.SliceStable(out, func(i, j int) bool { | ||
return strings.ToLower(out[i].DisplayName) < strings.ToLower(out[j].DisplayName) | ||
sort.SliceStable(installed, func(i, j int) bool { | ||
return strings.ToLower(installed[i].DisplayName) < strings.ToLower(installed[j].DisplayName) | ||
}) | ||
|
||
return out | ||
return installed, reachable | ||
} | ||
|
||
func (p *Proxy) GetListedApps(_ *incoming.Request, filter string, includePluginApps bool) []apps.ListedApp { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a method of
incoming.Request
? What does it have to do withProxy
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #331