Skip to content

Instantly share code, notes, and snippets.

@zupzup
zupzup / main.rs
Created October 29, 2020 13:29
Timeular Public API sign_in 2
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
struct SignInRequest {
api_key: String,
api_secret: String,
}
#[derive(Deserialize, Debug)]
struct SignInResponse {
token: String,
@zupzup
zupzup / main.rs
Created October 29, 2020 13:28
Timeular Public API sign_in 1
#[tokio::main]
async fn main() -> Result<(), Error> {
let api_key = env::var("TMLR_API_KEY").expect("TMLR_API_KEY needs to be set");
let api_secret = env::var("TMLR_API_SECRET").expect("TMLR_API_SECRET needs to be set");
println!("signing in..");
let token = sign_in(api_key, api_secret).await?;
@zupzup
zupzup / main.rs
Created October 29, 2020 13:22
Timeular Public API Deps and Constants
use once_cell::sync::Lazy;
use reqwest::Client;
use serde::{Deserialize, Serialize};
use std::env;
use tokio::fs;
type Error = Box<dyn std::error::Error>;
static CLIENT: Lazy<Client> = Lazy::new(|| Client::new());
@zupzup
zupzup / Cargo.toml
Created October 29, 2020 13:19
Timeular Public API Cargo.toml
[dependencies]
reqwest = { version = "0.10", features = ["json"] }
tokio = { version = "0.2", features = ["macros", "fs"] }
serde = {version = "1.0", features = ["derive"] }
serde_json = "1.0"
once_cell = "1.4"
container-juggler generate auth
image: redis:5.0.3
ports:
- "6379:6379"
auth-service:
extra_hosts:
- other-service:192.168.8.110
- other-service-db:192.168.8.110
...
@zupzup
zupzup / container-juggler.yml
Created May 26, 2020 14:15
container-juggler yml example
templateFolderPath: ./templates/
scenarios:
auth:
- redis
- auth-db
- auth-service
@zupzup
zupzup / container-juggler.yml
Created May 26, 2020 14:13
container juggler examples
templateFolderPath: ./templates/
scenarios:
auth:
- redis
- auth-db
- auth-service
@zupzup
zupzup / some_file.rs
Created March 18, 2020 14:53
some_gist
#[derive(Clone)]
pub struct JobContext {
pub db_pool: DBPool,
pub redis_pool: RedisPool,
}
pub trait Job {
fn run(&self, ctx: &JobContext) -> JobResult;
fn get_interval(&self) -> Duration;
fn get_name(&self) -> &'static str;