Skip to content

Commit

Permalink
services/federation: discontinue mysql support (#1753)
Browse files Browse the repository at this point in the history
Discontinue support for MySQL in the Federation service.

#1706 made the decision that we should remove mysql support from Federation due to limited users of that functionality and a lack of maintenance and testing in comparison to the main database solutions the other reference service implementations use, PostgreSQL.

Federation was the last service using MySQL in the repository, which also allows for it to be removed from the CircleCI setup and the client as a dependency.

- Remove mysql from Federation, displaying a meaningful error saying support is discontinued
- Add note to Federation CHANGELOG
- Update READMEs
- Remove from CircleCI config
- Remove packages supporting testing MySQL DBs
- Remove import of MySQL driver
  • Loading branch information
leighmcculloch authored Sep 17, 2019
1 parent 9894808 commit 00db88c
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 74 deletions.
6 changes: 1 addition & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,15 @@ commands:
sudo apt-get install postgresql-client-9.6
)
)
(sudo apt-get install mariadb-client-10.1 || sudo apt-get install mariadb-client-10.3)
- run:
name: Install dockerize
command: wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && sudo tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
environment:
DOCKERIZE_VERSION: v0.3.0
- run:
name: Wait for mysql, postgres and redis
name: Wait for postgres and redis
command: |
dockerize -wait tcp://localhost:5432 -timeout 1m
dockerize -wait tcp://localhost:3306 -timeout 1m
dockerize -wait tcp://localhost:6379 -timeout 1m
- run:
name: Run package tests
Expand Down Expand Up @@ -216,7 +214,6 @@ jobs:
- image: circleci/postgres:9.6.5-alpine-ram
environment:
POSTGRES_USER: circleci
- image: circleci/mysql:5.7
- image: circleci/redis:5.0-alpine
steps:
- install_go_deps
Expand All @@ -237,7 +234,6 @@ jobs:
- image: circleci/postgres:9.6.5-alpine-ram
environment:
POSTGRES_USER: circleci
- image: circleci/mysql:5.7
- image: circleci/redis:5.0-alpine
steps:
- install_go_deps
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ require (
github.com/go-chi/chi v3.1.5+incompatible
github.com/go-errors/errors v0.0.0-20150906023321-a41850380601
github.com/go-ini/ini v1.23.0 // indirect
github.com/go-sql-driver/mysql v1.4.0
github.com/gobuffalo/packr v1.12.1 // indirect
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d
github.com/gomodule/redigo v2.0.0+incompatible
Expand Down
1 change: 1 addition & 0 deletions services/federation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ bumps. A breaking change will get clearly notified in this log.
### Changed

- BREAKING CHANGE: The `url` database configuration has been renamed to `dsn` to more accurately reflect its content.
- BREAKING CHANGE: MySQL is no longer supported. To migrate your data to postgresql use any of the tools provided [here](https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL).
- Dropped support for Go 1.10, 1.11.

### Fixed
Expand Down
11 changes: 5 additions & 6 deletions services/federation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ By default this server uses a config file named `federation.cfg` in the current

* `port` - server listening port
* `database`
* `type` - database type (sqlite3, mysql, postgres)
* `type` - database type (sqlite3, postgres)
* `dsn` - The DSN (data source name) used to connect to the database connection. This value should be appropriate for the database type chosen.
* for `mysql`: `user:password@(host:port)/dbname` ([more info](https://github.com/go-sql-driver/mysql#dsn-data-source-name))
* for `postgres`: `postgres://user:password@host/dbname?sslmode=sslmode` ([more info](https://godoc.org/github.com/lib/pq#hdr-Connection_String_Parameters))
* `queries`
* `federation` - Implementation dependent query to fetch federation results, should return either 1 or 3 columns. These columns should be labeled `id`,`memo`,`memo_type`. Memo and memo_type are optional - see [Federation](https://www.stellar.org/developers/learn/concepts/federation.html) docs for more detail). When executed, this query will be provided with two input parameters, the first will be the name portion of a stellar address and the second will be the domain portion of a stellar address. For example, a request for `scott*stellar.org` would trigger a query with two input parameters, `scott` and `stellar.org` respectively.
Expand Down Expand Up @@ -43,8 +42,8 @@ In the case that every user owns a Stellar account, you don't need `memo`. You c
port = 8000

[database]
type = "mysql"
dsn = "dbuser:dbpassword@/dbname"
type = "postgres"
dsn = "postgres://user:password@host/dbname?sslmode=sslmode"

[queries]
federation = "SELECT account_id as id FROM Users WHERE username = ? AND domain = ?"
Expand All @@ -62,8 +61,8 @@ Let's say that your Stellar account ID is: `GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6
port = 8000

[database]
type = "mysql"
dsn = "dbuser:dbpassword@/dbname"
type = "postgres"
dsn = "postgres://user:password@host/dbname?sslmode=sslmode"

[queries]
federation = "SELECT username as memo, 'text' as memo_type, 'GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD' as id FROM Users WHERE username = ? AND domain = ?"
Expand Down
4 changes: 2 additions & 2 deletions services/federation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
type Config struct {
Port int `valid:"required"`
Database struct {
Type string `valid:"matches(^mysql|sqlite3|postgres$)"`
Type string `valid:"matches(^sqlite3|postgres$)"`
DSN string `valid:"required"`
} `valid:"required"`
Queries struct {
Expand Down Expand Up @@ -89,7 +89,7 @@ func initDriver(cfg Config) (federation.Driver, error) {

switch cfg.Database.Type {
case "mysql":
dialect = "mysql"
return nil, errors.Errorf("Invalid db type: %s, mysql support is discontinued", cfg.Database.Type)
case "postgres":
dialect = "postgres"
case "sqlite3":
Expand Down
39 changes: 39 additions & 0 deletions services/federation/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"testing"

"github.com/stellar/go/support/db/dbtest"
"github.com/stellar/go/support/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestInitDriver_dialect(t *testing.T) {
c := Config{}

testCases := []struct {
dbType string
dbDSN string
wantErr error
}{
{dbType: "", wantErr: errors.New("Invalid db type: ")},
{dbType: "postgres", dbDSN: dbtest.Postgres(t).DSN, wantErr: nil},
{dbType: "mysql", wantErr: errors.New("Invalid db type: mysql, mysql support is discontinued")},
{dbType: "bogus", wantErr: errors.New("Invalid db type: bogus")},
}

for _, tc := range testCases {
t.Run(tc.dbType, func(t *testing.T) {
c.Database.Type = tc.dbType
c.Database.DSN = tc.dbDSN
_, err := initDriver(c)
if tc.wantErr == nil {
require.Nil(t, err)
} else {
require.NotNil(t, err)
assert.Equal(t, tc.wantErr.Error(), err.Error())
}
})
}
}
32 changes: 0 additions & 32 deletions support/db/dbtest/mysql.go

This file was deleted.

26 changes: 0 additions & 26 deletions support/db/dbtest/mysql_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions support/db/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"github.com/jmoiron/sqlx"
"github.com/stellar/go/support/errors"

// Enable mysql
_ "github.com/go-sql-driver/mysql"
// Enable postgres
_ "github.com/lib/pq"
)
Expand Down

0 comments on commit 00db88c

Please sign in to comment.