-
Notifications
You must be signed in to change notification settings - Fork 110
/
cloud_connection.go
31 lines (25 loc) · 1015 Bytes
/
cloud_connection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Package inject provides an mock cloud connection service that can be used for testing.
package inject
import (
"context"
"go.viam.com/utils/rpc"
"go.viam.com/rdk/resource"
)
// CloudConnectionService is an implementation of the cloud.ConnectionService interface used for testing.
type CloudConnectionService struct {
resource.Named
resource.AlwaysRebuild
Conn rpc.ClientConn
AcquireConnectionErr error
}
// AcquireConnection returns a connection to the rpc server stored in the cloud connection service object.
func (cloudConnService *CloudConnectionService) AcquireConnection(ctx context.Context) (string, rpc.ClientConn, error) {
if cloudConnService.AcquireConnectionErr != nil {
return "", nil, cloudConnService.AcquireConnectionErr
}
return "hello", cloudConnService.Conn, nil
}
// Close is used by the CloudConnectionService to complete the cloud.ConnectionService interface.
func (cloudConnService *CloudConnectionService) Close(ctx context.Context) error {
return nil
}