System Architecture
Flow
Processing a query
Fetch data from Upstreams
When performing a data fetching process, RelationService will
- Iter all available upstreams which can handle this query
- Request and collect results from each upstream available
- Newly fetched data will be fed into this circulation again, until no new data is yield.
A psuedo code snippet describing this:
up_next = [{platform: :platform_to_query, identity: "identity_to_query"}]
fetched = []
until up_next.empty? do
processing = up_next.pop()
results = fetch_one(processing)
fetched.push(processing)
results.each do |result|
next if up_next.contains?(result) || fetched.contains?(result)
up_next.push(result)
end
end
# Query all available upstream for connections of given identity.
def fetch_one(identity)
all_upstreams.map do |upstream|
upstream.can_handle?(identity) ? upstream.perform_query(identity) : []
end.flatten()
end
Actual code can be found at src/upstream/mod.rs ->
pub async fn fetch_all()
definition
So you may found a "code search" kind of slow in the first time, but when it is fetched and cached in RelationService DB, second query will become pretty fast.
See also
- GraphQL usage