[performance] reduce InboxForward->Create calls by partially implementing Exists() #3647
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.
Description
This adds a simple in-memory map that stores the IDs of activities that we have recently created, which allows us to partially implement Exists() and reduce the number of unnecessary calls to Create() during inbox forwarding. Unfortunately we can never return a definite answer in Exists(), since the activity JSONLD-ID doesn't necessarily match the stored object's JSONLD-ID, which is the only part that we actually store in a lot of cases. So this provides a best-effort implementation to at least reduce unnecessary calls for recently handled activities.
In the future, I don't think we should strive to "fully" implement Exists(), instead focusing on removing our reliance on the go-fed code for federation logic.
Partially handles #1891
Checklist
go fmt ./...
andgolangci-lint run
.