Skip to content

Commit

Permalink
refactor: move dal errors into backend/dal (#1902)
Browse files Browse the repository at this point in the history
We should limit our top-level packages.
  • Loading branch information
alecthomas authored Jun 28, 2024
1 parent 9f48c74 commit 078e7ee
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 22 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ buildengine/.gitignore
go.work*
junit*.xml
/readme-tests
**/_ftl
/docs/public
.ftl.lock
2 changes: 1 addition & 1 deletion backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ import (
"github.com/TBD54566975/ftl/backend/controller/scaling"
"github.com/TBD54566975/ftl/backend/controller/scaling/localscaling"
"github.com/TBD54566975/ftl/backend/controller/scheduledtask"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/console/pbconsoleconnect"
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
"github.com/TBD54566975/ftl/backend/schema"
cf "github.com/TBD54566975/ftl/common/configuration"
"github.com/TBD54566975/ftl/db/dalerrs"
frontend "github.com/TBD54566975/ftl/frontend"
"github.com/TBD54566975/ftl/internal/cors"
ftlhttp "github.com/TBD54566975/ftl/internal/http"
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/async_calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/alecthomas/types/either"

"github.com/TBD54566975/ftl/backend/controller/sql"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
)

type asyncOriginParseRoot struct {
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/dal.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
"google.golang.org/protobuf/proto"

"github.com/TBD54566975/ftl/backend/controller/sql"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/maps"
"github.com/TBD54566975/ftl/internal/model"
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/dal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"golang.org/x/sync/errgroup"

"github.com/TBD54566975/ftl/backend/controller/sql/sqltest"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/model"
"github.com/TBD54566975/ftl/internal/sha256"
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/jackc/pgx/v5"

"github.com/TBD54566975/ftl/backend/controller/sql"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/model"
)
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

"github.com/TBD54566975/ftl/backend/controller/leases"
"github.com/TBD54566975/ftl/backend/controller/sql"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
)

// StartFSMTransition sends an event to an executing instance of an FSM.
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/fsm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/alecthomas/types/either"

"github.com/TBD54566975/ftl/backend/controller/sql/sqltest"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/log"
)

Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/TBD54566975/ftl/backend/controller/leases"
"github.com/TBD54566975/ftl/backend/controller/sql"
"github.com/TBD54566975/ftl/db/dalerrs"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/internal/log"
)

Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/lease_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/TBD54566975/ftl/backend/controller/leases"
"github.com/TBD54566975/ftl/backend/controller/sql"
"github.com/TBD54566975/ftl/backend/controller/sql/sqltest"
"github.com/TBD54566975/ftl/db/dalerrs"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/internal/log"
)

Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/jackc/pgx/v5"
"github.com/jpillora/backoff"

"github.com/TBD54566975/ftl/db/dalerrs"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/model"
)
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/dal/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"time"

"github.com/TBD54566975/ftl/backend/controller/sql"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/model"
"github.com/TBD54566975/ftl/internal/slices"
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/ingress/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/alecthomas/types/optional"

"github.com/TBD54566975/ftl/backend/controller/dal"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
ftlv1 "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1"
schemapb "github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/schema"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/log"
"github.com/TBD54566975/ftl/internal/model"
)
Expand Down
2 changes: 1 addition & 1 deletion backend/controller/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"time"

"github.com/TBD54566975/ftl/backend/controller/dal"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/TBD54566975/ftl/internal/slices"
)

Expand Down
5 changes: 3 additions & 2 deletions backend/controller/leader/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"sync"
"time"

"github.com/alecthomas/types/optional"

"github.com/TBD54566975/ftl/backend/controller/leases"
"github.com/TBD54566975/ftl/db/dalerrs"
dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/internal/log"
"github.com/alecthomas/types/optional"
)

// LeaderFactory is a function that is called whenever a new leader is acquired.
Expand Down
10 changes: 6 additions & 4 deletions db/dalerrs/dalerrs.go → backend/dal/errors.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Package dalerrs provides common error handling utilities for all domain-specific DALs,
// e.g. controller DAL and configuration DAL, which all connect to the same underlying DB
// and maintain the same interface guarantees
package dalerrs
// Package dal provides common types and functions for domain-specific DALs.
//
// In particular, common error types and error handling function for all
// domain-specific DALs, e.g. controller DAL and configuration DAL, which all
// connect to the same underlying DB and maintain the same interface guarantees
package dal

import (
stdsql "database/sql"
Expand Down
2 changes: 1 addition & 1 deletion common/configuration/dal/dal.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/alecthomas/types/optional"
"github.com/jackc/pgx/v5/pgxpool"

dalerrs "github.com/TBD54566975/ftl/backend/dal"
"github.com/TBD54566975/ftl/common/configuration/sql"
"github.com/TBD54566975/ftl/db/dalerrs"
)

type DAL struct {
Expand Down
3 changes: 2 additions & 1 deletion common/configuration/db_config_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"context"
"net/url"

"github.com/TBD54566975/ftl/db/dalerrs"
"github.com/alecthomas/types/optional"

dalerrs "github.com/TBD54566975/ftl/backend/dal"
)

// DBConfigProvider is a configuration provider that stores configuration in its key.
Expand Down

0 comments on commit 078e7ee

Please sign in to comment.