Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
remove curves: these were taken care of already, add 'version' field …
Browse files Browse the repository at this point in the history
…to Runtime, send version along with prometheus
  • Loading branch information
jeromegn committed Dec 14, 2018
1 parent 7e6b39b commit a1ec77a
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 35 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion distributed-fly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ config = "0.9"
sha2 = "0.8"
bytes = "*"
prometheus = "0.4"
floating-duration = "0.1"
11 changes: 2 additions & 9 deletions distributed-fly/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ use tokio_openssl::SslAcceptorExt;
#[macro_use]
extern crate prometheus;

use floating_duration::TimeAsFloat;

mod cert;
mod metrics;
mod proxy;
Expand All @@ -70,10 +68,6 @@ lazy_static! {
.unwrap();
}

static CURVES: &str = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256";

use std::time;

fn main() {
let env = Env::default().filter_or("LOG_LEVEL", "info");
env_logger::init_from_env(env);
Expand Down Expand Up @@ -133,7 +127,6 @@ fn main() {
openssl::ssl::select_next_proto(b"\x02h2\x08http/1.1", client)
.ok_or(openssl::ssl::AlpnError::NOACK)
});
tls_builder.set_cipher_list(CURVES).unwrap();

let certs_path = {
match GLOBAL_SETTINGS.read().unwrap().certs_path {
Expand Down Expand Up @@ -175,12 +168,12 @@ fn main() {
.map_err(|e| error!("error in stream: {}", e))
.for_each(move |stream| {
let remote_addr = stream.peer_addr().unwrap();
let start = time::Instant::now();
let timer = TLS_HANDSHAKE_TIME_HISTOGRAM.start_timer();
tls_acceptor
.accept_async(stream)
.map_err(|e| error!("error handshake conn: {}", e))
.and_then(move |stream| {
TLS_HANDSHAKE_TIME_HISTOGRAM.observe(start.elapsed().as_fractional_secs());
timer.observe_duration();
let h = hyper::server::conn::Http::new();
h.serve_connection(
stream,
Expand Down
4 changes: 2 additions & 2 deletions distributed-fly/src/runtime_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ impl RuntimeSelector for DistributedRuntimeSelector {
})),
}
};
let mut rt = Runtime::new(Some(rel.app.clone()), &settings);
let mut rt = Runtime::new(Some(rel.app_id.to_string()), Some(rel.version.to_string()), &settings);
let merged_conf = rel.clone().parsed_config().unwrap();
rt.eval(
rt.eval(
"<app config>",
&format!("window.app = {{ config: {} }};", merged_conf),
);
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dns/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
.get_matches();

let entry_file = matches.value_of("input").unwrap();
let mut runtime = Runtime::new(None, &SETTINGS.read().unwrap());
let mut runtime = Runtime::new(None, None, &SETTINGS.read().unwrap());

debug!("Loading dev tools");
runtime.eval_file("v8env/dist/dev-tools.js");
Expand Down
2 changes: 1 addition & 1 deletion src/bin/eval/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
.index(1),
).get_matches();

let mut runtime = Runtime::new(None, &SETTINGS.read().unwrap());
let mut runtime = Runtime::new(None, None, &SETTINGS.read().unwrap());
debug!("Loading dev tools");
runtime.eval_file("v8env/dist/dev-tools.js");
runtime.eval("<installDevTools>", "installDevTools();");
Expand Down
2 changes: 1 addition & 1 deletion src/bin/http/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() {
info!("V8 version: {}", libfly::version());

let entry_file = matches.value_of("input").unwrap();
let mut runtime = Runtime::new(None, &SETTINGS.read().unwrap());
let mut runtime = Runtime::new(None, None, &SETTINGS.read().unwrap());

debug!("Loading dev tools");
runtime.eval_file("v8env/dist/dev-tools.js");
Expand Down
2 changes: 1 addition & 1 deletion src/bin/test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() {
let env = Env::default().filter_or("LOG_LEVEL", "info");
env_logger::init_from_env(env);

let mut rt = Runtime::new(None, &SETTINGS.read().unwrap());
let mut rt = Runtime::new(None, None, &SETTINGS.read().unwrap());
rt.eval("mocha.js", str::from_utf8(MOCHA_SOURCE).unwrap());
rt.eval("chai.js", str::from_utf8(CHAI_SOURCE).unwrap());
rt.eval("testing.js", str::from_utf8(FLY_TESTING_SOURCE).unwrap());
Expand Down
18 changes: 9 additions & 9 deletions src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn serve_http(
.status(StatusCode::SERVICE_UNAVAILABLE)
.body(Body::empty())
.unwrap(),
Some(rt.name.clone()),
Some((rt.name.clone(), rt.version.clone())),
);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ pub fn serve_http(
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
.unwrap(),
Some(rt.name.clone()),
Some((rt.name.clone(), rt.version.clone())),
);
}

Expand Down Expand Up @@ -166,31 +166,31 @@ pub fn serve_http(

Ok(Response::from_parts(parts, body))
}),
Some(rt.name.clone()),
Some((rt.name.clone(), rt.version.clone())),
)
} else {
future_response(
Response::builder()
.status(StatusCode::SERVICE_UNAVAILABLE)
.body(Body::empty())
.unwrap(),
Some(rt.name.clone()),
Some((rt.name.clone(), rt.version.clone())),
)
}
}

fn future_response(res: Response<Body>, name: Option<String>) -> BoxedResponseFuture {
wrap_future(future::ok(res), name)
fn future_response(res: Response<Body>, namever: Option<(String, String)>) -> BoxedResponseFuture {
wrap_future(future::ok(res), namever)
}

fn wrap_future<F>(fut: F, maybe_name: Option<String>) -> BoxedResponseFuture
fn wrap_future<F>(fut: F, namever: Option<(String, String)>) -> BoxedResponseFuture
where
F: Future<Item = Response<Body>, Error = futures::Canceled> + Send + 'static,
{
Box::new(fut.and_then(move |res| {
let rt_name = maybe_name.unwrap_or(String::new());
let (name, ver) = namever.unwrap_or((String::new(), String::new()));
metrics::HTTP_RESPONSE_COUNTER
.with_label_values(&[rt_name.as_str(), res.status().as_str()])
.with_label_values(&[name.as_str(), ver.as_str(), res.status().as_str()])
.inc();
Ok(res)
}))
Expand Down
4 changes: 2 additions & 2 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ lazy_static! {
pub static ref HTTP_RESPONSE_COUNTER: IntCounterVec = register_int_counter_vec!(
"fly_http_responses_total",
"Total number of HTTP responses made.",
&["runtime", "status"]
&["runtime", "version", "status"]
)
.unwrap();
pub static ref HTTP_RESPONSE_TIME_HISTOGRAM: HistogramVec = register_histogram_vec!(
"fly_http_response_time_histogram_seconds",
"HTTP response times by runtime, in seconds.",
&["runtime"],
&["runtime", "version"],
vec![0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 1.0, 5.0, 10.0, 60.0]
)
.unwrap();
Expand Down
4 changes: 3 additions & 1 deletion src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl JsRuntime {
pub struct Runtime {
pub ptr: JsRuntime,
pub name: String,
pub version: String,
pub event_loop: Mutex<current_thread::Handle>,
timers: Mutex<HashMap<u32, oneshot::Sender<()>>>,
pub responses: Mutex<HashMap<u32, oneshot::Sender<JsHttpResponse>>>,
Expand Down Expand Up @@ -197,14 +198,15 @@ fn init_event_loop() -> (
}

impl Runtime {
pub fn new(name: Option<String>, settings: &Settings) -> Box<Runtime> {
pub fn new(name: Option<String>, version: Option<String>, settings: &Settings) -> Box<Runtime> {
JSINIT.call_once(|| unsafe { js_init() });

let (rthandle, txready, rxquit) = init_event_loop();

let mut rt = Box::new(Runtime {
ptr: JsRuntime(ptr::null() as *const js_runtime),
name: name.unwrap_or("v8".to_string()),
version: version.unwrap_or(String::new()),
event_loop: Mutex::new(rthandle.clone()),
ready_ch: Some(txready),
quit_ch: Some(rxquit),
Expand Down
2 changes: 2 additions & 0 deletions v8env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@
"@types/expect": "^1.20.3",
"@types/flatbuffers": "^1.9.0",
"@types/mocha": "^5.2.5",
"@types/pako": "^1.0.0",
"@types/query-string": "^6.1.0",
"@types/source-map-support": "^0.4.1",
"@types/text-encoding": "0.0.33",
"@types/whatwg-url": "^6.4.0",
"chai": "^4.2.0",
"expect": "^23.6.0",
"mocha": "^5.2.0",
"pako": "^1.0.7",
"rollup": "^0.65.0",
"rollup-plugin-commonjs": "^9.1.6",
"rollup-plugin-node-builtins": "^2.1.2",
Expand Down
10 changes: 10 additions & 0 deletions v8env/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.11.5.tgz#6489ebda4452592d3fd37aefa57eedc01ed13378"
integrity sha512-3j1EFLfrjYRHRFjBb+RIXXwr1YGzcfpQVMP39thZa6tMY+JjVgQddPF+hsdV800JqbuLwpwAWclDpbGSAw44vQ==

"@types/pako@^1.0.0":
version "1.0.0"
resolved "https://registry.yarnpkg.com/@types/pako/-/pako-1.0.0.tgz#eaae8364d1b7f752e263bc3fd68dfec98e6136c5"
integrity sha1-6q6DZNG391LiY7w/1o3+yY5hNsU=

"@types/query-string@^6.1.0":
version "6.1.0"
resolved "https://registry.yarnpkg.com/@types/query-string/-/query-string-6.1.0.tgz#5f721f9503bdf517d474c66cf4423da5dd2d5698"
Expand Down Expand Up @@ -1173,6 +1178,11 @@ once@^1.3.0:
dependencies:
wrappy "1"

pako@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.7.tgz#2473439021b57f1516c82f58be7275ad8ef1bb27"
integrity sha512-3HNK5tW4x8o5mO8RuHZp3Ydw9icZXx0RANAOMzlMzx7LVXhMJ4mo3MOBpzyd7r/+RUu8BmndP47LXT+vzjtWcQ==

parse-asn1@^5.0.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.1.tgz#f6bf293818332bd0dab54efb16087724745e6ca8"
Expand Down

0 comments on commit a1ec77a

Please sign in to comment.