aboutsummaryrefslogtreecommitdiffstats
path: root/indexer/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'indexer/config.go')
-rw-r--r--indexer/config.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/indexer/config.go b/indexer/config.go
new file mode 100644
index 000000000..3b626272a
--- /dev/null
+++ b/indexer/config.go
@@ -0,0 +1,35 @@
+package indexer
+
+import (
+ "plugin"
+)
+
+// Config is data sources related configs struct.
+type Config struct {
+ // Used by dex/backend init flow.
+ Enable bool
+
+ // Plugin path for building components.
+ Plugin string
+}
+
+// NewIndexerFromConfig initialize exporter according to given config.
+func NewIndexerFromConfig(bc ReadOnlyBlockChain, c Config) (idx Indexer) {
+ if c.Plugin == "" {
+ // default
+ return
+ }
+
+ plug, err := plugin.Open(c.Plugin)
+ if err != nil {
+ panic(err)
+ }
+
+ symbol, err := plug.Lookup(NewIndexerFuncName)
+ if err != nil {
+ panic(err)
+ }
+
+ idx = symbol.(NewIndexerFunc)(bc, c)
+ return
+}