Skip to content

Instantly share code, notes, and snippets.

View radzhome's full-sized avatar

Rad W radzhome

  • Ottawa
View GitHub Profile
@radzhome
radzhome / pubsub.py
Created April 16, 2019 20:13
redis pub sub
"""
Pub/sub is a pattern used in scaling software its important to understand what sort of
scaling it helps with. An important distinction is between pub/sub and message queueing.
In the queueing pattern, a queue (or list in Redis) buffers the messages to be processed while
a pool of workers pops items off the list and handles them. In this model, scaling the size of
your pool of workers scales the speed with which you process your queue, because each message
is passed to only one worker. All of the workers handle any given message in the exact same way.
In pub/sub on the other hand, the system attempts to deliver all of a channels messages to all
@radzhome
radzhome / phone.py
Created February 25, 2020 18:43
format_phone_number
import re
import logging
def phone_format(phone_number, raise_exception=False):
"""
Cleans up formatting for a phone number
format_phone_number
:param raise_exception: bool, throw an exception or return original value
:param phone_number: inputted raw phone
:return: str formatted_phone_number