node: Rename `tracked_repo` -> `repo_policies`
I was finding the current naming misleading, as the returned entries could be for blocked repos/nodes.
This commit is contained in:
parent
4f062ef2c6
commit
8e5627d28a
|
|
@ -18,7 +18,7 @@ fn print_repos(node: &Node) -> anyhow::Result<()> {
|
||||||
let mut t = term::Table::new(term::table::TableOptions::default());
|
let mut t = term::Table::new(term::table::TableOptions::default());
|
||||||
t.push(["RID", "Scope", "Policy"]);
|
t.push(["RID", "Scope", "Policy"]);
|
||||||
t.push(["---", "-----", "------"]);
|
t.push(["---", "-----", "------"]);
|
||||||
for tracking::Repo { id, scope, policy } in node.tracked_repos()? {
|
for tracking::Repo { id, scope, policy } in node.repo_policies()? {
|
||||||
t.push([
|
t.push([
|
||||||
term::format::highlight(id.to_string()),
|
term::format::highlight(id.to_string()),
|
||||||
term::format::secondary(scope.to_string()),
|
term::format::secondary(scope.to_string()),
|
||||||
|
|
@ -33,7 +33,7 @@ fn print_nodes(node: &Node) -> anyhow::Result<()> {
|
||||||
let mut t = term::Table::new(term::table::TableOptions::default());
|
let mut t = term::Table::new(term::table::TableOptions::default());
|
||||||
t.push(["DID", "Alias", "Policy"]);
|
t.push(["DID", "Alias", "Policy"]);
|
||||||
t.push(["---", "-----", "------"]);
|
t.push(["---", "-----", "------"]);
|
||||||
for tracking::Node { id, alias, policy } in node.tracked_nodes()? {
|
for tracking::Node { id, alias, policy } in node.node_policies()? {
|
||||||
t.push([
|
t.push([
|
||||||
term::format::highlight(Did::from(id).to_string()),
|
term::format::highlight(Did::from(id).to_string()),
|
||||||
match alias {
|
match alias {
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ fn command<H: Handle<Error = runtime::HandleError>>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandName::TrackedRepos => match handle.tracked_repos() {
|
CommandName::RepoPolicies => match handle.repo_policies() {
|
||||||
Ok(ts) => {
|
Ok(ts) => {
|
||||||
for t in ts.into_iter() {
|
for t in ts.into_iter() {
|
||||||
serde_json::to_writer(&mut writer, &t)?;
|
serde_json::to_writer(&mut writer, &t)?;
|
||||||
|
|
@ -171,7 +171,7 @@ fn command<H: Handle<Error = runtime::HandleError>>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandName::TrackedNodes => match handle.tracked_nodes() {
|
CommandName::NodePolicies => match handle.node_policies() {
|
||||||
Ok(ts) => {
|
Ok(ts) => {
|
||||||
for t in ts.into_iter() {
|
for t in ts.into_iter() {
|
||||||
serde_json::to_writer(&mut writer, &t)?;
|
serde_json::to_writer(&mut writer, &t)?;
|
||||||
|
|
|
||||||
|
|
@ -111,8 +111,8 @@ impl<G: Signer + Ecdh + 'static> radicle::node::Handle for Handle<G> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
type Routing = chan::Receiver<(Id, NodeId)>;
|
type Routing = chan::Receiver<(Id, NodeId)>;
|
||||||
type TrackedRepos = chan::Receiver<tracking::Repo>;
|
type RepoPolicies = chan::Receiver<tracking::Repo>;
|
||||||
type TrackedNodes = chan::Receiver<tracking::Node>;
|
type NodePolicies = chan::Receiver<tracking::Node>;
|
||||||
|
|
||||||
fn is_running(&self) -> bool {
|
fn is_running(&self) -> bool {
|
||||||
true
|
true
|
||||||
|
|
@ -136,10 +136,10 @@ impl<G: Signer + Ecdh + 'static> radicle::node::Handle for Handle<G> {
|
||||||
receiver.recv().map_err(Error::from)
|
receiver.recv().map_err(Error::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_repos(&self) -> Result<Self::TrackedRepos, Self::Error> {
|
fn repo_policies(&self) -> Result<Self::RepoPolicies, Self::Error> {
|
||||||
let (sender, receiver) = chan::unbounded();
|
let (sender, receiver) = chan::unbounded();
|
||||||
let query: Arc<QueryState> = Arc::new(move |state| {
|
let query: Arc<QueryState> = Arc::new(move |state| {
|
||||||
for t in state.tracked_repos()? {
|
for t in state.repo_policies()? {
|
||||||
if sender.send(t).is_err() {
|
if sender.send(t).is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -153,10 +153,10 @@ impl<G: Signer + Ecdh + 'static> radicle::node::Handle for Handle<G> {
|
||||||
Ok(receiver)
|
Ok(receiver)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_nodes(&self) -> Result<Self::TrackedNodes, Self::Error> {
|
fn node_policies(&self) -> Result<Self::NodePolicies, Self::Error> {
|
||||||
let (sender, receiver) = chan::unbounded();
|
let (sender, receiver) = chan::unbounded();
|
||||||
let query: Arc<QueryState> = Arc::new(move |state| {
|
let query: Arc<QueryState> = Arc::new(move |state| {
|
||||||
for t in state.tracked_nodes()? {
|
for t in state.node_policies()? {
|
||||||
if sender.send(t).is_err() {
|
if sender.send(t).is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1452,9 +1452,9 @@ pub trait ServiceState {
|
||||||
/// Get reference to routing table.
|
/// Get reference to routing table.
|
||||||
fn routing(&self) -> &dyn routing::Store;
|
fn routing(&self) -> &dyn routing::Store;
|
||||||
/// Get the tracked repos.
|
/// Get the tracked repos.
|
||||||
fn tracked_repos(&self) -> Result<Vec<tracking::Repo>, tracking::Error>;
|
fn repo_policies(&self) -> Result<Vec<tracking::Repo>, tracking::Error>;
|
||||||
/// Get the tracked nodes.
|
/// Get the tracked nodes.
|
||||||
fn tracked_nodes(&self) -> Result<Vec<tracking::Node>, tracking::Error>;
|
fn node_policies(&self) -> Result<Vec<tracking::Node>, tracking::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, A, S, G> ServiceState for Service<R, A, S, G>
|
impl<R, A, S, G> ServiceState for Service<R, A, S, G>
|
||||||
|
|
@ -1491,11 +1491,11 @@ where
|
||||||
&self.routing
|
&self.routing
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_repos(&self) -> Result<Vec<tracking::Repo>, tracking::Error> {
|
fn repo_policies(&self) -> Result<Vec<tracking::Repo>, tracking::Error> {
|
||||||
Ok(self.tracking.repo_entries()?.collect())
|
Ok(self.tracking.repo_entries()?.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_nodes(&self) -> Result<Vec<tracking::Node>, tracking::Error> {
|
fn node_policies(&self) -> Result<Vec<tracking::Node>, tracking::Error> {
|
||||||
Ok(self.tracking.node_entries()?.collect())
|
Ok(self.tracking.node_entries()?.collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ impl radicle::node::Handle for Handle {
|
||||||
type Error = HandleError;
|
type Error = HandleError;
|
||||||
type Sessions = service::Sessions;
|
type Sessions = service::Sessions;
|
||||||
type Routing = Vec<(Id, NodeId)>;
|
type Routing = Vec<(Id, NodeId)>;
|
||||||
type TrackedRepos = Vec<tracking::Repo>;
|
type RepoPolicies = Vec<tracking::Repo>;
|
||||||
type TrackedNodes = Vec<tracking::Node>;
|
type NodePolicies = Vec<tracking::Node>;
|
||||||
|
|
||||||
fn is_running(&self) -> bool {
|
fn is_running(&self) -> bool {
|
||||||
true
|
true
|
||||||
|
|
@ -40,7 +40,7 @@ impl radicle::node::Handle for Handle {
|
||||||
Ok(FetchResult::from(Ok::<Vec<RefUpdate>, Self::Error>(vec![])))
|
Ok(FetchResult::from(Ok::<Vec<RefUpdate>, Self::Error>(vec![])))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_repos(&self) -> Result<Self::TrackedRepos, Self::Error> {
|
fn repo_policies(&self) -> Result<Self::RepoPolicies, Self::Error> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.tracking_repos
|
.tracking_repos
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -53,7 +53,7 @@ impl radicle::node::Handle for Handle {
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_nodes(&self) -> Result<Self::TrackedNodes, Self::Error> {
|
fn node_policies(&self) -> Result<Self::NodePolicies, Self::Error> {
|
||||||
Ok(self
|
Ok(self
|
||||||
.tracking_nodes
|
.tracking_nodes
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
||||||
|
|
@ -125,14 +125,14 @@ pub enum CommandName {
|
||||||
TrackRepo,
|
TrackRepo,
|
||||||
/// Untrack the given repository.
|
/// Untrack the given repository.
|
||||||
UntrackRepo,
|
UntrackRepo,
|
||||||
/// Get the tracked repositories.
|
/// Get the repository tracking policies.
|
||||||
TrackedRepos,
|
RepoPolicies,
|
||||||
/// Track the given node.
|
/// Track the given node.
|
||||||
TrackNode,
|
TrackNode,
|
||||||
/// Untrack the given node.
|
/// Untrack the given node.
|
||||||
UntrackNode,
|
UntrackNode,
|
||||||
/// Get the tracked nodes.
|
/// Get the node tracking policies.
|
||||||
TrackedNodes,
|
NodePolicies,
|
||||||
/// Get the node's inventory.
|
/// Get the node's inventory.
|
||||||
Inventory,
|
Inventory,
|
||||||
/// Get the node's routing table.
|
/// Get the node's routing table.
|
||||||
|
|
@ -380,8 +380,8 @@ pub trait Handle {
|
||||||
type Error: std::error::Error + Send + Sync + 'static;
|
type Error: std::error::Error + Send + Sync + 'static;
|
||||||
|
|
||||||
type Routing: IntoIterator<Item = (Id, NodeId)>;
|
type Routing: IntoIterator<Item = (Id, NodeId)>;
|
||||||
type TrackedRepos: IntoIterator<Item = tracking::Repo>;
|
type RepoPolicies: IntoIterator<Item = tracking::Repo>;
|
||||||
type TrackedNodes: IntoIterator<Item = tracking::Node>;
|
type NodePolicies: IntoIterator<Item = tracking::Node>;
|
||||||
|
|
||||||
/// Check if the node is running. to a peer.
|
/// Check if the node is running. to a peer.
|
||||||
fn is_running(&self) -> bool;
|
fn is_running(&self) -> bool;
|
||||||
|
|
@ -400,10 +400,10 @@ pub trait Handle {
|
||||||
fn untrack_repo(&mut self, id: Id) -> Result<bool, Self::Error>;
|
fn untrack_repo(&mut self, id: Id) -> Result<bool, Self::Error>;
|
||||||
/// Untrack the given node.
|
/// Untrack the given node.
|
||||||
fn untrack_node(&mut self, id: NodeId) -> Result<bool, Self::Error>;
|
fn untrack_node(&mut self, id: NodeId) -> Result<bool, Self::Error>;
|
||||||
/// Get the tracking information for all tracked repos in storage.
|
/// Get the tracking information for all tracked or blocked repos in storage.
|
||||||
fn tracked_repos(&self) -> Result<Self::TrackedRepos, Self::Error>;
|
fn repo_policies(&self) -> Result<Self::RepoPolicies, Self::Error>;
|
||||||
/// Get the tracking information for all tracked nodes in storage.
|
/// Get the tracking information for all tracked or blocked nodes in storage.
|
||||||
fn tracked_nodes(&self) -> Result<Self::TrackedNodes, Self::Error>;
|
fn node_policies(&self) -> Result<Self::NodePolicies, Self::Error>;
|
||||||
/// Notify the service that a project has been updated, and announce local refs.
|
/// Notify the service that a project has been updated, and announce local refs.
|
||||||
fn announce_refs(&mut self, id: Id) -> Result<(), Self::Error>;
|
fn announce_refs(&mut self, id: Id) -> Result<(), Self::Error>;
|
||||||
/// Announce local inventory.
|
/// Announce local inventory.
|
||||||
|
|
@ -459,14 +459,14 @@ impl Node {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(finto): tracked_repos, tracked_nodes, and routing should all
|
// TODO(finto): repo_policies, node_policies, and routing should all
|
||||||
// attempt to return iterators instead of allocating vecs.
|
// attempt to return iterators instead of allocating vecs.
|
||||||
impl Handle for Node {
|
impl Handle for Node {
|
||||||
type Sessions = ();
|
type Sessions = ();
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
type TrackedRepos = Vec<tracking::Repo>;
|
type RepoPolicies = Vec<tracking::Repo>;
|
||||||
type TrackedNodes = Vec<tracking::Node>;
|
type NodePolicies = Vec<tracking::Node>;
|
||||||
type Routing = Vec<(Id, NodeId)>;
|
type Routing = Vec<(Id, NodeId)>;
|
||||||
|
|
||||||
fn is_running(&self) -> bool {
|
fn is_running(&self) -> bool {
|
||||||
|
|
@ -510,18 +510,18 @@ impl Handle for Node {
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_repos(&self) -> Result<Vec<tracking::Repo>, Self::Error> {
|
fn repo_policies(&self) -> Result<Vec<tracking::Repo>, Self::Error> {
|
||||||
let mut repos = Vec::new();
|
let mut repos = Vec::new();
|
||||||
for result in self.call::<&str, _>(CommandName::TrackedRepos, [])? {
|
for result in self.call::<&str, _>(CommandName::RepoPolicies, [])? {
|
||||||
let repo = result?;
|
let repo = result?;
|
||||||
repos.push(repo);
|
repos.push(repo);
|
||||||
}
|
}
|
||||||
Ok(repos)
|
Ok(repos)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tracked_nodes(&self) -> Result<Vec<tracking::Node>, Self::Error> {
|
fn node_policies(&self) -> Result<Vec<tracking::Node>, Self::Error> {
|
||||||
let mut repos = Vec::new();
|
let mut repos = Vec::new();
|
||||||
for result in self.call::<&str, _>(CommandName::TrackedNodes, [])? {
|
for result in self.call::<&str, _>(CommandName::NodePolicies, [])? {
|
||||||
let repo = result?;
|
let repo = result?;
|
||||||
repos.push(repo);
|
repos.push(repo);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue