Skip to content

Instantly share code, notes, and snippets.

View davidbarsky's full-sized avatar

David Barsky davidbarsky

View GitHub Profile
struct Ctx;
trait Handler: 'static + Send + Sync {
fn call<'a>(&'a self, s: String) -> Result<String, Err>;
}
impl<F> Handler for F
where
F: Send + Sync + 'static + for<'a> Fn(String) -> Result<String, Err>,
{
use lamdba::{S3WriteEvent, Context};
use aws::{S3, DynamoDB};
use serde::from_json;
type Err = Box<dyn std::error::Error + Send + Sync>;
#[lambda::main]
async fn main(event: S3WriteEvent, ctx: Context) -> Result<(), Err> {
let path = event.path();
let paths: Stream<String> = S3.get_object(path).await?;
/// `S3Request` is a trait that encodes:
/// - serialization mechanism (XML, JSON)
/// - routing (does this service even have a URI-based path), or can we just
/// - `POST` to an endpoint? (example: DynamoDB versus S3).
trait S3Resource {
type Response;
}
struct GetObjectRequest {
// ...
---- [ui] ui/associated-types/associated-types-overridden-binding-2.rs stdout ----
error: Error: expected failure status (Some(1)) but received status Some(101).
status: exit code: 101
command: "/home/ec2-user/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/home/ec2-user/rust/src/test/ui/associated-types/associated-types-overridden-binding-2.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/home/ec2-user/rust/build/x86_64-unknown-linux-gnu/test/ui/associated-types/associated-types-overridden-binding-2/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/home/ec2-user/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/ec2-user/rust/build/x86_64-unknown-linux-gnu/test/ui/associated-types/associated-types-overridden-binding-2/auxiliary" "-A" "unused"
stdout:
------------------------------------------
------------------------------------------
stderr:
export class S3Resources extends Construct {
constructor(parent: Construct, id: string, removalPolicy: RemovalPolicy) {
super(parent, id);
const bucket = new Bucket(this, "Bucket", {
versioned: true,
removalPolicy
});
new ssm.CfnParameter(this, "BucketName", {
error[E0277]: the trait bound `client_ext::HttpClient: tower_service::Service<http::request::Request<hyper::body::body::Body>>` is not satisfied
--> lambda-runtime-client-simple/src/client_ext.rs:85:15
|
85 | let svc = Retry::new(RetryGets, client);
| ^^^^^^^^^^ the trait `tower_service::Service<http::request::Request<hyper::body::body::Body>>` is not implemented for `client_ext::HttpClient`
|
= note: required by `<tower_retry::Retry<P, S>>::new`
use failure::{Error, Fail};
use http::{header::HeaderValue, HeaderMap, Method, Request};
use serde_derive::{Deserialize, Serialize};
use serde_json;
use warp::{self, path, Filter, Rejection};
#[derive(Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "camelCase")]
struct LambdaError {
error_message: String,
@davidbarsky
davidbarsky / init.vim
Created November 2, 2018 02:47
my vimrc
filetype plugin on
filetype indent on
set ruler
set number
set hidden
set clipboard=unnamedplus
syntax on
set wrap linebreak nolist
call plug#begin('~/.local/share/nvim/plugged')
import sys
import re
from timeit import default_timer as timer
if len(sys.argv) != 2:
print('Usage: python benchmark.py <filename>')
sys.exit(1)
def measure(data, pattern):
Request-scoped,
aggregatable events. Subscribers
┌────────────┐ ┌───────────────────┐
│ ┌────────┐ │ │ ┌───────────────┐ │
│ │ Span │ │───┐ Global Queue Supervisor ┌───▶│ │ Prometheus │ │
│ └────────┘ │ │ ┌──────────────┐ ┌──────────────────────────────┐ │ │ └───────────────┘ │
│ ┌────────┐ │ │ │ Insert self │ │ Pop span from queue, │ │ │ ┌───────────────┐ │
│ │ Span │ │───┼──▶│into queue on ├───────▶│publishing/cloning the span to├───┼───▶│ │ stdout │ │
│ └────────┘ │ │ │ drop. │ │ each registered subscriber. │ │ │ └───────────────┘ │
│ ┌────────┐ │ │ └──────────────┘ └──────────────────────────────┘ │ │ ┌───────────────┐ │