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

Development tips: getting started developing in rust on ztunnel #153

Open
howardjohn opened this issue Nov 17, 2022 · 4 comments
Open

Development tips: getting started developing in rust on ztunnel #153

howardjohn opened this issue Nov 17, 2022 · 4 comments
Labels
lifecycle/staleproof Indicates a PR or issue has been deemed to be immune from becoming stale and/or automatically closed

Comments

@howardjohn
Copy link
Member

howardjohn commented Nov 17, 2022

Since most developers on the project are new to rust, I thought it would be useful to have an issue to discuss tips for onboarding. Feel free to edit or comment.

IDEs

Intellij (or related IDEs) have a rust plugin that is pretty solid, with some tweaks:

VSCode or other LSP editors with rust-analyze is also great.

Note: due to the complexity of the language, the experience of both of these is still worse than Go unfortunately

Useful commands

cargo build # build in debug mode
cargo build --release # build in release mode - takes a while, but gives an optimized build. Do not benchmark without --release!!!
cargo check [--tests] # quickly check for compile errors
cargo clippy --fix --allow-staged --allow-dirty # find and fix (sometimes) lint errors
cargo fmt # format things

Resources

https://doc.rust-lang.org/book/ - the canonical learning rust book.

https://www.zero2prod.com/ - good real world walkthrough

https://tokio.rs/tokio/tutorial - good intro to async and tokio (library we use)

Coding style

Rust allows a wide variety of coding styles. Because most developers on the project are new-er to Rust, avoid use of complex Rust features when possible. If a function doesn't need to be generic, do not make it so. If a we can save 10nanoseconds on a infrequent codepath by using complex lifetimes - opt for a clone() instead.

Running locally

See https://github.com/istio/ztunnel/blob/master/LOCAL.md

Useful tools

https://nexte.st/ - Better test runner

@howardjohn howardjohn pinned this issue Nov 17, 2022
@ericvn
Copy link

ericvn commented Nov 18, 2022

Thanks.

@nmittler
Copy link
Contributor

nmittler commented Dec 2, 2022

@howardjohn mind adding a link to the Rust async programming book? https://rust-lang.github.io/async-book/

@kfaseela
Copy link
Member

kfaseela commented Dec 4, 2022

Thanks @howardjohn

@ericvn ericvn unpinned this issue Dec 7, 2023
@istio-policy-bot istio-policy-bot added the lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. label Dec 7, 2023
@hzxuzhonghu
Copy link
Member

no stale

@hzxuzhonghu hzxuzhonghu reopened this Dec 8, 2023
@zirain zirain added lifecycle/staleproof Indicates a PR or issue has been deemed to be immune from becoming stale and/or automatically closed and removed lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. labels Dec 8, 2023
@zirain zirain pinned this issue Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/staleproof Indicates a PR or issue has been deemed to be immune from becoming stale and/or automatically closed
Projects
Status: Done
Development

No branches or pull requests

7 participants