forked from algorand/conduit
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipelining followups #8
Closed
Closed
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
29ed381
privatize RetriesXYZ() + retriesNoInput()
78b8447
don't block inside of Start()
a4d7376
trim the special end of round log
f96dbc8
noop importer
d65afb4
test CLI for the health endpoint
f12f4e6
lint
4d0386a
gofmt
f38ed13
Update conduit/plugins/importers/noop/sample.yaml
tzaffi f68c929
Update pkg/cli/cli_test.go
tzaffi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -481,7 +481,7 @@ func (p *pipelineImpl) importerHandler(importer importers.Importer, roundChan <- | |
totalSelectWait += waitTime | ||
p.logger.Tracef("importer handler waited %dms to receive round %d", waitTime.Milliseconds(), rnd) | ||
|
||
blkData, importTime, lastError := Retries(importer.GetBlock, rnd, p, importer.Metadata().Name) | ||
blkData, importTime, lastError := retries(importer.GetBlock, rnd, p, importer.Metadata().Name) | ||
if lastError != nil { | ||
p.cancelWithProblem(fmt.Errorf("importer %s handler (%w): failed to import round %d after %dms: %w", importer.Metadata().Name, errImporterCause, rnd, importTime.Milliseconds(), lastError)) | ||
return | ||
|
@@ -533,7 +533,7 @@ func (p *pipelineImpl) processorHandler(idx int, proc processors.Processor, blkI | |
|
||
var procTime time.Duration | ||
var lastError error | ||
blk, procTime, lastError = Retries(proc.Process, blk, p, proc.Metadata().Name) | ||
blk, procTime, lastError = retries(proc.Process, blk, p, proc.Metadata().Name) | ||
if lastError != nil { | ||
p.cancelWithProblem(fmt.Errorf("processor[%d] %s handler (%w): failed to process round %d after %dms: %w", idx, proc.Metadata().Name, errProcessorCause, lastRnd, procTime.Milliseconds(), lastError)) | ||
return | ||
|
@@ -598,7 +598,7 @@ func (p *pipelineImpl) exporterHandler(exporter exporters.Exporter, blkChan plug | |
} | ||
|
||
var exportTime time.Duration | ||
exportTime, lastError = RetriesNoOutput(exporter.Receive, blk, p, eName) | ||
exportTime, lastError = retriesNoOutput(exporter.Receive, blk, p, eName) | ||
if lastError != nil { | ||
lastError = fmt.Errorf("aborting after failing to export round %d: %w", lastRound, lastError) | ||
return | ||
|
@@ -640,16 +640,15 @@ func (p *pipelineImpl) exporterHandler(exporter exporters.Exporter, blkChan plug | |
// WARNING: removing/re-log-levelling the following will BREAK: | ||
// - the E2E test (Search for "Pipeline round" in subslurp.py) | ||
// - the internal tools logstats collector (See func ConduitCollector in logstats.go of internal-tools repo) | ||
p.logger.Infof(logstatsE2Elog(nextRound, lastRound, len(blk.Payset), exportTime)) | ||
p.logger.Infof(logstatsE2Elog(lastRound, len(blk.Payset), exportTime)) | ||
} | ||
} | ||
}() | ||
} | ||
|
||
func logstatsE2Elog(nextRound, lastRound uint64, topLevelTxnCount int, exportTime time.Duration) string { | ||
func logstatsE2Elog(lastRound uint64, topLevelTxnCount int, exportTime time.Duration) string { | ||
return fmt.Sprintf( | ||
"UPDATED Pipeline NextRound=%d. FINISHED Pipeline round r=%d (%d txn) exported in %s", | ||
nextRound, | ||
"FINISHED Pipeline round r=%d (%d txn) exported in %s", | ||
lastRound, | ||
topLevelTxnCount, | ||
exportTime, | ||
|
@@ -696,8 +695,6 @@ func (p *pipelineImpl) Start() { | |
} | ||
} | ||
}(p.pipelineMetadata.NextRound) | ||
|
||
<-p.ctx.Done() | ||
Comment on lines
-699
to
-700
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the health endpoint bugfix. |
||
} | ||
|
||
func (p *pipelineImpl) Wait() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package noop | ||
|
||
import ( | ||
"context" | ||
_ "embed" // used to embed config | ||
"fmt" | ||
"time" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
sdk "github.com/algorand/go-algorand-sdk/v2/types" | ||
|
||
"github.com/algorand/conduit/conduit/data" | ||
"github.com/algorand/conduit/conduit/plugins" | ||
"github.com/algorand/conduit/conduit/plugins/importers" | ||
) | ||
|
||
// PluginName to use when configuring. | ||
var PluginName = "noop" | ||
|
||
const sleepForGetBlock = 100 * time.Millisecond | ||
|
||
// `noopImporter`s will function without ever erroring. This means they will also process out of order blocks | ||
// which may or may not be desirable for different use cases--it can hide errors in actual importers expecting in order | ||
// block processing. | ||
// The `noopImporter` will maintain `Round` state according to the round of the last block it processed. | ||
// It also sleeps 100 milliseconds between blocks to slow down the pipeline. | ||
type noopImporter struct { | ||
round uint64 | ||
cfg ImporterConfig | ||
} | ||
|
||
//go:embed sample.yaml | ||
var sampleConfig string | ||
|
||
var metadata = plugins.Metadata{ | ||
Name: PluginName, | ||
Description: "noop importer", | ||
Deprecated: false, | ||
SampleConfig: sampleConfig, | ||
} | ||
|
||
func (imp *noopImporter) Metadata() plugins.Metadata { | ||
return metadata | ||
} | ||
|
||
func (imp *noopImporter) Init(_ context.Context, _ data.InitProvider, cfg plugins.PluginConfig, _ *logrus.Logger) error { | ||
if err := cfg.UnmarshalConfig(&imp.cfg); err != nil { | ||
return fmt.Errorf("init failure in unmarshalConfig: %v", err) | ||
} | ||
imp.round = imp.cfg.Round | ||
return nil | ||
} | ||
|
||
func (imp *noopImporter) Close() error { | ||
return nil | ||
} | ||
|
||
func (imp *noopImporter) GetGenesis() (*sdk.Genesis, error) { | ||
return &sdk.Genesis{}, nil | ||
} | ||
|
||
func (imp *noopImporter) GetBlock(rnd uint64) (data.BlockData, error) { | ||
time.Sleep(sleepForGetBlock) | ||
imp.round = rnd | ||
return data.BlockData{ | ||
BlockHeader: sdk.BlockHeader{ | ||
Round: sdk.Round(rnd), | ||
}, | ||
}, nil | ||
} | ||
|
||
func (imp *noopImporter) Round() uint64 { | ||
return imp.round | ||
} | ||
|
||
func init() { | ||
importers.Register(PluginName, importers.ImporterConstructorFunc(func() importers.Importer { | ||
return &noopImporter{} | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package noop | ||
|
||
// ImporterConfig specific to the noop importer | ||
type ImporterConfig struct { | ||
// Optionally specify the round to start on | ||
Round uint64 `yaml:"round"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: noop | ||
# noop has no config | ||
config: | ||
tzaffi marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^^^^ !!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we probably don't need a no-input function right now -- is this+tests+above interface going to be reverted?