Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add groundwork for new versions of federation APIs #4390

Merged
merged 2 commits into from
Jan 21, 2019

Conversation

erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented Jan 15, 2019

This will be needed for things like MSC1794 (assuming that some form of it gets accepted)

@erikjohnston erikjohnston requested a review from a team January 15, 2019 11:22
@codecov-io
Copy link

Codecov Report

Merging #4390 into develop will decrease coverage by <.01%.
The diff coverage is 55%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4390      +/-   ##
===========================================
- Coverage    73.67%   73.66%   -0.01%     
===========================================
  Files          300      300              
  Lines        29815    29817       +2     
  Branches      4897     4897              
===========================================
- Hits         21965    21964       -1     
- Misses        6408     6412       +4     
+ Partials      1442     1441       -1
Impacted Files Coverage Δ
synapse/api/urls.py 85.18% <100%> (+0.56%) ⬆️
synapse/federation/transport/server.py 66.73% <100%> (+0.06%) ⬆️
synapse/federation/transport/client.py 69.19% <50.9%> (ø) ⬆️
synapse/storage/background_updates.py 94.4% <0%> (-1.4%) ⬇️
synapse/handlers/user_directory.py 71.08% <0%> (-0.31%) ⬇️
synapse/handlers/search.py 80.24% <0%> (ø) ⬆️
synapse/handlers/federation.py 61.72% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e41545...1a8f413. Read the comment docs.

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine. Per my comments I'm not entirely sure there is any value in having the v1 and v2 in constants rather than just treating it as part of the endpoint name, but if you'd rather leave it that's fine.

@@ -286,7 +288,7 @@ def new_func(request, *args, **kwargs):
return new_func

def register(self, server):
pattern = re.compile("^" + PREFIX + self.PATH + "$")
pattern = re.compile("^" + self.PREFIX + self.PATH + "$")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unconvinced that:

    PATH = "/invite/(?P<context>[^/]*)/(?P<event_id>[^/]*)"
    PREFIX = FEDERATION_V2_PREFIX

is clearer than

    PATH = "/v2/invite/(?P<context>[^/]*)/(?P<event_id>[^/]*)"

(in other words: although it's a ballache, would it be better to go through adding /v1 to the starts of all the PATHs?)

path (str): String template for the path
args: ([str]): Args to insert into path. Each arg will be url encoded

Returns:
str
"""
return prefix + path % tuple(urllib.parse.quote(arg, "") for arg in args)
return (
FEDERATION_V1_PREFIX
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related to my other comment: we may as well hardcode /v1 here.

@erikjohnston
Copy link
Member Author

I was vaguely copying it from how we do the CS API. Broadly, there the reason to not encode the version in the path is that some endpoints are shared across multiple versions/releases. I don't know if the same will happen to federation API, but it feels somewhat likely.

Though I guess the way that the CS API does this is to actually just have a PATHS parameter and use helper functions...

@erikjohnston
Copy link
Member Author

In the interest of moving things along, I'm going to merge this as is. I don't think the current way is particularly bad, though I do take your point about whether its worth it. Let's revisit this when we come to figuring out if we want to cut a full v2/ or r0/ style API

@erikjohnston erikjohnston merged commit 5f54765 into develop Jan 21, 2019
@richvdh
Copy link
Member

richvdh commented Jan 21, 2019

Let's revisit this when we come to figuring out if we want to cut a full v2/ or r0/ style API

I feel like I have already figured this out: we do not.

@erikjohnston erikjohnston deleted the erikj/versioned_fed_apis branch March 5, 2019 13:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants