google / tarpc

An RPC framework for Rust with a focus on ease of use.
MIT License
3.09k stars 189 forks source link

Use Instant (monotonic) time instead of SystemTime #422

Closed mislavn closed 5 months ago

mislavn commented 5 months ago

This continues on the #367 pull request.

Tarpc should use relative time, especially since RPC serialization no longer uses SystemTime but Duration.

With this commit Tarpc uses Instant time and on the edges converts Instant time to SystemTime for the Opentelemetry span's.

google-cla[bot] commented 5 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

tikue commented 5 months ago

I like this, thanks! I'll review this week.

mislavn commented 5 months ago

Thanks for the quick reply!

I just want to add a bit of context. We use Tarpc to communicate with an embedded device that doesn't have an internal clock. During runtime we update the clock and that may cause RPC timeouts. This PR eliminates the issue.

I haven't added any new tests because I couldn't figure out an easy way of mocking the SystemTime for testing.

tikue commented 5 months ago

Sounds like a cool application! Out of curiosity, what are you building?

mislavn commented 5 months ago

Sounds like a cool application! Out of curiosity, what are you building?

We are building X-ray detectors. Tarpc with channels is used for communication between our "microservices" on the detector, while for the public API facing the PC we use Cap'n proto but we still use Tarpc for testing and internal tools.

tikue commented 5 months ago

There are some failures — I think there are just some missing imports for the TimeUntil trait.

image
mislavn commented 5 months ago

It should be OK now, I verified it locally.

tikue commented 5 months ago

Thanks again, I think this is a great change!