Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make services information displayed with ockam node create | show command more dynamic. #3177

Closed
mrinalwadhwa opened this issue Aug 9, 2022 · 5 comments

Comments

@mrinalwadhwa
Copy link
Member

mrinalwadhwa commented Aug 9, 2022

After #3176

ockam node create displays:

> ockam node create

Node Created!

Node:
  Name: 6d3b9f7d
  Status: Running
  Services:
    Service:
      Type: TCP Listener
      Address: /ip4/127.0.0.1/tcp/60465
    Service:
      Type: Secure Channel Listener
      Address: /service/api
      Route: /ip4/127.0.0.1/tcp/60465/service/api
      Identity: P4842f385c9934b15e1cf0a4b09be9d1dddc407cb400a2c86bc6bd0fba09aaf6f
      Authorized Identities:
        - P4842f385c9934b15e1cf0a4b09be9d1dddc407cb400a2c86bc6bd0fba09aaf6f
    Service:
      Type: Uppercase
      Address: /service/uppercase
    Service:
      Type: Echo
      Address: /service/echo

This is also displayed on node show and node list

A part of this info is currently hardcoded so various demos become more easy to understand for new users:
https://github.com/build-trust/ockam/blob/develop/implementations/rust/ockam/ockam_command/src/node/show.rs#L66-L88

and roughly maps to services started here
https://github.com/build-trust/ockam/blob/develop/implementations/rust/ockam/ockam_api/src/nodes/service.rs#L186-L215

This information would be incomplete after someone run commands like ockam secure-channel-listener create or ockam tcp-listener create.

We should make this a dynamically generated list of services.

This is also related to the ockam service subcommand that @SanjoDeundiak started developing here
https://github.com/build-trust/ockam/tree/develop/implementations/rust/ockam/ockam_command/src/service


We love helping new contributors!
If you have questions or need help as you work on your first Ockam contribution, please leave a comment on this discussion.
If you're looking for other issues to contribute to, checkout this discussion and labels - good first issue or help wanted

@mrinalwadhwa mrinalwadhwa changed the title Make node information displayed for a command more dynamic. Make node information displayed with ockam node create | show command more dynamic. Aug 10, 2022
@mrinalwadhwa mrinalwadhwa changed the title Make node information displayed with ockam node create | show command more dynamic. Make services information displayed with ockam node create | show command more dynamic. Aug 10, 2022
@lameferret
Copy link
Contributor

What does dynamic means here?
I imagine something like:

struct NodeOutput(String);

impl NodeOutput {
    fn new() -> NodeOutput {
        NodeOutput(String::new())
    }

    fn name(mut self, name: &str) -> Self {
        let name = format!("Node name: {}\n", name);
        self.0.push_str(&name);
        self
    }

    fn build(self) -> String {
        self.0
    }
}

fn main() {
    let nodeoutput = NodeOutput::new()
        .name("service one")
        .name("service two")
        .build();
    println!("{:?}", nodeoutput);
}

*memory allocations can be improved

@mrinalwadhwa
Copy link
Member Author

Thank you for looking into this.

What does dynamic means here?

I meant to say that, this list displayed here is populated from what is in the registry. So as we add new services they are all displayed. Instead of this hardcoded output.

r#"
Node:
Name: {}
Status: {}
Services:
Service:
Type: TCP Listener
Address: /ip4/127.0.0.1/tcp/{}
Service:
Type: Secure Channel Listener
Address: /service/api
Route: /ip4/127.0.0.1/tcp/{}/service/api
Identity: {}
Authorized Identities:
- {}
Service:
Type: Uppercase
Address: /service/uppercase
Service:
Type: Echo
Address: /service/echo
Secure Channel Listener Address: /service/api
"#,

Your output sketch looks good.

@lameferret
Copy link
Contributor

Alright then, I would create a PR based on the sketch in ockam_commad/util.

@lameferret
Copy link
Contributor

Hey @mrinalwadhwa, what is the scope of this issue? Should it be limited to node create | list or be a companion to #3241 's output, part and replace println! usage for output?

@mrinalwadhwa
Copy link
Member Author

@anuvratsingh I suggest we keep this issue decoupled from the bigger refactor in #3241. This one can just be about the output.

What you have in #3223 seems close enough to land. I think another interesting piece of this is getting the list of services from the node api.

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

Successfully merging a pull request may close this issue.

3 participants