Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Al replace boltdb sqlite #313

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions impl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ docker run \
did-dht
```

### SQLite

To use a SQLite database as the storage backend, set configuration option `storage_uri` to a `sqlite://` URI with
the database connection string. The schema will be created or updated as needed while the program starts.

### Postgres

To use a postgres database as the storage backend, set configuration option `storage_uri` to a `postgres://` URI with
Expand Down
2 changes: 1 addition & 1 deletion impl/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func GetDefaultConfig() Config {
APIHost: "0.0.0.0",
APIPort: 8305,
BaseURL: "http://localhost:8305",
StorageURI: "bolt://diddht.db",
StorageURI: "sqlite://diddht.db",
Telemetry: false,
},
DHTConfig: DHTServiceConfig{
Expand Down
2 changes: 1 addition & 1 deletion impl/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ env = "dev"
api_host = "0.0.0.0"
api_port = 8305
log_level = "debug"
storage_uri = "bolt://diddht.db"
storage_uri = "sqlite://diddht.db"
telemetry = false

[dht]
Expand Down
2 changes: 1 addition & 1 deletion impl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/joho/godotenv v1.5.1
github.com/lestrrat-go/jwx/v2 v2.1.2
github.com/magefile/mage v1.15.0
github.com/mattn/go-sqlite3 v1.14.15
github.com/miekg/dns v1.1.62
github.com/mitchellh/go-homedir v1.1.0
github.com/mr-tron/base58 v1.2.0
Expand All @@ -29,7 +30,6 @@ require (
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/tv42/zbase32 v0.0.0-20220222190657-f76a9fc892fa
go.etcd.io/bbolt v1.3.11
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin v0.56.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.56.0
go.opentelemetry.io/otel v1.31.0
Expand Down
3 changes: 1 addition & 2 deletions impl/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
Expand Down Expand Up @@ -475,8 +476,6 @@ github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPyS
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0=
go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand Down
2 changes: 1 addition & 1 deletion impl/pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
func TestHealthCheckAPI(t *testing.T) {
shutdown := make(chan os.Signal, 1)
serviceConfig, err := config.LoadConfig("")
serviceConfig.ServerConfig.StorageURI = "bolt://health-check.db"
serviceConfig.ServerConfig.StorageURI = "sqlite://health-check.db"
serviceConfig.ServerConfig.BaseURL = testServerURL
assert.NoError(t, err)

Expand Down
2 changes: 1 addition & 1 deletion impl/pkg/service/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func TestNoConfig(t *testing.T) {
func newDHTService(t *testing.T, id string, bootstrapPeers ...anacrolixdht.Addr) DHTService {
defaultConfig := config.GetDefaultConfig()

db, err := storage.NewStorage(fmt.Sprintf("bolt://diddht-test-%s.db", id))
db, err := storage.NewStorage(fmt.Sprintf("sqlite://diddht-test-%s.db", id))
require.NoError(t, err)
require.NotEmpty(t, db)

Expand Down
290 changes: 0 additions & 290 deletions impl/pkg/storage/db/bolt/bolt.go

This file was deleted.

Loading