-
Notifications
You must be signed in to change notification settings - Fork 113
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
[RSDK-8294] Use Global Connection to App in Internal Cloud Service and Local Robot #4782
Changes from 7 commits
c6a7cb3
4484f8d
fe83e57
da298d8
cfde0c8
7ff0029
2ec5c6a
b08f684
090edd1
73038c8
82ffad8
81c7e45
73facf7
ec1aecc
bcaea48
0f75a6e
ed75da4
1201c72
c44a5a8
6c57c86
ad4b3e1
b8df4aa
f2b1c6f
13e8ee3
2e2cd6e
9124464
d94aa1b
f45cf7c
fe7ea97
827e743
2aae7df
6ad3d96
0d38c61
c3e8c39
3377d59
26c9c6b
962b21a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -341,6 +341,7 @@ func newWithResources( | |
ctx context.Context, | ||
cfg *config.Config, | ||
resources map[resource.Name]resource.Resource, | ||
conn rpc.ClientConn, | ||
logger logging.Logger, | ||
opts ...Option, | ||
) (robot.LocalRobot, error) { | ||
|
@@ -434,6 +435,12 @@ func newWithResources( | |
r.packageManager = packages.NewDeferredPackageManager( | ||
ctx, | ||
func(ctx context.Context) (packagespb.PackageServiceClient, error) { | ||
if conn != nil { | ||
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. Spoke offline, but these few lines are probably unnecessary if |
||
return packagespb.NewPackageServiceClient(conn), err | ||
} | ||
|
||
// NOTE(bashar-515): this case where `conn` is nil, `cfg.Cloud` is non-nil, and `cfg.Cloud.AppAddress` is not the empty string | ||
// is only encountered in tests. It is not an actual path expected to be taken in prod | ||
_, cloudConn, err := r.cloudConnSvc.AcquireConnection(ctx) | ||
return packagespb.NewPackageServiceClient(cloudConn), err | ||
}, | ||
|
@@ -548,10 +555,11 @@ func newWithResources( | |
func New( | ||
ctx context.Context, | ||
cfg *config.Config, | ||
conn rpc.ClientConn, | ||
logger logging.Logger, | ||
opts ...Option, | ||
) (robot.LocalRobot, error) { | ||
cheukt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return newWithResources(ctx, cfg, nil, logger, opts...) | ||
return newWithResources(ctx, cfg, nil, conn, logger, opts...) | ||
} | ||
|
||
// removeOrphanedResources is called by the module manager to remove resources | ||
|
@@ -1002,16 +1010,22 @@ func RobotFromConfigPath(ctx context.Context, cfgPath string, logger logging.Log | |
logger.CError(ctx, "cannot read config") | ||
return nil, err | ||
} | ||
return RobotFromConfig(ctx, cfg, logger, opts...) | ||
return RobotFromConfig(ctx, cfg, nil, logger, opts...) | ||
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. Again, the code paths that call 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. it is possible that RobotFromConfigPath might be used with a cloud config - probably easier to just let users pass in a conn if they want |
||
} | ||
|
||
// RobotFromConfig is a helper to process a config and then create a robot based on it. | ||
func RobotFromConfig(ctx context.Context, cfg *config.Config, logger logging.Logger, opts ...Option) (robot.LocalRobot, error) { | ||
func RobotFromConfig( | ||
ctx context.Context, | ||
cfg *config.Config, | ||
conn rpc.ClientConn, | ||
logger logging.Logger, | ||
opts ...Option, | ||
) (robot.LocalRobot, error) { | ||
processedCfg, err := config.ProcessConfig(cfg) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return New(ctx, processedCfg, logger, opts...) | ||
return New(ctx, processedCfg, conn, logger, opts...) | ||
} | ||
|
||
// RobotFromResources creates a new robot consisting of the given resources. Using RobotFromConfig is preferred | ||
|
@@ -1022,7 +1036,7 @@ func RobotFromResources( | |
logger logging.Logger, | ||
opts ...Option, | ||
) (robot.LocalRobot, error) { | ||
return newWithResources(ctx, &config.Config{}, resources, logger, opts...) | ||
return newWithResources(ctx, &config.Config{}, resources, nil, logger, opts...) | ||
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. I think it's safe to pass a nil connection here because |
||
} | ||
|
||
// DiscoverComponents takes a list of discovery queries and returns corresponding | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -529,7 +529,7 @@ func (s *robotServer) serveWeb(ctx context.Context, cfg *config.Config) (err err | |
// state of initializing until reconfigured with full config. | ||
minimalProcessedConfig.Initial = true | ||
|
||
myRobot, err := robotimpl.New(ctx, &minimalProcessedConfig, s.logger, robotOptions...) | ||
myRobot, err := robotimpl.New(ctx, &minimalProcessedConfig, s.conn, s.logger, robotOptions...) | ||
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. MAIN CODE PATH START 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. AHHHH |
||
if err != nil { | ||
cancel() | ||
return err | ||
|
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.
Off-topic, but any context on the purpose of this example @cheukt ? Still necessary to keep around ?
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.
we can probably remove, we want users using modules directly
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.
what exactly should I remove?
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.
don't have to remove in this ticket, made a ticket here