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
def test_section_a_resilient_to_data_store_b_being_down | |
Toxiproxy[:data_store_b].down do | |
get '/section_a' | |
assert_response :success | |
end | |
end |
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
def load_customer | |
if customer_id = session[:customer_id] | |
@customer = Customer.find_by_id(customer_id) | |
end | |
end |
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
def test_storefront_resilient_to_sessions_down | |
Toxiproxy[:sessions_data_store].down do | |
get '/' | |
assert_equal 'Customer sign in is currently unavailable', flash[:notice] | |
assert_response :success | |
end | |
end |
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
def load_customer | |
if customer_id = session[:customer_id] | |
@customer = Customer.find_by_id(session[:customer_id]) | |
end | |
# in reality e.g. a redis exception thrown from the driver | |
# could be raised from circuit breaker or semian as well (see later) | |
rescue Sessions::DataStoreUnavailable | |
flash[:notice] = 'Customer sign in is currently unavailable' | |
@customer = nil | |
end |
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
WORKDIR="/home/vagrant/src" | |
clone_repo() { | |
local name=$1; shift | |
local repo=$1; shift | |
if [[ ! -d "$WORKDIR/$name" ]]; then |
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
class Book < Airrecord::Table | |
class Endorser < Airrecord::Table | |
self.base_key = "" | |
self.table_name = "Endorser" | |
end | |
self.base_key = "" | |
self.table_name = "Books" | |
has_many :endorsements, class: 'Book::Endorser', column: 'Endorsements' |
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
# frozen_string_literal: true | |
# By default, ActiveRecord will issue a PING command to the database to check | |
# if it is active at various points. This overhead is unnecessary; we instead | |
# attempt to issue queries without checking the connection, then if the query | |
# returns an error and the connection was closed, try to reconnect. | |
# This also allows for reconnection during a single UoW, improving resiliency | |
# under transient connection failure (e.g. ProxySQL restarts). | |
# | |
# To avoid amplifying load when a database is intermittently down, the attempt |
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::{fs::OpenOptions, io::Result}; | |
use std::io::{Read, Write, Seek, SeekFrom}; | |
use std::slice; | |
use std::time::Instant; | |
const BUF_SIZE: usize = 1024 * 32; | |
const FILE_SIZE: usize = 1024 * 1024 * 512; | |
const QUEUE_DEPTH: usize = 32; | |
fn main() -> Result<()> { |
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::io::{Read, Seek, SeekFrom, Write}; | |
use std::slice; | |
use std::time::Instant; | |
use std::{fs::OpenOptions, io::Result}; | |
use std::ptr; | |
use std::mem::forget; | |
const BUF_SIZE: usize = 1024 * 32; | |
const FILE_SIZE: usize = 1024 * 1024 * 512; | |
const QUEUE_DEPTH: usize = 32; |
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
require "sqlite3" | |
require 'set' | |
require 'byebug' | |
# Will be rebuilt at any time. Nice and incremental. | |
db = SQLite3::Database.new "index.db" | |
# Keep prefix indexes for "mos*" searches. | |
# | |
# TODO: It doesn't seem like SQLITE FTS5 supports synonyms well. That's ok, but | |
# we're going to want that. We can download this database from Princeton, write |