-
Notifications
You must be signed in to change notification settings - Fork 5
/
subgraph.go
53 lines (41 loc) · 1.36 KB
/
subgraph.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package subgraph
import (
"github.com/streamingfast/sparkle/entity"
pbcodec "github.com/streamingfast/sparkle/pb/sf/ethereum/type/v2"
"go.uber.org/zap"
)
var MainSubgraphDef *Definition
type Subgraph interface {
Init() error
LoadDynamicDataSources(blockNum uint64) error
// FIXME: this should be a `bstream.Block`, and generated `HandleBlock`
// casts it to an ETH-specific block, or a `ToNative()` first thing.
HandleBlock(block *pbcodec.Block) error
LogStatus()
}
type DDL interface {
InitiateSchema(handleStatement func(statement string) error) error
CreateTables(handleStatement func(table string, statement string) error) error
CreateIndexes(handleStatement func(table string, statement string) error) error
DropIndexes(handleStatement func(table string, statement string) error) error
}
type Definition struct {
PackageName string
HighestParallelStep int
StartBlock uint64
IncludeFilter string
Entities *entity.Registry
DDL DDL
Manifest string
GraphQLSchema string
Abis map[string]string
New func(Base) Subgraph
MergeFunc func(step int, current, next entity.Interface) entity.Interface
}
// Base contains initialized values for a Subgraph instance, wrapped in a struct for future-proofness.
type Base struct {
Intrinsics
*Definition
ID string // QmHELLOWORLD as fetched when necessary
Log *zap.Logger
}