You've already forked speedtest-go
@ -5,12 +5,10 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"go.etcd.io/bbolt"
|
||||
|
||||
"github.com/librespeed/speedtest/database/schema"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -4,8 +4,11 @@ import (
|
||||
"github.com/librespeed/speedtest/config"
|
||||
"github.com/librespeed/speedtest/database/bolt"
|
||||
"github.com/librespeed/speedtest/database/mysql"
|
||||
"github.com/librespeed/speedtest/database/none"
|
||||
"github.com/librespeed/speedtest/database/postgresql"
|
||||
"github.com/librespeed/speedtest/database/schema"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -26,5 +29,9 @@ func SetDBInfo(conf *config.Config) {
|
||||
DB = mysql.Open(conf.DatabaseHostname, conf.DatabaseUsername, conf.DatabasePassword, conf.DatabaseName)
|
||||
case "bolt":
|
||||
DB = bolt.Open(conf.DatabaseFile)
|
||||
case "none":
|
||||
DB = none.Open("")
|
||||
default:
|
||||
log.Fatalf("Unsupported database type: %s", conf.DatabaseType)
|
||||
}
|
||||
}
|
||||
|
23
database/none/none.go
Normal file
23
database/none/none.go
Normal file
@ -0,0 +1,23 @@
|
||||
package none
|
||||
|
||||
import (
|
||||
"github.com/librespeed/speedtest/database/schema"
|
||||
)
|
||||
|
||||
type None struct{}
|
||||
|
||||
func Open(_ string) *None {
|
||||
return &None{}
|
||||
}
|
||||
|
||||
func (n *None) Insert(_ *schema.TelemetryData) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *None) FetchByUUID(_ string) (*schema.TelemetryData, error) {
|
||||
return &schema.TelemetryData{}, nil
|
||||
}
|
||||
|
||||
func (n *None) FetchLast100() ([]schema.TelemetryData, error) {
|
||||
return []schema.TelemetryData{}, nil
|
||||
}
|
Reference in New Issue
Block a user