Skip to content

Commit c8c2710

Browse files
committed
perf(build): speed up local CLI rebuilds
1 parent 6deb1f0 commit c8c2710

12 files changed

Lines changed: 78 additions & 254 deletions

File tree

‎Cargo.lock‎

Lines changed: 1 addition & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ tokio = { version = "1.43", features = ["full"] }
1919
# gRPC/Protobuf
2020
tonic = "0.12"
2121
tonic-build = "0.12"
22+
prost-build = "0.13"
2223
prost = "0.13"
2324
prost-types = "0.13"
2425

@@ -97,7 +98,6 @@ futures = "0.3"
9798
bytes = "1"
9899
pin-project-lite = "0.2"
99100
tokio-stream = "0.1"
100-
protobuf-src = "1.1.0"
101101
url = "2"
102102

103103
# Database
@@ -149,3 +149,9 @@ strip = true
149149
[profile.dev]
150150
# Faster compile times for dev builds
151151
debug = 1
152+
153+
# Compile build scripts and proc-macros with optimizations so they run faster.
154+
# This speeds up tonic-build, clap derive, serde derive, etc. at the cost of a
155+
# one-time slower compilation of those crates.
156+
[profile.dev.build-override]
157+
opt-level = 2

‎THIRD-PARTY-NOTICES‎

Lines changed: 0 additions & 210 deletions
Original file line numberDiff line numberDiff line change
@@ -870,216 +870,6 @@ Used by:
870870
See the License for the specific language governing permissions and
871871
limitations under the License.
872872

