this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Slog for GORM

+28 -6
+3 -2
go.mod
··· 42 42 github.com/mr-tron/base58 v1.2.0 43 43 github.com/multiformats/go-multihash v0.2.3 44 44 github.com/opensearch-project/opensearch-go/v2 v2.3.0 45 + github.com/orandin/slog-gorm v1.3.2 45 46 github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f 46 47 github.com/prometheus/client_golang v1.17.0 47 48 github.com/prometheus/client_model v0.5.0 ··· 49 50 github.com/redis/go-redis/v9 v9.3.0 50 51 github.com/rivo/uniseg v0.1.0 51 52 github.com/samber/slog-echo v1.8.0 52 - github.com/stretchr/testify v1.8.4 53 + github.com/stretchr/testify v1.9.0 53 54 github.com/urfave/cli/v2 v2.25.7 54 55 github.com/whyrusleeping/cbor-gen v0.1.1-0.20240311221002-68b9f235c302 55 56 github.com/whyrusleeping/go-did v0.0.0-20230824162731-404d1707d5d6 ··· 70 71 golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 71 72 gorm.io/driver/postgres v1.5.0 72 73 gorm.io/driver/sqlite v1.5.4 73 - gorm.io/gorm v1.25.5 74 + gorm.io/gorm v1.25.9 74 75 gorm.io/plugin/opentelemetry v0.1.3 75 76 ) 76 77
+8 -4
go.sum
··· 499 499 github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= 500 500 github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= 501 501 github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= 502 + github.com/orandin/slog-gorm v1.3.2 h1:C0lKDQPAx/pF+8K2HL7bdShPwOEJpPM0Bn80zTzxU1g= 503 + github.com/orandin/slog-gorm v1.3.2/go.mod h1:MoZ51+b7xE9lwGNPYEhxcUtRNrYzjdcKvA8QXQQGEPA= 502 504 github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 h1:1/WtZae0yGtPq+TI6+Tv1WTxkukpXeMlviSxvL7SRgk= 503 505 github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9/go.mod h1:x3N5drFsm2uilKKuuYo6LdyD8vZAW55sH/9w+pbo1sw= 504 506 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= ··· 578 580 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 579 581 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 580 582 github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 581 - github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= 582 583 github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= 584 + github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= 585 + github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= 583 586 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 584 587 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 585 588 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= ··· 590 593 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 591 594 github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 592 595 github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= 593 - github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= 594 596 github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= 597 + github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 598 + github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 595 599 github.com/stvp/go-udp-testing v0.0.0-20201019212854-469649b16807/go.mod h1:7jxmlfBCDBXRzr0eAQJ48XC1hBu1np4CS5+cHEYfwpc= 596 600 github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= 597 601 github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= ··· 1078 1082 gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0= 1079 1083 gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4= 1080 1084 gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= 1081 - gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls= 1082 - gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= 1085 + gorm.io/gorm v1.25.9 h1:wct0gxZIELDk8+ZqF/MVnHLkA1rvYlBWUMv2EdsK1g8= 1086 + gorm.io/gorm v1.25.9/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= 1083 1087 gorm.io/plugin/opentelemetry v0.1.3 h1:z6QgEBef/+4S6D00+jUeRPreI0LAf7Idfqe3dz3TWKg= 1084 1088 gorm.io/plugin/opentelemetry v0.1.3/go.mod h1:tndJHOdvPT0pyGhOb8E2209eXJCUxhC5UpKw7bGVWeI= 1085 1089 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+17
util/cliutil/util.go
··· 12 12 "github.com/bluesky-social/indigo/api" 13 13 "github.com/bluesky-social/indigo/did" 14 14 "github.com/bluesky-social/indigo/xrpc" 15 + slogGorm "github.com/orandin/slog-gorm" 15 16 "github.com/urfave/cli/v2" 16 17 "gorm.io/driver/postgres" 17 18 "gorm.io/driver/sqlite" ··· 164 165 // NOTE(bnewbold): might also handle file:// as sqlite, but let's keep it 165 166 // explicit for now 166 167 168 + isSqlite := false 167 169 openConns := maxConnections 168 170 if strings.HasPrefix(dburl, "sqlite://") { 169 171 sqliteSuffix := dburl[len("sqlite://"):] ··· 174 176 } 175 177 dial = sqlite.Open(sqliteSuffix) 176 178 openConns = 1 179 + isSqlite = true 177 180 } else if strings.HasPrefix(dburl, "sqlite=") { 178 181 sqliteSuffix := dburl[len("sqlite="):] 179 182 // if this isn't ":memory:", ensure that directory exists (eg, if db ··· 183 186 } 184 187 dial = sqlite.Open(sqliteSuffix) 185 188 openConns = 1 189 + isSqlite = true 186 190 } else if strings.HasPrefix(dburl, "postgresql://") || strings.HasPrefix(dburl, "postgres://") { 187 191 // can pass entire URL, with prefix, to gorm driver 188 192 dial = postgres.Open(dburl) ··· 194 198 return nil, fmt.Errorf("unsupported or unrecognized DATABASE_URL value: %s", dburl) 195 199 } 196 200 201 + gormLogger := slogGorm.New() 202 + 197 203 db, err := gorm.Open(dial, &gorm.Config{ 198 204 SkipDefaultTransaction: true, 199 205 TranslateError: true, 206 + Logger: gormLogger, 200 207 }) 201 208 if err != nil { 202 209 return nil, err ··· 210 217 sqldb.SetMaxIdleConns(80) 211 218 sqldb.SetMaxOpenConns(openConns) 212 219 sqldb.SetConnMaxIdleTime(time.Hour) 220 + 221 + if isSqlite { 222 + // Set pragmas for sqlite 223 + if err := db.Exec("PRAGMA journal_mode=WAL;").Error; err != nil { 224 + return nil, err 225 + } 226 + if err := db.Exec("PRAGMA synchronous=normal;").Error; err != nil { 227 + return nil, err 228 + } 229 + } 213 230 214 231 return db, nil 215 232 }