-
Notifications
You must be signed in to change notification settings - Fork 45
/
options.go
52 lines (42 loc) · 1.15 KB
/
options.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
package pipeline
import (
"context"
"github.com/streamingfast/substreams"
pbsubstreamsrpc "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2"
)
type PipelineOptioner interface {
PipelineOptions(ctx context.Context, startBlock, stopBlock uint64, requestID string) []Option
}
type Option func(p *Pipeline)
func WithPreBlockHook(f substreams.BlockHook) Option {
return func(p *Pipeline) {
p.preBlockHooks = append(p.preBlockHooks, f)
}
}
// WithPendingUndoMessage allows sending a message right before we send the first 'BlockScopedData'
func WithPendingUndoMessage(msg *pbsubstreamsrpc.Response) Option {
return func(p *Pipeline) {
p.pendingUndoMessage = msg
}
}
func WithPostBlockHook(f substreams.BlockHook) Option {
return func(p *Pipeline) {
p.postBlockHooks = append(p.postBlockHooks, f)
}
}
func WithPostJobHook(f substreams.PostJobHook) Option {
return func(p *Pipeline) {
p.postJobHooks = append(p.postJobHooks, f)
}
}
func WithFinalBlocksOnly() Option {
return func(p *Pipeline) {
p.finalBlocksOnly = true
}
}
func WithHighestStage(stage uint32) Option {
return func(p *Pipeline) {
s := int(stage)
p.highestStage = &s
}
}