Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add /state_ids federation API #979

Merged
merged 9 commits into from Aug 4, 2016

Conversation

Projects
None yet
2 participants
Owner

erikjohnston commented Aug 3, 2016

The new API only returns the event_ids for the state, as most requesters will already have the vast majority of the events already.

Add /state_ids federation API
The new API only returns the event_ids for the state, as most
requesters will already have the vast majority of the events already.

@NegativeMjark NegativeMjark commented on the diff Aug 3, 2016

synapse/federation/federation_client.py
+ state_event_ids = result["pdus"]
+ auth_event_ids = result.get("auth_chain", [])
+
+ event_map, _failed_to_fetch = yield self.get_events(
+ [destination], room_id, set(state_event_ids + auth_event_ids)
+ )
+
+ pdus = [event_map[e_id] for e_id in state_event_ids]
+ auth_chain = [event_map[e_id] for e_id in auth_event_ids]
+
+ auth_chain.sort(key=lambda e: e.depth)
+
+ defer.returnValue((pdus, auth_chain))
+ except HttpResponseException as e:
+ if e.code == 404:
+ logger.info("Failed to use get_room_state_ids API, falling back")
@NegativeMjark

NegativeMjark Aug 3, 2016

Contributor

Are you actually falling back here? I'm not seeing any calls to transport_layer.get_room_state

@NegativeMjark NegativeMjark and 1 other commented on an outdated diff Aug 3, 2016

synapse/federation/federation_client.py
+ defer.returnValue((signed_events, failed_to_fetch))
+
+ def random_server_list():
+ srvs = list(destinations)
+ random.shuffle(srvs)
+ return srvs
+
+ batch_size = 20
+ for i in xrange(0, len(missing_events), batch_size):
+ batch = missing_events[i:i + batch_size]
+
+ deferreds = [
+ self.get_pdu(
+ destinations=random_server_list(),
+ event_id=e_id,
+ ).addBoth(lambda r, e: (r, e), e_id)
@NegativeMjark

NegativeMjark Aug 3, 2016

Contributor

Does this work as a callback for both errors and callbacks?

erikjohnston added some commits Aug 3, 2016

@erikjohnston erikjohnston referenced this pull request in matrix-org/sytest Aug 3, 2016

Merged

Test new /state_ids API #278

@NegativeMjark NegativeMjark commented on an outdated diff Aug 3, 2016

synapse/federation/federation_client.py
+ return srvs
+
+ batch_size = 20
+ for i in xrange(0, len(missing_events), batch_size):
+ batch = missing_events[i:i + batch_size]
+
+ deferreds = [
+ self.get_pdu(
+ destinations=random_server_list(),
+ event_id=e_id,
+ ).addBoth(lambda r, e: (r, e), e_id)
+ for e_id in batch
+ ]
+
+ res = yield defer.DeferredList(deferreds, consumeErrors=True)
+ for (result, val), (e_id, _) in res:
@NegativeMjark

NegativeMjark Aug 3, 2016

Contributor

Why is it (result,val), (e_id, _) here but (r, e), e_id) in the list comprehension above. What's the difference between result and val.

erikjohnston added some commits Aug 3, 2016

Contributor

NegativeMjark commented Aug 4, 2016

LGTM

erikjohnston added some commits Aug 4, 2016

@erikjohnston erikjohnston merged commit 1b5436a into develop Aug 4, 2016

10 checks passed

Flake8 + Packaging (Commit) Build #1359 origin/erikj/state_ids_api succeeded in 37 sec
Details
Flake8 + Packaging (Merged PR) Build finished.
Details
Sytest Dendron (Commit) Build #458 origin/erikj/state_ids_api succeeded in 9 min 8 sec
Details
Sytest Dendron (Merged PR) Build finished.
Details
Sytest Postgres (Commit) Build #1291 origin/erikj/state_ids_api succeeded in 6 min 32 sec
Details
Sytest Postgres (Merged PR) Build finished.
Details
Sytest SQLite (Commit) Build #1324 origin/erikj/state_ids_api succeeded in 5 min 35 sec
Details
Sytest SQLite (Merged PR) Build finished.
Details
Unit Tests (Commit) Build #1396 origin/erikj/state_ids_api succeeded in 2 min 39 sec
Details
Unit Tests (Merged PR) Build finished.
Details

@richvdh richvdh deleted the erikj/state_ids_api branch Dec 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment