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

grpc server scaffolding #8

Merged
merged 1 commit into from
Nov 6, 2024
Merged

grpc server scaffolding #8

merged 1 commit into from
Nov 6, 2024

Conversation

suurkivi
Copy link
Collaborator

@suurkivi suurkivi commented Nov 5, 2024

grpc server scaffolding

For now, run on port 50060 +

example:

grpcurl -plaintext -import-path src/proto -proto src/proto/rpc.proto -d '{}' 127.0.0.1:50061 rpc.SnapchainService/SubmitMessage
ERROR:
  Code: Unimplemented
  Message: not implemented

Note that if the server has an error (e.g. port already in use) it will shutdown the process by sending a signal over a channel.

Err(e) => error!(error = ?e, "{}", msg),
}

shutdown_tx.send(()).await.ok();
Copy link
Contributor

Choose a reason for hiding this comment

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

When will this be hit?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess for any reason the grpc server stops running. I'm not sure the full set of cases, but one common one is when the grpc server address/port is already in use.

@@ -138,7 +180,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}),
nonce: tick_count as u64, // Need the nonce to avoid the gossip duplicate message check
};
println!("Registering validator with nonce: {}", register_validator.nonce);
info!("Registering validator with nonce: {}", register_validator.nonce);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, I'll swap the remaining printlns with tracing in my next pr

src/server.rs Outdated
pub struct MySnapchainService;

#[tonic::async_trait]
impl SnapchainService for MySnapchainService {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should put this into network/

"src/proto/rpc.proto",
"src/proto/message.proto",
"src/proto/username_proof.proto",
], &["src/proto"])?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to autodiscover all the files, but not a priority

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a TODO

Choose a reason for hiding this comment

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

Good to see this implemented as proposed in issue 5 some days ago
#5

@suurkivi suurkivi merged commit 639bd85 into main Nov 6, 2024
@suurkivi suurkivi deleted the js/messages branch November 6, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants