remove pkg/transformers; extract shared files needed to

libraries/shared; work on automated db migration management
This commit is contained in:
Ian Norden
2019-02-24 21:38:47 -06:00
parent 55fa9b8364
commit decc2a3caf
545 changed files with 431 additions and 15922 deletions
+21 -2
View File
@@ -23,6 +23,7 @@ import (
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
@@ -47,8 +48,7 @@ var composeAndExecuteCmd = &cobra.Command{
ipcPath = "http://kovan0.vulcanize.io:8545"
[exporter]
filePath = "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins/"
fileName = "exporter"
name = "exporter"
[exporter.transformers]
transformer1 = "github.com/path/to/transformer1"
transformer2 = "github.com/path/to/transformer2"
@@ -75,9 +75,20 @@ loaded into and executed over by a generic watcher`,
func composeAndExecute() {
// generate code to build the plugin according to the config file
autogenConfig = autogen.Config{
FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins",
FileName: viper.GetString("exporter.name"),
Save: viper.GetBool("exporter.save"),
Initializers: viper.GetStringMapString("exporter.transformers"),
Dependencies: viper.GetStringMapString("exporter.repositories"),
Migrations: viper.GetStringMapString("exporter.migrations"),
}
fmt.Println("generating plugin")
generator := autogen.NewGenerator(autogenConfig, databaseConfig)
err := generator.GenerateExporterPlugin()
if err != nil {
fmt.Println("generating plugin failed")
log.Fatal(err)
}
@@ -86,14 +97,21 @@ func composeAndExecute() {
if err != nil {
log.Fatal(err)
}
if !autogenConfig.Save {
defer utils.ClearFiles(pluginPath)
}
fmt.Println("opening plugin")
plug, err := plugin.Open(pluginPath)
if err != nil {
fmt.Println("opening pluggin failed")
log.Fatal(err)
}
// Load the `Exporter` symbol from the plugin
fmt.Println("loading transformers from plugin")
symExporter, err := plug.Lookup("Exporter")
if err != nil {
fmt.Println("loading Exporter symbol failed")
log.Fatal(err)
}
@@ -116,6 +134,7 @@ func composeAndExecute() {
w.AddTransformers(initializers)
// Execute over the TransformerInitializer set using the watcher
fmt.Println("executing transformers")
ticker := time.NewTicker(pollingInterval)
defer ticker.Stop()
for range ticker.C {
-74
View File
@@ -1,74 +0,0 @@
// VulcanizeDB
// Copyright © 2018 Vulcanize
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package cmd
import (
"fmt"
"github.com/spf13/cobra"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
// getSignaturesCmd represents the getSignatures command
var getSignaturesCmd = &cobra.Command{
Use: "getSignatures",
Short: "A command to see transformer method and event signatures",
Long: `A convenience command to see method/event signatures for Maker transformers
vulcanizedb getSignatures`,
Run: func(cmd *cobra.Command, args []string) {
getSignatures()
},
}
func getSignatures() {
signatures := make(map[string]string)
signatures["BiteSignature"] = constants.GetBiteSignature()
signatures["CatFileChopLumpSignature"] = constants.GetCatFileChopLumpSignature()
signatures["CatFileFlipSignature"] = constants.GetCatFileFlipSignature()
signatures["CatFilePitVowSignature"] = constants.GetCatFilePitVowSignature()
signatures["DealSignature"] = constants.GetDealSignature()
signatures["DentFunctionSignature"] = constants.GetDentFunctionSignature()
signatures["DripDripSignature"] = constants.GetDripDripSignature()
signatures["DripFileIlkSignature"] = constants.GetDripFileIlkSignature()
signatures["DripFileRepoSignature"] = constants.GetDripFileRepoSignature()
signatures["DripFileVowSignature"] = constants.GetDripFileVowSignature()
signatures["FlapKickSignature"] = constants.GetFlapKickSignature()
signatures["FlipKickSignature"] = constants.GetFlipKickSignature()
signatures["FlopKickSignature"] = constants.GetFlopKickSignature()
signatures["FrobSignature"] = constants.GetFrobSignature()
signatures["LogValueSignature"] = constants.GetLogValueSignature()
signatures["PitFileDebtCeilingSignature"] = constants.GetPitFileDebtCeilingSignature()
signatures["PitFileIlkSignature"] = constants.GetPitFileIlkSignature()
signatures["TendFunctionSignature"] = constants.GetTendFunctionSignature()
signatures["VatFluxSignature"] = constants.GetVatFluxSignature()
signatures["VatFoldSignature"] = constants.GetVatFoldSignature()
signatures["VatGrabSignature"] = constants.GetVatGrabSignature()
signatures["VatHealSignature"] = constants.GetVatHealSignature()
signatures["VatInitSignature"] = constants.GetVatInitSignature()
signatures["VatMoveSignature"] = constants.GetVatMoveSignature()
signatures["VatSlipSignature"] = constants.GetVatSlipSignature()
signatures["VatTollSignature"] = constants.GetVatTollSignature()
signatures["VatTuneSignature"] = constants.GetVatTuneSignature()
signatures["VowFlogSignature"] = constants.GetVowFlogSignature()
for name, sig := range signatures {
fmt.Println(name, ": ", sig)
}
}
func init() {
rootCmd.AddCommand(getSignaturesCmd)
}
+2 -9
View File
@@ -55,7 +55,7 @@ const (
var rootCmd = &cobra.Command{
Use: "vulcanizedb",
PersistentPreRun: configure,
PersistentPreRun: database,
}
func Execute() {
@@ -65,7 +65,7 @@ func Execute() {
}
}
func configure(cmd *cobra.Command, args []string) {
func database(cmd *cobra.Command, args []string) {
ipc = viper.GetString("client.ipcpath")
levelDbPath = viper.GetString("client.leveldbpath")
storageDiffsPath = viper.GetString("filesystem.storageDiffsPath")
@@ -76,13 +76,6 @@ func configure(cmd *cobra.Command, args []string) {
User: viper.GetString("database.user"),
Password: viper.GetString("database.password"),
}
autogenConfig = autogen.Config{
FilePath: viper.GetString("exporter.filePath"),
FileName: viper.GetString("exporter.fileName"),
Initializers: viper.GetStringMapString("exporter.transformers"),
Dependencies: viper.GetStringMapString("exporter.repositories"),
Migrations: viper.GetStringMapString("exporter.migrations"),
}
viper.Set("database.config", databaseConfig)
}