Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Only include go-sqlite3 on the relevant binaries (#1900)
Browse files Browse the repository at this point in the history
* Only include go-sqlite3 on the relevant binaries

* The driver name is always sqlite3 now

* Update to matrix-org/go-sqlite3-js@e537baa
  • Loading branch information
neilalexander authored Jul 20, 2021
1 parent 0ff078e commit f63068d
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 26 deletions.
1 change: 0 additions & 1 deletion appservice/storage/sqlite3/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/gomatrixserverlib"
_ "github.com/mattn/go-sqlite3"
)

// Database stores events intended to be later sent to application services
Expand Down
2 changes: 2 additions & 0 deletions cmd/dendrite-demo-libp2p/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import (
"github.com/matrix-org/dendrite/eduserver/cache"

"github.com/sirupsen/logrus"

_ "github.com/mattn/go-sqlite3"
)

func createKeyDB(
Expand Down
2 changes: 2 additions & 0 deletions cmd/dendrite-demo-pinecone/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import (
pineconeSessions "github.com/matrix-org/pinecone/sessions"

"github.com/sirupsen/logrus"

_ "github.com/mattn/go-sqlite3"
)

var (
Expand Down
2 changes: 2 additions & 0 deletions cmd/dendrite-demo-yggdrasil/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import (
"github.com/matrix-org/gomatrixserverlib"

"github.com/sirupsen/logrus"

_ "github.com/mattn/go-sqlite3"
)

var (
Expand Down
2 changes: 2 additions & 0 deletions cmd/dendrite-monolith-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import (
"github.com/matrix-org/dendrite/signingkeyserver"
"github.com/matrix-org/dendrite/userapi"
"github.com/sirupsen/logrus"

_ "github.com/mattn/go-sqlite3"
)

var (
Expand Down
2 changes: 2 additions & 0 deletions cmd/dendrite-polylith-multi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/matrix-org/dendrite/setup"
"github.com/matrix-org/dendrite/setup/config"
"github.com/sirupsen/logrus"

_ "github.com/mattn/go-sqlite3"
)

type entrypoint func(base *setup.BaseDendrite, cfg *config.Dendrite)
Expand Down
2 changes: 0 additions & 2 deletions federationsender/storage/sqlite3/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ package sqlite3
import (
"database/sql"

_ "github.com/mattn/go-sqlite3"

"github.com/matrix-org/dendrite/federationsender/storage/shared"
"github.com/matrix-org/dendrite/federationsender/storage/sqlite3/deltas"
"github.com/matrix-org/dendrite/internal/caching"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/lucas-clemente/quic-go v0.19.3
github.com/matrix-org/dugong v0.0.0-20180820122854-51a565b5666b
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4
github.com/matrix-org/go-sqlite3-js v0.0.0-20210625141222-bd2b7124cee8
github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16
github.com/matrix-org/gomatrixserverlib v0.0.0-20210719140634-f44a103bb12e
github.com/matrix-org/naffka v0.0.0-20210623111924-14ff508b58e0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1024,8 +1024,8 @@ github.com/matrix-org/dugong v0.0.0-20180820122854-51a565b5666b h1:xpcmnpfUImRC4
github.com/matrix-org/dugong v0.0.0-20180820122854-51a565b5666b/go.mod h1:NgPCr+UavRGH6n5jmdX8DuqFZ4JiCWIJoZiuhTRLSUg=
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4 h1:eqE5OnGx9ZMWmrRbD3KF/3KtTunw0iQulI7YxOIdxo4=
github.com/matrix-org/go-http-js-libp2p v0.0.0-20200518170932-783164aeeda4/go.mod h1:3WluEZ9QXSwU30tWYqktnpC1x9mwZKx1r8uAv8Iq+a4=
github.com/matrix-org/go-sqlite3-js v0.0.0-20210625141222-bd2b7124cee8 h1:/FKUeUlCATr1gXxYqlaJgH8FW/sw0Jz8t7s8BIlECfg=
github.com/matrix-org/go-sqlite3-js v0.0.0-20210625141222-bd2b7124cee8/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d h1:mGhPVaTht5NViFN/UpdrIlRApmH2FWcVaKUH5MdBKiY=
github.com/matrix-org/go-sqlite3-js v0.0.0-20210709140738-b0d1ba599a6d/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
github.com/matrix-org/gomatrix v0.0.0-20190528120928-7df988a63f26/go.mod h1:3fxX6gUjWyI/2Bt7J1OLhpCzOfO/bB3AiX0cJtEKud0=
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16 h1:ZtO5uywdd5dLDCud4r0r55eP4j9FuUNpl60Gmntcop4=
github.com/matrix-org/gomatrix v0.0.0-20210324163249-be2af5ef2e16/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
Expand Down
8 changes: 0 additions & 8 deletions internal/sqlutil/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"database/sql"
"errors"
"fmt"
"runtime"
"strings"

"github.com/matrix-org/util"
Expand Down Expand Up @@ -113,13 +112,6 @@ func QueryVariadicOffset(count, offset int) string {
return str
}

func SQLiteDriverName() string {
if runtime.GOOS == "js" {
return "sqlite3_js"
}
return "sqlite3"
}

func minOfInts(a, b int) int {
if a <= b {
return a
Expand Down
4 changes: 2 additions & 2 deletions internal/sqlutil/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func Open(dbProperties *config.DatabaseOptions) (*sql.DB, error) {
var driverName, dsn string
switch {
case dbProperties.ConnectionString.IsSQLite():
driverName = SQLiteDriverName()
driverName = "sqlite3"
dsn, err = ParseFileURI(dbProperties.ConnectionString)
if err != nil {
return nil, fmt.Errorf("ParseFileURI: %w", err)
Expand All @@ -123,7 +123,7 @@ func Open(dbProperties *config.DatabaseOptions) (*sql.DB, error) {
if err != nil {
return nil, err
}
if driverName != SQLiteDriverName() {
if driverName != "sqlite3" {
logrus.WithFields(logrus.Fields{
"MaxOpenConns": dbProperties.MaxOpenConns(),
"MaxIdleConns": dbProperties.MaxIdleConns(),
Expand Down
1 change: 0 additions & 1 deletion mediaapi/storage/sqlite3/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/matrix-org/dendrite/mediaapi/types"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/gomatrixserverlib"
_ "github.com/mattn/go-sqlite3"
)

// Database is used to store metadata about a repository of media files.
Expand Down
2 changes: 0 additions & 2 deletions roomserver/storage/sqlite3/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"context"
"database/sql"

_ "github.com/mattn/go-sqlite3"

"github.com/matrix-org/dendrite/internal/caching"
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/roomserver/storage/shared"
Expand Down
2 changes: 0 additions & 2 deletions signingkeyserver/storage/sqlite3/keydb.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/gomatrixserverlib"

_ "github.com/mattn/go-sqlite3"
)

// A Database implements gomatrixserverlib.KeyDatabase and is used to store
Expand Down
3 changes: 0 additions & 3 deletions syncapi/storage/sqlite3/syncserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ package sqlite3
import (
"database/sql"

// Import the sqlite3 package
_ "github.com/mattn/go-sqlite3"

"github.com/matrix-org/dendrite/internal/sqlutil"
"github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/syncapi/storage/shared"
Expand Down
2 changes: 0 additions & 2 deletions userapi/storage/devices/sqlite3/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/matrix-org/dendrite/userapi/api"
"github.com/matrix-org/dendrite/userapi/storage/devices/sqlite3/deltas"
"github.com/matrix-org/gomatrixserverlib"

_ "github.com/mattn/go-sqlite3"
)

// The length of generated device IDs
Expand Down

0 comments on commit f63068d

Please sign in to comment.