indexserver: introduce DocumentRankVersion (#460)
This field allows us to indicate when the ranks have changed, which
forces us to re-index. We introduce DocumentRankVersion as a builder
options such that it can influence that behavior. By making a
corresponding change to Sourcegraph to set this field we will
automatically update indexes as document ranks change for a repository.
Note: We remove the document ranking feature flag from index server.
This is now completely controlled by frontend.
Note: I got started on a larger refactor here to make this more clean.
The idea is to make DocumentRanksPath a URL which is controlled by
Sourcegraph. We can then use the URL changing to indicate re-indexing
for example. For now this is a much smaller change which will unblock us
sooner.
Test Plan: Ran a local server and tested that when the ranks are missing
nothing happens. When the ranks change or are added we reindex.
Additionally when the ranks do not change it does nothing.
go install ./cmd/zoekt-git-index
go run ./cmd/zoekt-sourcegraph-indexserver \
-sourcegraph_url ~/src/github.com/sourcegraph/ \
-listen 127.0.0.1:6072
# We expect this to trigger an index
echo -e "README.md\t0.1" > ~/src/github.com/sourcegraph/zoekt/SG_DOCUMENT_RANKS
pkill -SIGUSR1 zoekt-sourcegra
# We expect this to do nothing since the ranks have not changed
pkill -SIGUSR1 zoekt-sourcegra
# We expect this to trigger a re-index
echo -e "README.md\t0.2" > ~/src/github.com/sourcegraph/zoekt/SG_DOCUMENT_RANKS
pkill -SIGUSR1 zoekt-sourcegra