Skip to content

[Rust][Server] Upgrade to tokio v1 - #11873

Merged
wing328 merged 9 commits into
OpenAPITools:masterfrom
sransara:rust-server-tokio-1
Mar 16, 2022
Merged

[Rust][Server] Upgrade to tokio v1#11873
wing328 merged 9 commits into
OpenAPITools:masterfrom
sransara:rust-server-tokio-1

Conversation

@sransara

@sransara sransara commented Mar 14, 2022

Copy link
Copy Markdown
Contributor

This PR upgrades rust-server generated code to use tokio v1.

  • tokio from 0.2 to 1.14
  • hyper from 0.13 to 0.14
  • hyper-tls from 0.4 to 0.5
  • hyper-openssl from 0.8 to 0.9
  • swagger-rs from 5.0.2 to 6.1

These upgrades are done in combination because they are cross-dependent upon each other, for example hyper depends on tokio 1.0 or higher.

This PR is a spiritual successor to (also based off the branch):

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request. @frol @farcaller @richardwhiuk @paladinzh

@sransara
sransara marked this pull request as ready for review March 14, 2022 21:17
@farcaller

Copy link
Copy Markdown
Contributor

Looks like some nice simplifications overall and version bumps are always welcome. Good stuff, thanks for your contribution!

@wing328

wing328 commented Mar 15, 2022

Copy link
Copy Markdown
Member

Thanks for the PR. i tested the change locally but got

   Compiling ops-v3 v0.0.1 (/Users/williamcheng/Code/openapi-generator/samples/server/petstore/rust-server/output/ops-v3)
error[E0412]: cannot find type `HttpsConnector` in this scope
   --> output/openapi-v3/src/server/callbacks.rs:131:57
    |
126 | type HttpConnector = hyper_tls::HttpsConnector<hyper::client::HttpConnector>;
    | ----------------------------------------------------------------------------- similarly named type alias `HttpConnector` defined here
...
131 | impl<C> Client<DropContextService<hyper::client::Client<HttpsConnector, Body>, C>, C> where
    |                                                         ^^^^^^^^^^^^^^
    |
help: a type alias with a similar name exists
    |
131 | impl<C> Client<DropContextService<hyper::client::Client<HttpConnector, Body>, C>, C> where
    |                                                         ~~~~~~~~~~~~~
help: consider importing one of these items
    |
1   | use crate::client::HttpsConnector;
    |
1   | use hyper_tls::HttpsConnector;
    |

warning: field is never read: `nullable_thing`
  --> output/rust-server-test/src/models.rs:60:13
   |
60 |             pub nullable_thing: Vec<String>,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: field is never read: `required_nullable_thing`
  --> output/rust-server-test/src/models.rs:61:13
   |
61 |             pub required_nullable_thing: Vec<String>,
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0412`.

To repeat the issue, please run mvn integration-test -f samples/server/petstore/rust-server/pom.xml.

Please take a look when you've time. Thank you.

@sransara

sransara commented Mar 16, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for taking a look. I was able to replicate and solve the issue by cross compiling for non-linux target OS. Can you please try again with the latest version?

It flew under the radar because I'm testing on a Linux machine and some packages are dependent on the OS. I was able to build by cross compiling for Windows (x86_64-pc-windows-gnu) but I'm unable to test the run executable. So any help would be appreciated.

@wing328

wing328 commented Mar 16, 2022

Copy link
Copy Markdown
Member

All tests passed locally:

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests ops-v3

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests petstore-with-fake-endpoints-models-for-testing

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests ping-bearer-auth

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests rust-server-test

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  04:28 min
[INFO] Finished at: 2022-03-16T15:27:02+08:00
[INFO] ------------------------------------------------------------------------

@wing328
wing328 merged commit 4e602b6 into OpenAPITools:master Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants