forked from cerc-io/ipld-eth-server
work on porting storage watcher; watcher type is defined for
transformers in the config, storage transformers are exported from plugin like event transformers
This commit is contained in:
+46
-3
@@ -26,9 +26,10 @@ import (
|
||||
)
|
||||
|
||||
type Plugin struct {
|
||||
Initializers map[string]string // Map of import aliases to transformer initializer paths
|
||||
Dependencies map[string]string // Map of vendor dep names to their repositories
|
||||
Migrations map[string]string // Map of vendor dep names to relative path from repository to db migrations
|
||||
Initializers map[string]string // Map of import aliases to transformer initializer paths
|
||||
Dependencies map[string]string // Map of vendor dep names to their repositories
|
||||
Migrations map[string]string // Map of vendor dep names to relative path from repository to db migrations
|
||||
Types map[string]PluginType // Map of import aliases to their transformer initializer type (e.g. eth-event vs eth-storage)
|
||||
FilePath string
|
||||
FileName string
|
||||
Save bool
|
||||
@@ -64,3 +65,45 @@ func (c *Plugin) GetMigrationsPaths() ([]string, error) {
|
||||
|
||||
return paths, nil
|
||||
}
|
||||
|
||||
type PluginType int
|
||||
|
||||
const (
|
||||
UnknownTransformerType PluginType = iota + 1
|
||||
EthEvent
|
||||
EthStorage
|
||||
IpfsEvent
|
||||
IpfsStorage
|
||||
)
|
||||
|
||||
func (pt PluginType) String() string {
|
||||
names := [...]string{
|
||||
"eth_event",
|
||||
"eth_storage",
|
||||
"ipfs_event",
|
||||
"ipfs_storage",
|
||||
}
|
||||
|
||||
if pt > IpfsStorage || pt < EthEvent {
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
return names[pt]
|
||||
}
|
||||
|
||||
func GetPluginType(str string) PluginType {
|
||||
types := [...]PluginType{
|
||||
EthEvent,
|
||||
EthStorage,
|
||||
IpfsEvent,
|
||||
IpfsStorage,
|
||||
}
|
||||
|
||||
for _, ty := range types {
|
||||
if ty.String() == str && ty.String() != "Unknown" {
|
||||
return ty
|
||||
}
|
||||
}
|
||||
|
||||
return UnknownTransformerType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user