Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

feat(proxy): peer branches #678

Merged
merged 20 commits into from
Jul 23, 2020
Merged

feat(proxy): peer branches #678

merged 20 commits into from
Jul 23, 2020

Conversation

FintanH
Copy link
Contributor

@FintanH FintanH commented Jul 15, 2020

Moving the revisions function into source so that it only operates over
a Browser. The peer logic gets moved to handler and the information gets
passed down.

As well as this, we extend the branches endpoint so that it can take a
PeerId if we want to look at a peer's list of branches. We test this in the revisions test.

FintanH added 2 commits July 15, 2020 16:59
Moving the revisions function into source so that it only operates over
a Browser. The peer logic gets moved to handler and the information gets
passed down.

As well as this, we extend the branches endpoint so that it can take a
PeerId if we want to look at a peer's list of branches. We test this in the revisions test.
@FintanH
Copy link
Contributor Author

FintanH commented Jul 15, 2020

I left this as a draft because I built on top of the other PR. But it's pretty much good to review.

proxy/src/http/source.rs Outdated Show resolved Hide resolved
@FintanH FintanH changed the base branch from fintan/typed-source-params to master July 16, 2020 08:39
@FintanH FintanH marked this pull request as ready for review July 16, 2020 08:39
@FintanH FintanH added this to the β1 milestone Jul 16, 2020
"project_id",
"ID of the project the blob is part of",
))
.and(warp::filters::query::query::<PeerQuery>())
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be called BranchesQuery? Since it's the query string for /branches?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ya fair 👍

proxy/src/coco/source.rs Outdated Show resolved Hide resolved
#[serde(rename_all = "camelCase")]
pub struct UserRevisions {
/// Owner of the repo.
pub(crate) identity: identity::Identity,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious - why are these only visible in the crate?

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a best practice we should be following elsewhere too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They were private, so I went one level up. I suppose since proxy is actually the only consumer of this library it could just be pub.

What's your stance on this @xla?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't really use crate visibility anywhere else at the moment. While we should be diligent about our library (i.e. the everything under the lib.rs mod tree) - we don't really have been so far. It's fair to use pub for now and clean up the lib once it has more applications than just being consumed in our very own beloved main.rs.

Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

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

Dope! Open question inside.

#[serde(rename_all = "camelCase")]
pub struct UserRevisions {
/// Owner of the repo.
pub(crate) identity: identity::Identity,
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't really use crate visibility anywhere else at the moment. While we should be diligent about our library (i.e. the everything under the lib.rs mod tree) - we don't really have been so far. It's fair to use pub for now and clean up the lib once it has more applications than just being consumed in our very own beloved main.rs.

/// Bundled response to retrieve both branches and tags for a user repo.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct UserRevisions {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any other form of Revisions? My question aims at for our domain which tries to capture the source tree exploration, we always have the dimensions of identity if I understand correctly, so could this be just named Revisions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have Revision, which is an enum over Tag, Branch or Sha. So I wouldn't say that this is multiple of those, technically. Not sure what would capture this concept better 🤷 Maybe Revisions with docs

use crate::error;
use crate::identity;
Copy link
Contributor

Choose a reason for hiding this comment

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

I highlighted this in another PR, this import shows that we haven't really figured out the direction of dependencies. At the core of our library are the protocol wrappers and they should be consumed by outer layers (identity, project, session) which ultimately is packaged in our APIs (HTTP for now). I'd like to challenge how we can make sure that identity is not imported here, maybe the concept of revisions scoped by identity doesn't belong down here in the coco machine room.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot about generics. No more modules :)

proxy/src/coco/source.rs Outdated Show resolved Hide resolved
@@ -70,7 +70,7 @@ where
.and(http::with_peer(peer))
.and(http::with_shared(registry))
.and(http::with_store(store))
.and(document::param::<String>(
.and(document::param::<coco::Urn>(
Copy link
Contributor

Choose a reason for hiding this comment

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

🖤

FintanH added 2 commits July 20, 2020 16:01
* Renamed UserRevisions to Revisions.
* Removed Identity and replaced with peer_id, user fields.
* Parameterise over P and U so that we don't import librad modules.
@FintanH
Copy link
Contributor Author

FintanH commented Jul 20, 2020

WIP Update: I parameterised but the output isn't exactly what we want for the front end. Will finish up tomorrow.

@FintanH
Copy link
Contributor Author

FintanH commented Jul 20, 2020

@xla: should have a cleaner bound of separation now. Lemme know what you think :)

Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

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

Tis dope!

🌫 🔶 🌤 🐡

proxy/src/coco/source.rs Show resolved Hide resolved
proxy/src/http/source.rs Outdated Show resolved Hide resolved
@FintanH FintanH merged commit 4aa5a05 into master Jul 23, 2020
@FintanH FintanH deleted the fintan/peer-browsing branch July 23, 2020 13:13
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.

5 participants