-
Notifications
You must be signed in to change notification settings - Fork 47
/
types.go
37 lines (29 loc) · 1.25 KB
/
types.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
package substreams
import (
"context"
pbsubstreamsrpc "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2"
pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
)
type ResponseFromAnyTier interface {
ProtoMessage()
}
type ResponseFunc func(ResponseFromAnyTier) error
func NewBlockScopedDataResponse(in *pbsubstreamsrpc.BlockScopedData) *pbsubstreamsrpc.Response {
return &pbsubstreamsrpc.Response{
Message: &pbsubstreamsrpc.Response_BlockScopedData{BlockScopedData: in},
}
}
func NewSnapshotData(in *pbsubstreamsrpc.InitialSnapshotData) *pbsubstreamsrpc.Response {
return &pbsubstreamsrpc.Response{
Message: &pbsubstreamsrpc.Response_DebugSnapshotData{DebugSnapshotData: in},
}
}
func NewSnapshotComplete() *pbsubstreamsrpc.Response {
return &pbsubstreamsrpc.Response{
Message: &pbsubstreamsrpc.Response_DebugSnapshotComplete{DebugSnapshotComplete: &pbsubstreamsrpc.InitialSnapshotComplete{}},
}
}
// BlockHooks will always be called with a valid clock
type BlockHook func(ctx context.Context, clock *pbsubstreams.Clock) error
// PostJobHooks will be called at the end of a job. The clock can be `nil` in some circumstances, or it can be >= job.StopBlock
type PostJobHook func(ctx context.Context, clock *pbsubstreams.Clock) error