Skip to content

Go code, scripts and utilities for the Replica project.

Notifications You must be signed in to change notification settings

getlantern/replica

Repository files navigation

See the docs at https://github.com/getlantern/replica-docs

FAQ

Search Index Roundtrippers (i.e., how your Replica search query gets fetched)

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
  • 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

  • The request gets routed to searchProxy.ServeHTTP

    • Which strips the prefix route here
    • And continues with the handling here
    • And as you see here, it uses DualSearchIndexRoundTripper to run the search query in parallel through both the primary and local search indices

About

Go code, scripts and utilities for the Replica project.

Resources

Stars

Watchers

Forks

Packages

No packages published