Skip to content

Commit

Permalink
fix: handle the fact lambdo returns scheme & port
Browse files Browse the repository at this point in the history
Signed-off-by: WoodenMaiden <[email protected]>
  • Loading branch information
WoodenMaiden committed May 22, 2024
1 parent 8a361f8 commit 1bd23b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion routes/function/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (c *Controller) RunFunction(ctx *gin.Context) {
}

_, err = http.Post(
fmt.Sprint("http://", string(fnState.Address), ":", fnState.Port, "/execute"),
fmt.Sprint(string(fnState.Address), ":", fnState.Port, "/execute"),
"application/json",
ctx.Request.Body,
)
Expand Down
5 changes: 4 additions & 1 deletion scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"errors"
"fmt"
"time"
"net/url"

"github.com/do4-2022/grobuzin/database"

"github.com/google/uuid"
Expand Down Expand Up @@ -67,6 +69,7 @@ func (s *Scheduler) LookForReadyInstance(functionId uuid.UUID, cursor uint64) (f
}

func (s *Scheduler) SpawnVM(function database.Function) (fnState database.FunctionState, err error) {
url, _ := url.Parse(s.Lambdo.URL)
res, err := s.Lambdo.SpawnVM(function)

if (err != nil) {
Expand All @@ -77,7 +80,7 @@ func (s *Scheduler) SpawnVM(function database.Function) (fnState database.Functi

fnState = database.FunctionState{
ID: res.ID,
Address: s.Lambdo.URL,
Address: fmt.Sprint(url.Scheme, "://", url.Hostname()),
Port: res.Ports[0][0],
Status: int(database.FnReady),
LastUsed: "never",
Expand Down

0 comments on commit 1bd23b8

Please sign in to comment.