-
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
base: main
Are you sure you want to change the base?
Conversation
51a1242
to
edca01a
Compare
37a88e2
to
c6a7cb3
Compare
robot/impl/local_robot.go
Outdated
} | ||
|
||
// 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) { |
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.
There is a code path where this function might be called in a scenario where a connection to App is expected (i.e., the config might have a cloud component), so I am including the parameter here.
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
AHHHH
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.
Generally LGTM, just a couple comments and know you're still working on the internal cloud service piece.
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 ?
robot/impl/local_robot.go
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Spoke offline, but these few lines are probably unnecessary if AcquireConnection
gets the global app connection.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
AHHHH
The function
AcquireConnection()
, is directly called in two places. This PR eliminates one of said calls by ensuring all code paths that lead to the call have their own global connection that propagates down to where the function executes to replace the call. All of these paths except for one stem from either a test or code in our examples subdirectory. In many of the tests, a nil connection is sufficient. For the few where this is not true (i.e., the ones that expect to use a connection to app--determined by the existence of a "Cloud" component within the config used to define the robot being tested), a catch-all call toAcquireConnection()
is made, giving the local robot its own connection to manage. This call is marked with a comment in the code.