-
Notifications
You must be signed in to change notification settings - Fork 499
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
exp/support/pipeline: Generic Pipeline #1414
Conversation
b5ae8a6
to
97c1024
Compare
97c1024
to
3ddaa56
Compare
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 good, minor comments. A number of public methods are missing docstrings, worth a quick pass over for those.
exp/ingest/pipeline/main.go
Outdated
|
||
var _ supportPipeline.ReadCloser = &ledgerReadCloserWrapper{} | ||
|
||
// readCloserWrapperState wraps pipelinne.ReadCloser to implement StateReadCloser interface. |
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.
typo pipelinne
exp/ingest/pipeline/main.go
Outdated
|
||
var _ io.StateReadCloser = &readCloserWrapperState{} | ||
|
||
// readCloserWrapperLedger wraps pipelinne.ReadCloser to implement LedgerReadCloser interface. |
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.
typo pipelinne
exp/ingest/pipeline/main.go
Outdated
|
||
var _ io.LedgerReadCloser = &readCloserWrapperLedger{} | ||
|
||
// writeCloserWrapperState wraps pipelinne.WriteCloser to implement StateWriteCloser interface. |
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.
typo pipelinne
exp/ingest/pipeline/main.go
Outdated
|
||
var _ io.StateWriteCloser = &writeCloserWrapperState{} | ||
|
||
// writeCloserWrapperLedger wraps pipelinne.WriteCloser to implement LedgerWriteCloser interface. |
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.
typo pipelinne
"io" | ||
) | ||
|
||
const bufferSize = 50000 |
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.
worth a comment
b.readEntries++ | ||
b.readEntriesMutex.Unlock() | ||
return entry, nil | ||
} else { |
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.
could drop the else
here
// `ctx.Done()` channel and exit when it returns a value. This can happen when | ||
// pipeline execution is interrupted, ex. due to an error. | ||
// | ||
// Given all information above `ProcessLedger` should always look like 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.
This large standard pattern makes me wonder whether we could provide an interface for a custom processing object which would plug in in the right places in this pattern. Then we just execute the generic pattern with the custom user-supplied code.
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.
Good call but I'm not sure how we could change the code to support it. This comment (and all the *Wrapper
structs) are for ease of use for developers as Golang does not have a support for generics. We could use generic pipeline processor but I really want to prevent having developers to work with interface{}
type.
Let me think about it and create another PR when we have a solution.
in |
We can but it's |
This commit introduces a new `exp/support/pipeline` package that allows creating pipelines processing arbitrary objects to support two pipeline types in the ingestion system. Ingestion system will operate on two pipelines in most cases: state updates pipeline (processing history archives data) and transactions pipeline (processing ledger transactions provided by ledger backend). To support this, the existing pipeline code had to be changed to be more generic to support different reader and writer types and to prevent code duplication. We extract and update the existing pipeline code to a separate `exp/support/pipeline` package and change it to be generic. This not only allows us to create two pipeline types in `exp/ingest` but also enables developers to use it in their apps (or in other SDF apps). Additionally, a number of wrappers have been added to `exp/ingest/pipeline` to allow easier development (without type checking from `interface{}`).
PR Checklist
PR Structure
otherwise).
services/friendbot
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
Summary
Creates a new
exp/support/pipeline
package that allows creating pipelines processing arbitrary objects to support two pipeline types in the ingestion system.Close #1388.
Goal and scope
Ingestion system will operate on two pipelines in most cases: state updates pipeline (processing history archives data) and transactions pipeline (processing ledger transactions provided by ledger backend). To support this, the existing pipeline code had to be changed to be more generic to support different reader and writer types and to prevent code duplication.
Summary of changes
This commit extracts and updates the existing pipeline code to a separate
exp/support/pipeline
package and changes it to be generic. This not only allows us to create two pipeline types inexp/ingest
but also enables developers to use it in their apps (or in other SDF apps). Additionally, a number of wrappers have been addedexp/ingest/pipline
to allow easier development (without type checking frominterface{}
).Known limitations & issues
Docs of
exp/support/pipeline
should be improved with examples how to use it and how it works.What shouldn't be reviewed
All should be reviewed.