Skip to content

Commit

Permalink
Host orchestrator client depends only on HO api
Browse files Browse the repository at this point in the history
  • Loading branch information
jemoreira committed Oct 25, 2023
1 parent 2a72d33 commit 887e7ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
11 changes: 0 additions & 11 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
apiv1 "github.com/google/cloud-android-orchestration/api/v1"

"github.com/hashicorp/go-multierror"
"github.com/pion/webrtc/v3"
)

type OpTimeoutError string
Expand Down Expand Up @@ -150,16 +149,6 @@ func (c *serviceImpl) waitForOperation(op *apiv1.Operation, res any) error {
return c.httpHelper.NewPostRequest(path, nil).Do(res)
}

func asWebRTCICEServers(in []apiv1.IceServer) []webrtc.ICEServer {
out := []webrtc.ICEServer{}
for _, s := range in {
out = append(out, webrtc.ICEServer{
URLs: s.URLs,
})
}
return out
}

const headerNameCOInjectBuildAPICreds = "X-Cutf-Cloud-Orchestrator-Inject-BuildAPI-Creds"

func (s *serviceImpl) RootURI() string {
Expand Down
23 changes: 16 additions & 7 deletions pkg/client/host_orchestrator_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"net/http"
"time"

apiv1 "github.com/google/cloud-android-orchestration/api/v1"
wclient "github.com/google/cloud-android-orchestration/pkg/webrtcclient"

hoapi "github.com/google/android-cuttlefish/frontend/src/liboperator/api/v1"
Expand Down Expand Up @@ -59,8 +58,8 @@ type hostOrchestratorServiceImpl struct {
ChunkUploadBackOffOpts BackOffOpts
}

func (c *hostOrchestratorServiceImpl) getInfraConfig() (*apiv1.InfraConfig, error) {
var res apiv1.InfraConfig
func (c *hostOrchestratorServiceImpl) getInfraConfig() (*hoapi.InfraConfig, error) {
var res hoapi.InfraConfig
if err := c.httpHelper.NewGetRequest(fmt.Sprintf("/infra_config")).Do(&res); err != nil {
return nil, err
}
Expand Down Expand Up @@ -167,7 +166,7 @@ func (c *hostOrchestratorServiceImpl) webRTCForward(srcCh chan any, connID strin
close(stopPollCh)
break
}
forwardMsg := apiv1.ForwardMsg{Payload: msg}
forwardMsg := hoapi.ForwardMsg{Payload: msg}
path := fmt.Sprintf("/polled_connections/%s/:forward", connID)
i := 0
for ; i < maxConsecutiveErrors; i++ {
Expand All @@ -186,9 +185,9 @@ func (c *hostOrchestratorServiceImpl) webRTCForward(srcCh chan any, connID strin
}
}

func (c *hostOrchestratorServiceImpl) createPolledConnection(device string) (*apiv1.NewConnReply, error) {
var res apiv1.NewConnReply
rb := c.httpHelper.NewPostRequest("/polled_connections", &apiv1.NewConnMsg{DeviceId: device})
func (c *hostOrchestratorServiceImpl) createPolledConnection(device string) (*hoapi.NewConnReply, error) {
var res hoapi.NewConnReply
rb := c.httpHelper.NewPostRequest("/polled_connections", &hoapi.NewConnMsg{DeviceId: device})
if err := rb.Do(&res); err != nil {
return nil, err
}
Expand Down Expand Up @@ -282,3 +281,13 @@ func (c *hostOrchestratorServiceImpl) UploadFiles(uploadDir string, filenames []
}
return uploader.Upload(filenames)
}

func asWebRTCICEServers(in []hoapi.IceServer) []webrtc.ICEServer {
out := []webrtc.ICEServer{}
for _, s := range in {
out = append(out, webrtc.ICEServer{
URLs: s.URLs,
})
}
return out
}

0 comments on commit 887e7ca

Please sign in to comment.