diff --git a/cli/setup.go b/cli/setup.go index 4028e0b3..3a6facb3 100644 --- a/cli/setup.go +++ b/cli/setup.go @@ -58,7 +58,7 @@ func setup() { } if opts.DB.Path != "memory" { - if ok, _ := regexp.MatchString(`^(s3|gcs|logr|file|mysql|dendrodb)://(.+)$`, opts.DB.Path); !ok { + if ok, _ := regexp.MatchString(`^(s3|gcs|logr|file|dendrodb)://(.+)$`, opts.DB.Path); !ok { log.Fatalf("Invalid path %s. Specify a valid data store configuration path", opts.DB.Path) } } diff --git a/db/db.go b/db/db.go index 43b67b54..4aed9241 100644 --- a/db/db.go +++ b/db/db.go @@ -31,7 +31,6 @@ import ( "github.com/abcum/surreal/util/data" "github.com/abcum/surreal/util/uuid" - _ "github.com/abcum/surreal/kvs/mysql" _ "github.com/abcum/surreal/kvs/rixxdb" ) diff --git a/glide.yaml b/glide.yaml index d81565a7..611dfd0c 100644 --- a/glide.yaml +++ b/glide.yaml @@ -10,8 +10,6 @@ import: version: ^3.2.0 - package: github.com/elithrar/simple-scrypt version: ^1.3.0 -- package: github.com/go-sql-driver/mysql - version: ^1.3.0 - package: github.com/gorilla/websocket version: ^1.2.0 - package: github.com/hashicorp/serf diff --git a/kvs/ds.go b/kvs/ds.go index 47bf7ab3..81a8923f 100644 --- a/kvs/ds.go +++ b/kvs/ds.go @@ -45,8 +45,6 @@ func New(opts *cnf.Options) (ds *DS, err error) { db, err = stores["rixxdb"](opts) case strings.HasPrefix(opts.DB.Path, "file://"): db, err = stores["rixxdb"](opts) - case strings.HasPrefix(opts.DB.Path, "mysql://"): - db, err = stores["mysql"](opts) case strings.HasPrefix(opts.DB.Path, "rixxdb://"): db, err = stores["rixxdb"](opts) case strings.HasPrefix(opts.DB.Path, "dendrodb://"): diff --git a/kvs/mysql/db.go b/kvs/mysql/db.go deleted file mode 100644 index 9b1686d7..00000000 --- a/kvs/mysql/db.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright © 2016 Abcum Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mysql - -import ( - "io" - - "context" - - "database/sql" - - "github.com/abcum/surreal/kvs" - "github.com/abcum/surreal/log" -) - -type DB struct { - pntr *sql.DB -} - -func (db *DB) Begin(ctx context.Context, writable bool) (txn kvs.TX, err error) { - var pntr *sql.Tx - if pntr, err = db.pntr.BeginTx(ctx, &sql.TxOptions{}); err != nil { - log.WithPrefix("kvs").Errorln(err) - err = &kvs.DBError{Err: err} - return - } - return &TX{pntr: pntr}, err -} - -func (db *DB) Import(r io.Reader) (err error) { - return nil -} - -func (db *DB) Export(w io.Writer) (err error) { - return nil -} - -func (db *DB) Close() (err error) { - return db.pntr.Close() -} diff --git a/kvs/mysql/err.go b/kvs/mysql/err.go deleted file mode 100644 index 733bc7c9..00000000 --- a/kvs/mysql/err.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright © 2016 Abcum Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mysql - -import ( - "errors" -) - -// ErrKvNotExpectedValue occurs when conditionally putting or deleting a key-value item. -var ErrTxNotExpectedValue = errors.New("KV val is not expected value") diff --git a/kvs/mysql/kv.go b/kvs/mysql/kv.go deleted file mode 100644 index e5bebc0d..00000000 --- a/kvs/mysql/kv.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright © 2016 Abcum Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mysql - -// KV represents a row stored in the database. -type KV struct { - ver uint64 - key []byte - val []byte -} - -// Exi returns whether this key-value item actually exists. -func (kv *KV) Exi() bool { - return kv.val != nil -} - -// Key returns the key for the underlying key-value item. -func (kv *KV) Key() []byte { - return kv.key -} - -// Val returns the value for the underlying key-value item. -func (kv *KV) Val() []byte { - return kv.val -} - -// Ver returns the version for the underlying key-value item. -func (kv *KV) Ver() uint64 { - return kv.ver -} diff --git a/kvs/mysql/main.go b/kvs/mysql/main.go deleted file mode 100644 index b7526c01..00000000 --- a/kvs/mysql/main.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright © 2016 Abcum Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mysql - -import ( - "time" - - "strings" - - "crypto/tls" - "crypto/x509" - - "database/sql" - - "github.com/abcum/surreal/cnf" - "github.com/abcum/surreal/kvs" - "github.com/abcum/surreal/log" - - "github.com/go-sql-driver/mysql" -) - -func init() { - - kvs.Register("mysql", func(opts *cnf.Options) (db kvs.DB, err error) { - - var pntr *sql.DB - - path := strings.TrimPrefix(opts.DB.Path, "mysql://") - - if cnf.Settings.DB.Cert.SSL { - - cas := x509.NewCertPool() - all := make([]tls.Certificate, 0, 1) - car := []byte(cnf.Settings.DB.Cert.CA) - crt := []byte(cnf.Settings.DB.Cert.Crt) - key := []byte(cnf.Settings.DB.Cert.Key) - - if ok := cas.AppendCertsFromPEM(car); !ok { - log.WithPrefix("kvs").Errorln("Failed to append CA file.") - } - - par, err := tls.X509KeyPair(crt, key) - if err != nil { - log.WithPrefix("kvs").Errorln(err) - } - - mysql.RegisterTLSConfig("default", &tls.Config{ - InsecureSkipVerify: true, - RootCAs: cas, - Certificates: append(all, par), - }) - - } - - pntr, err = sql.Open("mysql", path) - if err != nil { - log.WithPrefix("kvs").Errorln(err) - return - } - - // Set the maximum connection lifetime - - pntr.SetConnMaxLifetime(1 * time.Hour) - - // Output logs to the default logger - - mysql.SetLogger(log.Instance()) - - // Set the max number of idle connections - - pntr.SetMaxIdleConns(350) - - // Set the max number of open connections - - pntr.SetMaxOpenConns(350) - - // Return the database pointer - - return &DB{pntr: pntr}, err - - }) - -} diff --git a/kvs/mysql/sql.go b/kvs/mysql/sql.go deleted file mode 100644 index b4c91101..00000000 --- a/kvs/mysql/sql.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright © 2016 Abcum Ltd -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package mysql - -const sqlClr = ` - DELETE FROM kv - WHERE k=? -` - -const sqlClrP = ` - DELETE FROM kv - WHERE k LIKE CONCAT(?, '%') - LIMIT ? -` - -const sqlClrR = ` - DELETE FROM kv - WHERE k>=? AND k=? AND k=? AND k m { - continue - } - b[i] = chars[c%t] - i++ - if i == l { - return b - } - } - - } - -}