github.com/streamingfast/substreams@v1.6.2/types.go (about)

     1  package substreams
     2  
     3  import (
     4  	"context"
     5  
     6  	pbsubstreamsrpc "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2"
     7  	pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
     8  )
     9  
    10  type ResponseFromAnyTier interface {
    11  	ProtoMessage()
    12  }
    13  type ResponseFunc func(ResponseFromAnyTier) error
    14  
    15  func NewBlockScopedDataResponse(in *pbsubstreamsrpc.BlockScopedData) *pbsubstreamsrpc.Response {
    16  	return &pbsubstreamsrpc.Response{
    17  		Message: &pbsubstreamsrpc.Response_BlockScopedData{BlockScopedData: in},
    18  	}
    19  }
    20  
    21  func NewSnapshotData(in *pbsubstreamsrpc.InitialSnapshotData) *pbsubstreamsrpc.Response {
    22  	return &pbsubstreamsrpc.Response{
    23  		Message: &pbsubstreamsrpc.Response_DebugSnapshotData{DebugSnapshotData: in},
    24  	}
    25  }
    26  
    27  func NewSnapshotComplete() *pbsubstreamsrpc.Response {
    28  	return &pbsubstreamsrpc.Response{
    29  		Message: &pbsubstreamsrpc.Response_DebugSnapshotComplete{DebugSnapshotComplete: &pbsubstreamsrpc.InitialSnapshotComplete{}},
    30  	}
    31  }
    32  
    33  // BlockHooks will always be called with a valid clock
    34  type BlockHook func(ctx context.Context, clock *pbsubstreams.Clock) error
    35  
    36  // PostJobHooks will be called at the end of a job. The clock can be `nil` in some circumstances, or it can be >= job.StopBlock
    37  type PostJobHook func(ctx context.Context, clock *pbsubstreams.Clock) error