mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-20 10:30:25 -05:00
- Execute RefreshConnections asyncronously - Add connection_state table to indicate the loading state of connections - Optimise RefreshConnections by cloning connection schemas - Add locking to ensure only a single instance of RefreshConnections runs - Start executing queries without waiting for connections to load, add smart error handling to wait for required connection - Optimise autocomplete for high connection count - Autocomplete and inspect data available before all conections are refreshed - Update file watcher to respond to CHMOD, so thaat it pickes up deletion of file contents Closes #3394 Closes #3267
40 lines
982 B
Go
40 lines
982 B
Go
package interactive
|
|
|
|
import (
|
|
"github.com/c-bata/go-prompt"
|
|
"sort"
|
|
)
|
|
|
|
type autoCompleteSuggestions struct {
|
|
schemas []prompt.Suggest
|
|
unqualifiedTables []prompt.Suggest
|
|
unqualifiedQueries []prompt.Suggest
|
|
tablesBySchema map[string][]prompt.Suggest
|
|
queriesByMod map[string][]prompt.Suggest
|
|
mods []prompt.Suggest
|
|
}
|
|
|
|
func newAutocompleteSuggestions() *autoCompleteSuggestions {
|
|
return &autoCompleteSuggestions{
|
|
tablesBySchema: make(map[string][]prompt.Suggest),
|
|
queriesByMod: make(map[string][]prompt.Suggest),
|
|
}
|
|
}
|
|
func (s autoCompleteSuggestions) sort() {
|
|
sortSuggestions := func(s []prompt.Suggest) {
|
|
sort.Slice(s, func(i, j int) bool {
|
|
return s[i].Text < s[j].Text
|
|
})
|
|
}
|
|
|
|
sortSuggestions(s.schemas)
|
|
sortSuggestions(s.unqualifiedTables)
|
|
sortSuggestions(s.unqualifiedQueries)
|
|
for _, tables := range s.tablesBySchema {
|
|
sortSuggestions(tables)
|
|
}
|
|
for _, queries := range s.queriesByMod {
|
|
sortSuggestions(queries)
|
|
}
|
|
}
|