See the docs at https://github.com/getlantern/replica-docs
Replica on the client-side (desktop, Android, etc.) uses two search indices:
- Either a replica-rust instance somewhere remote (e.g., the one at https://replica-search-aws.lantern.io. See here for a complete breakdown).
- We'll call this the
primary
search index
- We'll call this the
- Or, a local "backup" instance living on the user's device, fetched from the DHT
- See here for more info
- We'll call this the
local
search index
When a search query occurs, ./server/dualsearchroundtripper.go:DualSearchIndexRoundTripper
(which implements http.RoundTripper
) runs the same request in parallel on both indices (i.e., it multipaths the request) and favours always the primary
index (for fresher results). See that file for more info.
To be clear, here's the full search code flow:
-
./server/server.go:NewHTTPHandler()
creates a new local HTTP server.- Clients like lantern-android and lantern-desktop will create this so that the UI can talk to Go code through HTTP
-
A client runs a request like
http://localhost:whateverport/search?s=bunnyfoofoo
- Through the
/search
route in NewHTTPHandler - which gets handled here in handleSearch
- Through the
-
The request gets routed to searchProxy.ServeHTTP