This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
static METRICS_INIT: metrics::OnceIdentifier = metrics::OnceIdentifier::new(); | |
if let Some(recorder) = metrics::try_recorder() { | |
let id = METRICS_INIT.get_or_init(|| { | |
recorder.register_histogram( | |
{ | |
format!("{}.{}", std::module_path!(), "service.execution_time") | |
} | |
.into(), | |
None, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn poll_write( | |
self: Pin<&mut Self>, | |
cx: &mut Context, | |
buf: &[u8] | |
) -> Poll<io::Result<usize>> { | |
let me = self.project(); | |
// encrypt our input buffer | |
let mut ebuf = if let Some(wbuf) = me.remaining.take() { | |
// we had a leftover buffer, so extend it from our current input, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
impl<S: AsyncRead + Unpin> AsyncRead for Decryption<S> { | |
fn poll_read( | |
self: Pin<&mut Self>, | |
cx: &mut Context, | |
buf: &mut [u8] | |
) -> Poll<io::Result<usize>> { | |
let this = self.project(); | |
let n = match this.stream.poll_read(cx, buf) { | |
Poll::Pending => return Poll::Pending, | |
Poll::Ready(res) => res?, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// current best approach i can think of (doesn't optimize for static labels): | |
struct Metadata<'a> { | |
fields: &'static [&'static str], | |
// not even sure if this works with items having same lifetime as the list? whatever | |
values: &'a [&'a str], | |
} | |
fn with_runtime_labels() { | |
// this is some label value, gathered at runtime, of type &'a str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn handle_logfilter<S>(handle: Handle<EnvFilter, S>) | |
-> impl Filter<Extract = impl Reply, Error = Rejection> + Clone | |
where | |
S: Subscriber, | |
{ | |
let handle = warp::any().map(move || handle.clone()); | |
warp::path("logfilter") | |
.and(warp::post()) | |
.and( | |
warp::body::bytes().and_then(|body: Bytes| async move { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax = "proto3"; | |
package grpc.pettycache.cache; | |
message GetSingleKeyRequest { | |
bytes key = 1; | |
} | |
message GetSingleKeyResponse { | |
bytes key = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using tokio ^0.1 and metrics-exporter-http ^0.2 | |
std::thread::spawn(move || { | |
tokio::runtime::current_thread::block_on_all(exporter.into_future()); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::Arc; | |
use futures_intrusive::sync::ManualResetEvent; | |
use crate::wg::{WaitGroup, WaitGroupHandle}; | |
pub struct Context { | |
start: WaitGroup, | |
done: WaitGroup, | |
close: Arc<ManualResetEvent>, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn parse_redis_value_async<R>(reader: &mut R) -> RedisResult<Value> | |
where | |
R: AsyncBufRead + Unpin, | |
{ | |
let mut state = AnySendPartialState::default(); | |
let mut pending_data = false; | |
let mut buffered = Vec::new(); | |
loop { | |
// Figure out the view into our "current" buffer. We can track of data returned by the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Parses a redis value asynchronously. | |
pub async fn parse_redis_value_async<R>(reader: &mut R) -> RedisResult<Value> | |
where | |
R: AsyncBufRead, | |
{ | |
let mut state = AnySendPartialState::default(); | |
let mut pending_data = false; | |
let mut buffered = Vec::new(); |