You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "tisonkun (via GitHub)" <gi...@apache.org> on 2025/10/02 12:54:53 UTC
[PR] chore: bump major version [opendal-reqsign]
tisonkun opened a new pull request, #643:
URL: https://github.com/apache/opendal-reqsign/pull/643
We are now tightly coupled with `jiff`.
I don't see we can encapsulate jiff entirely. Perhaps either:
* `pub extern crate jiff as jiff02` and add a `jiff02` feature flag
* Hide jiff Timestamp behind `pub struct reqsign_core::Timestamp(jiff:Timestamp)`, and expose methods as needed, like adding a duration, parsing/print specific timestamp format, etc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3361916956
Wrapped at https://github.com/apache/opendal-reqsign/pull/643/commits/208b95fd18e0fbe3f3880ee8db7eb8ea04a67aca.
Let me try to use this wrapper in all the services tomorrow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3361302539
> For the first, that seems fine?
Yeah. This can be fine.
> Similarly for the second.
Would you prefer the way wrap a `jiff::SignedDuration` into `reqsign_core::Duration`, or add new method like `timestamp.add_duration_secs`?
That said, I noticed `jiff::Timestamp` implements `Add/Sub<UnsignedDuration>`, let me see if I can directly use std's Duration in these places.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3361217904
@BurntSushi Thanks for your feedback!
Yes I think for parsing/printing, we can encapsulate the logics behind a method of reqsign's own Timestamp.
The only two cases I hesitate to do are:
https://github.com/apache/opendal-reqsign/blob/282b5dc716af0f788c50802229652d342e97a33e/services/azure-storage/src/provide_credential/azure_cli.rs#L100-L106
[First] This is quite service-specific logic. To avoid directly depending on `jiff::civil::DateTime` and `jiff::tz::TimeZone`, perhaps I'd add a method `parse_datetime_utc`. But then this opens a hole for specific services.
https://github.com/apache/opendal-reqsign/blob/282b5dc716af0f788c50802229652d342e97a33e/services/azure-storage/src/provide_credential/client_secret.rs#L93-L94
[Second] We have several timestamp calcualtions. I wonder if we should encapsulate `jiff::SignedDuration` behind an own struct as well, or it'd be better to add new methods like `timestamp.expire_in_secs` and so on.
cc @Xuanwo
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "BurntSushi (via GitHub)" <gi...@apache.org>.
BurntSushi commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3361135775
> I don't see we can encapsulate jiff entirely
I'm not super familiar with the entire API, but is it "just" this module? https://docs.rs/reqsign/latest/reqsign/time/index.html
If so, one way to go about this is to define `DateTime` as a newtype wrapper that encapsulates its implementation. That is:
```rust
pub struct Timestamp(jiff::Timestamp);
```
And then you just expose methods on this type that provide what is needed to do conversions. So for example:
```rust
impl Timestamp {
pub fn as_secs(self) -> i64;
pub fn subsec_nanos(self) -> i32;
}
```
And you probably also want a constructor as well.
Then people using Jiff can just do the conversions manually. Similarly, people _not_ using Jiff can use these to convert to whatever timestamp type they're using.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#discussion_r2400505619
##########
services/aws-v4/src/credential.rs:
##########
@@ -54,7 +55,7 @@ impl SigningCredential for Credential {
// Take 120s as buffer to avoid edge cases.
if let Some(valid) = self
.expires_in
- .map(|v| v > now() + jiff::SignedDuration::from_mins(2))
+ .map(|v| v > Timestamp::now() + Duration::from_secs(120))
Review Comment:
Workaround https://github.com/rust-lang/rust/issues/140881 that is only stable from Rust 1.91.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "BurntSushi (via GitHub)" <gi...@apache.org>.
BurntSushi commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3361366928
Yeah, and methods like [`Timestamp::checked_add`](https://docs.rs/jiff/latest/jiff/struct.TimestampArithmetic.html) accept a `std::time::Duration` as well.
If you can live with unsigned durations, then absolutely use `std::time::Duration`. Otherwise, it's kind of dealer's choice here. Another newtype is more ceremony, and you aren't _really_ a datetime crate. Just a user of one. So I'd probably opt for an `i64` or something if you can't use `std::time::Duration`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3363803026
Ready for review.
@Xuanwo @BurntSushi welcome to give a look :D
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun commented on code in PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#discussion_r2400506310
##########
services/azure-storage/src/provide_credential/azure_pipelines.rs:
##########
@@ -233,12 +233,12 @@ impl ProvideCredential for AzurePipelinesCredentialProvider {
.await?;
// Calculate expiration time
- let expires_in = std::time::Duration::from_secs(token_response.expires_in);
- let expires_on = now().checked_add(expires_in).ok();
+ let expires_in = Duration::from_secs(token_response.expires_in);
+ let expires_on = Timestamp::now() + expires_in;
Review Comment:
We use add almost everywhere. So I'd use add first and leave whether to use add or checked_add a follow-up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "tisonkun (via GitHub)" <gi...@apache.org>.
tisonkun merged PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] chore: bump major version [opendal-reqsign]
Posted by "BurntSushi (via GitHub)" <gi...@apache.org>.
BurntSushi commented on PR #643:
URL: https://github.com/apache/opendal-reqsign/pull/643#issuecomment-3361275949
For the first, that seems fine? As in, I don't see where Jiff is being used as a public dependency there. And I don't see any Jiff-specific behavior there either. Similarly for the second.
Maybe what you're talking about is making the Jiff dependency optional or completely decoupled so that users of the crate can provide their own datetime calculations. That is certainly something you could do if you don't want to force Jiff on folks, but that's _distinct_ from having Jiff has a public dependency. If Jiff is a private dependency, then once Jiff 1.0 is released, you can update to it without needing to do your own semver compatible release. You could even switch back to Chrono at that point if you wanted to without any semver breaking changes. That is, you are decoupled from Jiff at the _API_ level.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org