873-
================================================================================
874-
License: Apache-2.0
875-
--------------------------------------------------------------------------------
876-
877-
Used by:
878-
- protobuf-src 1.1.0+21.5 (https://github.com/MaterializeInc/rust-protobuf-native)
879-
880-
881-
Apache License
882-
Version 2.0, January 2004
883-
http://www.apache.org/licenses/
884-
885-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
886-
887-
1. Definitions.
888-
889-
"License" shall mean the terms and conditions for use, reproduction,
890-
and distribution as defined by Sections 1 through 9 of this document.
891-
892-
"Licensor" shall mean the copyright owner or entity authorized by
893-
the copyright owner that is granting the License.
894-
895-
"Legal Entity" shall mean the union of the acting entity and all
896-
other entities that control, are controlled by, or are under common
897-
control with that entity. For the purposes of this definition,
898-
"control" means (i) the power, direct or indirect, to cause the
899-
direction or management of such entity, whether by contract or
900-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
901-
outstanding shares, or (iii) beneficial ownership of such entity.
902-
903-
"You" (or "Your") shall mean an individual or Legal Entity
904-
exercising permissions granted by this License.
905-
906-
"Source" form shall mean the preferred form for making modifications,
907-
including but not limited to software source code, documentation
908-
source, and configuration files.
909-
910-
"Object" form shall mean any form resulting from mechanical
911-
transformation or translation of a Source form, including but
912-
not limited to compiled object code, generated documentation,
913-
and conversions to other media types.
914-
915-
"Work" shall mean the work of authorship, whether in Source or
916-
Object form, made available under the License, as indicated by a
917-
copyright notice that is included in or attached to the work
918-
(an example is provided in the Appendix below).
919-
920-
"Derivative Works" shall mean any work, whether in Source or Object
921-
form, that is based on (or derived from) the Work and for which the
922-
editorial revisions, annotations, elaborations, or other modifications
923-
represent, as a whole, an original work of authorship. For the purposes
924-
of this License, Derivative Works shall not include works that remain
925-
separable from, or merely link (or bind by name) to the interfaces of,
926-
the Work and Derivative Works thereof.
927-
928-
"Contribution" shall mean any work of authorship, including
929-
the original version of the Work and any modifications or additions
930-
to that Work or Derivative Works thereof, that is intentionally
931-
submitted to Licensor for inclusion in the Work by the copyright owner
932-
or by an individual or Legal Entity authorized to submit on behalf of
933-
the copyright owner. For the purposes of this definition, "submitted"
934-
means any form of electronic, verbal, or written communication sent
935-
to the Licensor or its representatives, including but not limited to
936-
communication on electronic mailing lists, source code control systems,
937-
and issue tracking systems that are managed by, or on behalf of, the
938-
Licensor for the purpose of discussing and improving the Work, but
939-
excluding communication that is conspicuously marked or otherwise
940-
designated in writing by the copyright owner as "Not a Contribution."
941-
942-
"Contributor" shall mean Licensor and any individual or Legal Entity
943-
on behalf of whom a Contribution has been received by Licensor and
944-
subsequently incorporated within the Work.
945-
946-
2. Grant of Copyright License. Subject to the terms and conditions of
947-
this License, each Contributor hereby grants to You a perpetual,
948-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
949-
copyright license to reproduce, prepare Derivative Works of,
950-
publicly display, publicly perform, sublicense, and distribute the
951-
Work and such Derivative Works in Source or Object form.
952-
953-
3. Grant of Patent License. Subject to the terms and conditions of
954-
this License, each Contributor hereby grants to You a perpetual,
955-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
956-
(except as stated in this section) patent license to make, have made,
957-
use, offer to sell, sell, import, and otherwise transfer the Work,
958-
where such license applies only to those patent claims licensable
959-
by such Contributor that are necessarily infringed by their
960-
Contribution(s) alone or by combination of their Contribution(s)
961-
with the Work to which such Contribution(s) was submitted. If You
962-
institute patent litigation against any entity (including a
963-
cross-claim or counterclaim in a lawsuit) alleging that the Work
964-
or a Contribution incorporated within the Work constitutes direct
965-
or contributory patent infringement, then any patent licenses
966-
granted to You under this License for that Work shall terminate
967-
as of the date such litigation is filed.
968-
969-
4. Redistribution. You may reproduce and distribute copies of the
970-
Work or Derivative Works thereof in any medium, with or without
971-
modifications, and in Source or Object form, provided that You
972-
meet the following conditions:
973-
974-
(a) You must give any other recipients of the Work or
975-
Derivative Works a copy of this License; and
976-
977-
(b) You must cause any modified files to carry prominent notices
978-
stating that You changed the files; and
979-
980-
(c) You must retain, in the Source form of any Derivative Works
981-
that You distribute, all copyright, patent, trademark, and
982-
attribution notices from the Source form of the Work,
983-
excluding those notices that do not pertain to any part of
984-
the Derivative Works; and
985-
986-
(d) If the Work includes a "NOTICE" text file as part of its
987-
distribution, then any Derivative Works that You distribute must
988-
include a readable copy of the attribution notices contained
989-
within such NOTICE file, excluding those notices that do not
990-
pertain to any part of the Derivative Works, in at least one
991-
of the following places: within a NOTICE text file distributed
992-
as part of the Derivative Works; within the Source form or
993-
documentation, if provided along with the Derivative Works; or,
994-
within a display generated by the Derivative Works, if and
995-
wherever such third-party notices normally appear. The contents
996-
of the NOTICE file are for informational purposes only and
997-
do not modify the License. You may add Your own attribution
998-
notices within Derivative Works that You distribute, alongside
999-
or as an addendum to the NOTICE text from the Work, provided
1000-
that such additional attribution notices cannot be construed
1001-
as modifying the License.
1002-
1003-
You may add Your own copyright statement to Your modifications and
1004-
may provide additional or different license terms and conditions
1005-
for use, reproduction, or distribution of Your modifications, or
1006-
for any such Derivative Works as a whole, provided Your use,
1007-
reproduction, and distribution of the Work otherwise complies with
1008-
the conditions stated in this License.
1009-
1010-
5. Submission of Contributions. Unless You explicitly state otherwise,
1011-
any Contribution intentionally submitted for inclusion in the Work
1012-
by You to the Licensor shall be under the terms and conditions of
1013-
this License, without any additional terms or conditions.
1014-
Notwithstanding the above, nothing herein shall supersede or modify
1015-
the terms of any separate license agreement you may have executed
1016-
with Licensor regarding such Contributions.
1017-
1018-
6. Trademarks. This License does not grant permission to use the trade
1019-
names, trademarks, service marks, or product names of the Licensor,
1020-
except as required for reasonable and customary use in describing the
1021-
origin of the Work and reproducing the content of the NOTICE file.
1022-
1023-
7. Disclaimer of Warranty. Unless required by applicable law or
1024-
agreed to in writing, Licensor provides the Work (and each
1025-
Contributor provides its Contributions) on an "AS IS" BASIS,
1026-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1027-
implied, including, without limitation, any warranties or conditions
1028-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
1029-
PARTICULAR PURPOSE. You are solely responsible for determining the
1030-
appropriateness of using or redistributing the Work and assume any
1031-
risks associated with Your exercise of permissions under this License.
1032-
1033-
8. Limitation of Liability. In no event and under no legal theory,
1034-
whether in tort (including negligence), contract, or otherwise,
1035-
unless required by applicable law (such as deliberate and grossly
1036-
negligent acts) or agreed to in writing, shall any Contributor be
1037-
liable to You for damages, including any direct, indirect, special,
1038-
incidental, or consequential damages of any character arising as a
1039-
result of this License or out of the use or inability to use the
1040-
Work (including but not limited to damages for loss of goodwill,
1041-
work stoppage, computer failure or malfunction, or any and all
1042-
other commercial damages or losses), even if such Contributor
1043-
has been advised of the possibility of such damages.
1044-
1045-
9. Accepting Warranty or Additional Liability. While redistributing
1046-
the Work or Derivative Works thereof, You may choose to offer,
1047-
and charge a fee for, acceptance of support, warranty, indemnity,
1048-
or other liability obligations and/or rights consistent with this
1049-
License. However, in accepting such obligations, You may act only
1050-
on Your own behalf and on Your sole responsibility, not on behalf
1051-
of any other Contributor, and only if You agree to indemnify,
1052-
defend, and hold each Contributor harmless for any liability
1053-
incurred by, or claims asserted against, such Contributor by reason
1054-
of your accepting any such warranty or additional liability.
1055-
1056-
END OF TERMS AND CONDITIONS
1057-
1058-
APPENDIX: How to apply the Apache License to your work.
1059-
1060-
To apply the Apache License to your work, attach the following
1061-
boilerplate notice, with the fields enclosed by brackets "[]"
1062-
replaced with your own identifying information. (Don't include
1063-
the brackets!) The text should be enclosed in the appropriate
1064-
comment syntax for the file format. We also recommend that a
1065-
file or class name and description of purpose be included on the
1066-
same "printed page" as the copyright notice for easier
1067-
identification within third-party archives.
1068-
1069-
Copyright [2007] Neal Norwitz
1070-
Portions Copyright [2007] Google Inc.
1071-
1072-
Licensed under the Apache License, Version 2.0 (the "License");
1073-
you may not use this file except in compliance with the License.
1074-
You may obtain a copy of the License at
1075-
1076-
http://www.apache.org/licenses/LICENSE-2.0
1077-
1078-
Unless required by applicable law or agreed to in writing, software
1079-
distributed under the License is distributed on an "AS IS" BASIS,
1080-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1081-
See the License for the specific language governing permissions and
1082-
limitations under the License.
1083873

1084874
================================================================================
1085875
License: Apache-2.0

‎crates/openshell-cli/src/run.rs‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use futures::StreamExt;
1414
use http_body_util::Full;
1515
use hyper::{Request, StatusCode};
1616
use hyper_rustls::HttpsConnectorBuilder;
17-
use hyper_util::{client::legacy::Client, rt::TokioExecutor};
17+
use hyper_util::{
18+
client::legacy::Client, client::legacy::connect::HttpConnector, rt::TokioExecutor,
19+
};
1820
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
1921
use miette::{IntoDiagnostic, Result, WrapErr, miette};
2022
use openshell_bootstrap::{
@@ -1271,14 +1273,22 @@ async fn http_health_check(server: &str, tls: &TlsOptions) -> Result<Option<Stat
12711273
let uri: hyper::Uri = format!("{base}/healthz").parse().into_diagnostic()?;
12721274

12731275
let scheme = uri.scheme_str().unwrap_or("https");
1276+
if scheme.eq_ignore_ascii_case("http") {
1277+
let client: Client<HttpConnector, Full<Bytes>> =
1278+
Client::builder(TokioExecutor::new()).build_http();
1279+
let req = health_check_request(uri, tls)?;
1280+
let resp = client.request(req).await.into_diagnostic()?;
1281+
return Ok(Some(resp.status()));
1282+
}
1283+
12741284
let https = if tls.gateway_insecure && scheme.eq_ignore_ascii_case("https") {
12751285
let insecure_config = build_insecure_rustls_config()?;
12761286
HttpsConnectorBuilder::new()
12771287
.with_tls_config(insecure_config)
12781288
.https_or_http()
12791289
.enable_http1()
12801290
.build()
1281-
} else if scheme.eq_ignore_ascii_case("http") || tls.is_bearer_auth() {
1291+
} else if tls.is_bearer_auth() {
12821292
HttpsConnectorBuilder::new()
12831293
.with_native_roots()
12841294
.into_diagnostic()?
@@ -1295,18 +1305,20 @@ async fn http_health_check(server: &str, tls: &TlsOptions) -> Result<Option<Stat
12951305
.build()
12961306
};
12971307
let client: Client<_, Full<Bytes>> = Client::builder(TokioExecutor::new()).build(https);
1308+
let req = health_check_request(uri, tls)?;
1309+
let resp = client.request(req).await.into_diagnostic()?;
1310+
Ok(Some(resp.status()))
1311+
}
1312+
1313+
fn health_check_request(uri: hyper::Uri, tls: &TlsOptions) -> Result<Request<Full<Bytes>>> {
12981314
let mut req_builder = Request::builder().method("GET").uri(uri);
12991315
// Inject edge authentication headers when an edge token is configured.
13001316
if let Some(ref token) = tls.edge_token {
13011317
req_builder = req_builder
13021318
.header("Cf-Access-Jwt-Assertion", token.as_str())
13031319
.header("Cookie", format!("CF_Authorization={token}"));
13041320
}
1305-
let req = req_builder
1306-
.body(Full::new(Bytes::new()))
1307-
.into_diagnostic()?;
1308-
let resp = client.request(req).await.into_diagnostic()?;
1309-
Ok(Some(resp.status()))
1321+
req_builder.body(Full::new(Bytes::new())).into_diagnostic()
13101322
}
13111323

13121324
async fn gateway_reachable(server: &str, tls: &TlsOptions) -> bool {

‎crates/openshell-core/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dev-settings = []
2929

3030
[build-dependencies]
3131
tonic-build = { workspace = true }
32-
protobuf-src = { workspace = true }
32+
prost-build = { workspace = true }
3333

3434
[dev-dependencies]
3535
tempfile = "3"

0 commit comments

Comments
 (0)