MCPcopy Index your code
hub / github.com/rilldata/rill / OpenRuntimeClient

Method OpenRuntimeClient

cli/pkg/cmdutil/helper.go:470–511  ·  view source on GitHub ↗

OpenRuntimeClient opens a client for the production deployment for the given project. If local is true, it connects to the locally running runtime instead of the deployed project's runtime. It returns the runtime client and instance ID for the project.

(ctx context.Context, org, project, branch string, local bool)

Source from the content-addressed store, hash-verified

468// If local is true, it connects to the locally running runtime instead of the deployed project's runtime.
469// It returns the runtime client and instance ID for the project.
470func (h *Helper) OpenRuntimeClient(ctx context.Context, org, project, branch string, local bool) (*runtimeclient.Client, string, error) {
471 var host, instanceID, jwt string
472 if local {
473 // This is the default port that Rill localhost uses for gRPC.
474 // TODO: In the future, we should capture the gRPC port in ~/.rill and use it here.
475 host = "http://localhost:49009"
476 instanceID = "default"
477 } else {
478 adm, err := h.Client()
479 if err != nil {
480 return nil, "", err
481 }
482
483 proj, err := adm.GetProject(ctx, &adminv1.GetProjectRequest{
484 Org: org,
485 Project: project,
486 Branch: branch,
487 })
488 if err != nil {
489 return nil, "", err
490 }
491
492 depl := proj.Deployment
493 if depl == nil {
494 return nil, "", fmt.Errorf("project %q is not currently deployed", project)
495 }
496 if depl.Status != adminv1.DeploymentStatus_DEPLOYMENT_STATUS_RUNNING {
497 return nil, "", fmt.Errorf("deployment status not RUNNING: %s", depl.Status.String())
498 }
499
500 host = depl.RuntimeHost
501 instanceID = depl.RuntimeInstanceId
502 jwt = proj.Jwt
503 }
504
505 rt, err := runtimeclient.New(host, jwt)
506 if err != nil {
507 return nil, "", fmt.Errorf("failed to connect to runtime: %w", err)
508 }
509
510 return rt, instanceID, nil
511}
512
513func (h *Helper) GitHelper(org, project, localPath string) *GitHelper {
514 h.gitHelperMu.Lock()

Callers 6

StatusCmdFunction · 0.45
RefreshCmdFunction · 0.45
PartitionsCmdFunction · 0.45
TablesCmdFunction · 0.45
ChatCmdFunction · 0.45
QueryCmdFunction · 0.45

Calls 4

ClientMethod · 0.95
GetProjectMethod · 0.65
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected