This file contains 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
extern crate futures; | |
use std::io::{self, BufRead}; | |
use std::thread; | |
use futures::{Future, Sink, Stream}; | |
use futures::stream::BoxStream; | |
use futures::sync::mpsc::channel; | |
fn stdin() -> impl Stream<String, io::Error> { |
This file contains 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 gitlab::webhooks::WebHook; | |
use hyper::service::{make_service_fn, service_fn}; | |
use hyper::{Body, Request, Response, Server}; | |
use log::{log_enabled, Level}; | |
async fn gitlab_webhook(req: Request<Body>) -> Result<Response<Body>, hyper::Error> { | |
log::debug!("< {:?}", req); | |
let body = hyper::body::to_bytes(req.into_body()).await?; | |
let event: Result<WebHook, _> = serde_json::from_slice(&body); | |
match event { |
This file contains 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::cmp::Reverse; | |
use std::collections::HashMap; | |
use std::fs::File; | |
use std::io::BufRead; | |
use std::io::BufReader; | |
use walkdir::WalkDir; | |
fn get_version(entry: walkdir::Result<walkdir::DirEntry>) -> Option<String> { | |
let entry = entry.ok()?; | |
let path = entry.path(); |
This file contains 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 actix::prelude::*; | |
use actix_web::{middleware, web, App, HttpResponse, HttpServer}; | |
use log::info; | |
use std::io; | |
use std::thread; | |
use std::time::Duration; | |
fn my_handler() -> HttpResponse { | |
"Hello".into() |
This file contains 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 some_test -> Result<(), Error> { | |
let mut rt = tokio::runtime::Runtime::new().unwrap(); | |
rt.spawn(microservice_1.map_err(|e| panic!(e))); | |
rt.spawn(microservice_2.map_err(|e| panic!(e))); | |
rt.spawn(microservice_3.map_err(|e| panic!(e))); | |
rt.spawn(microservice_4.map_err(|e| panic!(e))); | |
// do testing and do not touch rt anymore | |
} |
This file contains 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
#[macro_use] | |
extern crate nom; | |
use nom::alpha; | |
use nom::types::CompleteStr; | |
use nom::ErrorKind; | |
named!(block<CompleteStr, Vec<(CompleteStr, CompleteStr)>>, | |
do_parse!( | |
tag!("BEGIN") >> |
This file contains 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
[package] | |
name = "ratelimiting-server" | |
version = "0.1.0" | |
[dependencies] | |
futures = "0.1" | |
tokio = "0.1" | |
hyper = "0.12" |
This file contains 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
module Cli where | |
port output : String | |
port output = | |
"Sub-orbital table 8-bit realism boat soul-delay face forwards industrial | |
grade drone. Cartel towards footage tube assault table woman stimulate bridge | |
claymore mine semiotics human. Post-construct j-pop military-grade stimulate | |
narrative realism. Shoes convenience store sunglasses realism numinous tanto | |
long-chain hydrocarbons. Franchise tower render-farm girl wonton soup sprawl | |
fetishism Kowloon advert semiotics shoes dolphin drugs otaku marketing. |
This file contains 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
#![allow(dead_code)] | |
extern crate futures; | |
extern crate time; | |
use futures::prelude::*; | |
use futures::sync::mpsc::{channel, Receiver}; | |
use time::{Tm, now_utc}; | |
use std::{thread}; |
This file contains 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 Client { | |
pub fn connect( | |
handle: &Handle, | |
uri: hyper::Uri, | |
framework_info: mesos::FrameworkInfo, | |
) -> Box<Future<Item = Self, Error = failure::Error>> { | |
// Mesos subscribe essage | |
let mut call = scheduler::Call::new(); | |
let mut subscribe = scheduler::Call_Subscribe::new(); | |
subscribe.set_framework_info(framework_info); |
NewerOlder