-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
WIP: ADR 073: Built-in Indexer Implementation #20547
Conversation
Important Review skippedAuto reviews are limited to specific labels. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
buf := new(strings.Builder) | ||
var params []interface{} | ||
if exists { | ||
params, err = tm.UpdateSql(buf, key, value) |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
if exists { | ||
params, err = tm.UpdateSql(buf, key, value) | ||
} else { | ||
params, err = tm.InsertSql(buf, key, value) |
Check warning
Code scanning / CodeQL
Useless assignment to local variable Warning
if err != nil { | ||
return err | ||
} | ||
case schema.Bech32AddressKind: |
Check warning
Code scanning / CodeQL
Directly using the bech32 constants Warning
for indexerName, factory := range indexerRegistry { | ||
indexerOpts, ok := opts.Options[indexerName] | ||
if !ok { | ||
continue | ||
} | ||
|
||
if opts.Logger != nil { | ||
opts.Logger.Info(fmt.Sprintf("Starting Indexer %s", indexerName), "options", indexerOpts) | ||
} | ||
|
||
optsMap, ok := indexerOpts.(map[string]interface{}) | ||
if !ok { | ||
return appdata.Listener{}, fmt.Errorf("invalid indexer options type %T for %s, expected a map", indexerOpts, indexerName) | ||
} | ||
|
||
indexer, err := factory(optsMap, resources) | ||
if err != nil { | ||
return appdata.Listener{}, fmt.Errorf("failed to create indexer %s: %w", indexerName, err) | ||
} | ||
|
||
res, err := indexer.Initialize(ctx, InitializationData{}) | ||
if err != nil { | ||
return appdata.Listener{}, fmt.Errorf("failed to initialize indexer %s: %w", indexerName, err) | ||
} | ||
|
||
indexers = append(indexers, res.Listener) | ||
|
||
// TODO handle last block persisted | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map Warning
go func() { | ||
<-ctx.Done() | ||
err := i.db.Close() | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to close database: %v", err)) | ||
} | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
go func() { | ||
var err error | ||
for { | ||
select { | ||
case packet := <-packetChan: | ||
if err != nil { | ||
// if we have an error, don't process any more packets | ||
// and return the error and finish when it's time to commit | ||
if _, ok := packet.(CommitData); ok { | ||
commitChan <- err | ||
return | ||
} | ||
} else { | ||
// process the packet | ||
err = listener.SendPacket(packet) | ||
// if it's a commit | ||
if _, ok := packet.(CommitData); ok { | ||
commitChan <- err | ||
if err != nil { | ||
return | ||
} | ||
} | ||
} | ||
|
||
case <-doneChan: | ||
return | ||
} | ||
} | ||
}() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
This PR will stay in draft and includes the WIP implementation of #20532 so that people can take a look if they're interested. Once specific pieces are ready, they'll be broken out into smaller standalone PRs.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...