-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathtypes.go
More file actions
49 lines (41 loc) · 1.86 KB
/
types.go
File metadata and controls
49 lines (41 loc) · 1.86 KB
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
package substreams
import (
"context"
pbssinternal "github.com/streamingfast/substreams/pb/sf/substreams/intern/v2"
pbsubstreamsrpc "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2"
pbsubstreamsrpcv4 "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v4"
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 NewBlockScopedDatasResponse(in *pbsubstreamsrpcv4.BlockScopedDatas) *pbsubstreamsrpcv4.Response {
return &pbsubstreamsrpcv4.Response{
Message: &pbsubstreamsrpcv4.Response_BlockScopedDatas{BlockScopedDatas: in},
}
}
func NewBlockScopedDataInternResponse(in *pbssinternal.BlockScopedData) *pbssinternal.ProcessRangeResponse {
return &pbssinternal.ProcessRangeResponse{
Type: &pbssinternal.ProcessRangeResponse_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