Skip to content

Commit

Permalink
Set up mysql2 as a storage provider
Browse files Browse the repository at this point in the history
The flags needed to be redefined with a 2 suffix too to work around duplicate declarations.
  • Loading branch information
mhutchinson committed Nov 15, 2023
1 parent 5706630 commit 30db159
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/trillian_log_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
_ "github.com/google/trillian/storage/cloudspanner"
_ "github.com/google/trillian/storage/crdb"
_ "github.com/google/trillian/storage/mysql"
_ "github.com/google/trillian/storage/mysql2"

// Load quota providers
_ "github.com/google/trillian/quota/crdbqm"
Expand Down
1 change: 1 addition & 0 deletions cmd/trillian_log_signer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import (
_ "github.com/google/trillian/storage/cloudspanner"
_ "github.com/google/trillian/storage/crdb"
_ "github.com/google/trillian/storage/mysql"
_ "github.com/google/trillian/storage/mysql2"

// Load quota providers
_ "github.com/google/trillian/quota/crdbqm"
Expand Down
8 changes: 4 additions & 4 deletions storage/mysql2/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import (
)

var (
mySQLURI = flag.String("mysql_uri", "test:zaphod@tcp(127.0.0.1:3306)/test", "Connection URI for MySQL database")
maxConns = flag.Int("mysql_max_conns", 0, "Maximum connections to the database")
maxIdle = flag.Int("mysql_max_idle_conns", -1, "Maximum idle database connections in the connection pool")
mySQLURI = flag.String("mysql2_uri", "test:zaphod@tcp(127.0.0.1:3306)/test", "Connection URI for MySQL database")
maxConns = flag.Int("mysql2_max_conns", 0, "Maximum connections to the database")
maxIdle = flag.Int("mysql2_max_idle_conns", -1, "Maximum idle database connections in the connection pool")

mysqlMu sync.Mutex
mysqlErr error
Expand All @@ -49,7 +49,7 @@ func GetDatabase() (*sql.DB, error) {
}

func init() {
if err := storage.RegisterProvider("mysql", newMySQLStorageProvider); err != nil {
if err := storage.RegisterProvider("mysql2", newMySQLStorageProvider); err != nil {
klog.Fatalf("Failed to register storage provider mysql: %v", err)
}
}
Expand Down

0 comments on commit 30db159

Please sign in to comment.