Files
steampipe/pkg/interactive/run.go
kaidaguerre 404dd35e21 Update database code to use pgx interface so we can leverage the connection pool hook functions to pre-warm connections. Closes #2422 (#2438)
* Provide feedback for failed prepared statements
* Move error functions to error_helpers
* Make maintenance client retriable
2022-10-05 12:38:57 +01:00

30 lines
949 B
Go

package interactive
import (
"context"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_local"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/query"
"github.com/turbot/steampipe/pkg/query/queryresult"
)
// RunInteractivePrompt starts the interactive query prompt
func RunInteractivePrompt(ctx context.Context, initData *query.InitData) (*queryresult.ResultStreamer, error) {
resultsStreamer := queryresult.NewResultStreamer()
interactiveClient, err := newInteractiveClient(ctx, initData, resultsStreamer)
if err != nil {
error_helpers.ShowErrorWithMessage(ctx, err, "interactive client failed to initialize")
// do not bind shutdown to any cancellable context
db_local.ShutdownService(ctx, constants.InvokerQuery)
return nil, err
}
// start the interactive prompt in a go routine
go interactiveClient.InteractivePrompt(ctx)
return resultsStreamer, nil
}