-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Off-chain] feat: observable utils #171
Merged
Merged
Conversation
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
bryanchriswhite
added
miner
Changes related to the Miner
off-chain
Off-chain business logic
labels
Nov 9, 2023
red-0ne
reviewed
Nov 9, 2023
bryanchriswhite
commented
Nov 9, 2023
red-0ne
approved these changes
Nov 9, 2023
Olshansk
approved these changes
Nov 9, 2023
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.
Couple comments but very nice and clean!
return value, true | ||
} | ||
return value, false | ||
} |
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.
Great comments, naming, design, and everything across the board
…utils * issues/13/refactor/map: fix: `MapReplay` usages post-refactor chore: review feedback improvement
…le-utils * pokt/main: [Off-chain] refactor: `MapFn`s receive context arg (#170)
okdas
pushed a commit
that referenced
this pull request
Nov 14, 2024
* refactor: `MapFn`s receive context arg * chore: add `ForEach` map shorthand operator * chore: add `/pkg/observable/filter` * chore: add `/pkg/observable/logging` * chore: add godoc comments * chore: review feedback improvement * fix: `MapReplay` usages post-refactor * chore: review feedback improvements
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds:
ForEach()
calls the given function for each notification (likeMap()
without an destination)EitherError()
filters out only eithers with error populated and maps the error to the destinationEitherSuccess()
filters out only eithers with value populated and maps the value to the destinationLogErrors()
logs notifications from the given error observableHuman Summary
AI Summary
Summary generated by Reviewpad on 09 Nov 23 19:54 UTC
This pull request includes three changes:
Added a new file
pkg/observable/filter/either.go
, which provides functions for filtering and mapping an observable of an either type. It includes functionsEitherError
andEitherSuccess
for filtering eithers based on whether they are populated with errors or values, respectively.Added a new file
pkg/observable/logging/logging.go
, which includes functions for logging errors received from an observable. TheLogErrors
function logs all errors received from the observable.Modified the existing file
pkg/observable/channel/map.go
to include a new typeForEachFn
and a new functionForEach
. TheForEach
function applies the givenforEachFn
to each notification received from the observable, similar toMap
, but without publishing to a destination observable. It is useful for side effects and is a terminal observable operator.Issue
[Explain the reasoning for the PR in 1-2 sentences. Consider adding a link or a screenshot.]
Type of change
Select one or more:
Testing
make go_develop_and_test
Sanity Checklist