Skip to content

Commit

Permalink
fix: routing table only contained one entry (#395)
Browse files Browse the repository at this point in the history
Thus even with more than one replica, only a single replica would ever
receive traffic.
  • Loading branch information
alecthomas authored Sep 18, 2023
1 parent c104542 commit aaef01c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
19 changes: 10 additions & 9 deletions backend/controller/internal/dal/dal.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,17 +832,18 @@ func (d *DAL) GetRoutingTable(ctx context.Context, modules []string) (map[string
if len(routes) == 0 {
return nil, errors.Wrap(ErrNotFound, "no routes found")
}
return maps.FromSlice(routes, func(row sql.GetRoutingTableRow) (string, []Route) {
out := make(map[string][]Route, len(routes))
for _, route := range routes {
// This is guaranteed to be non-nil by the query, but sqlc doesn't quite understand that.
moduleName := row.ModuleName.MustGet()
return moduleName, []Route{{
moduleName := route.ModuleName.MustGet()
out[moduleName] = append(out[moduleName], Route{
Module: moduleName,
Deployment: row.DeploymentName,
Runner: model.RunnerKey(row.RunnerKey),
Endpoint: row.Endpoint,
}}

}), nil
Deployment: route.DeploymentName,
Runner: model.RunnerKey(route.RunnerKey),
Endpoint: route.Endpoint,
})
}
return out, nil
}

func (d *DAL) GetRunnerState(ctx context.Context, runnerKey model.RunnerKey) (RunnerState, error) {
Expand Down
15 changes: 0 additions & 15 deletions examples/online-boutique/services/echo/generated_ftl_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,3 @@ package echo
import (
"context"
)

type EchoRequest struct {
Name string `json:"name"`
}

type EchoResponse struct {
Message string `json:"message"`
}

// Echo returns a greeting with the current time.
//
//ftl:verb
func Echo(context.Context, EchoRequest) (EchoResponse, error) {
panic("Verb stubs should not be called directly, instead use github.com/TBD54566975/ftl/runtime-go/sdk.Call()")
}
2 changes: 1 addition & 1 deletion scripts/psql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ if [ -t 0 ]; then
fi

# shellcheck disable=SC2086
docker exec ${flags} ftl-db-1 psql --pset pager=off -U postgres "$@"
docker exec ${flags} ftl-db-1 psql --pset pager=off --pset null='<null>' -U postgres "$@"

0 comments on commit aaef01c

Please sign in to comment.