-
Notifications
You must be signed in to change notification settings - Fork 26
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
enhancement: plugin interface #83
Conversation
Codecov Report
@@ Coverage Diff @@
## master #83 +/- ##
==========================================
+ Coverage 67.66% 69.54% +1.88%
==========================================
Files 32 36 +4
Lines 1976 2417 +441
==========================================
+ Hits 1337 1681 +344
- Misses 570 645 +75
- Partials 69 91 +22
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
if err != nil { | ||
return fmt.Errorf("Pipeline.Init(): could not initialize importer (%s): %w", p.cfg.Importer.Name, err) | ||
} | ||
genesis, err := (*p.importer).GetGenesis() |
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.
new interface method in use
@@ -55,6 +54,7 @@ type algodImporter struct { | |||
ctx context.Context | |||
cancel context.CancelFunc | |||
mode int | |||
genesis *sdk.Genesis |
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.
Cache the genesis in the algodImporter
struct to avoid having to call the genesis endpoint after Init()
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.
Looks great!
@@ -149,7 +151,8 @@ func TestInitCatchup(t *testing.T) { | |||
targetRound sdk.Round | |||
adminToken string // to trigger fast-catchup | |||
algodServer *httptest.Server | |||
err string | |||
errInit string | |||
errGetGen string |
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.
It looks like you didn't end up using this?
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.
See for example lines 195/196. Sometimes I omitted them when they were ""
, but if that's confusing I can add these back in.
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.
It looks like 195 is also ""
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.
The latest commit adds in all zero-valued errInit
and errGetGen
:
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 mean that none of these tests define errGetGen
to anything besides an empty string, so it could be removed.
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.
Thanks for these observations. My gut was telling me that we need a failure case for full coverage and I half-baked a solution by providing errGetGen
. But both of you observed that I didn't actually finish baking the cake. Now it should be all baked: 5b114a0
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.
Nice cleaning
Re-organize Plugin Interfaces
These changes grew out a personal project to create a binary conduit plugin (or plugins) which will help me calculate taxes. As I go along and spot various opportunites for streamlining, clarifying the requirements, and docs, I'll continue putting up small[1] PR's of this kind.
Except for the last commit (see Odd Finding below), all changes are non-functional. I'm expecting to roll back the last commit, but it's worth further discussion.
Summary of Changes
.markdownlint.yml
. This isn't enforced in CI but while using the VS Code extension it helped me identify some bugs in our docs. For example, some improperly formatted list items.Plugin interface
extendingPluginMetadata
and with methodsConfig()
andClose()
inconduit/plugins/plugin.go
. These are extended by theImporter
,Processor
andExporter
interfaces instead ofPlugingMetadata
resulting in changes in:conduit/plugins/exporters/exporter.go
conduit/plugins/importers/importer.go
conduit/plugins/processors/processor.go
docs/Configuration.md
docs/GettingStarted.md
docs/tutorials/WritingBlocksToFile.md
docs/tutorials/IndexerMigration.md
genesis
value returned from newly introducedImporter.GetGenesis()
meets expectations in various unit tests.Odd Finding
Notice that all tests pass after I commented out all usages of
Config()
. Is this actually used anywhere? If not, we should consider removing it from the plugin interfaces.Upshot of Odd Finding
After a discussion, we decided to streamline the
Plugin
interface as follows:Config()
from the interfacesPluginMetadata
directly intoPlugin
interfaceInit()
toPlugin
interface and...GetGenesis()
fromImporter.Init()
[1]: It was still small at the original time that I created this PR description.