import asyncio | |
import re | |
from asyncio.streams import StreamReader, StreamWriter | |
from contextlib import closing | |
from typing import Tuple, Optional | |
import async_timeout | |
StreamPair = Tuple[StreamReader, StreamWriter] |
import json | |
import logging | |
import sys | |
logger = logging.getLogger(__name__) | |
class PyBayFormatter(logging.Formatter): | |
"""Implementation of JSON structured logging that works for most handlers.""" |
#!/usr/bin/python3.7 | |
import asyncio | |
import ipaddress | |
import re | |
import sys | |
MAX_NUMBER_WORKERS = 200 |
import time | |
from threading import Thread | |
try: | |
import socketserver as SocketServer | |
import http.server as SimpleHTTPServer | |
except ImportError: | |
import SocketServer | |
import SimpleHTTPServer |
System: Debian/Ubuntu/Fedora. Might work for others as well.
As mentioned here, to update a go version you will first need to uninstall the original version.
To uninstall, delete the /usr/local/go
directory by:
# config file | |
# vim ~/.config/fish/config.fish | |
# reload the config | |
# source ~/.config/fish/config.fish | |
# set the workspace path | |
set -x GOPATH /users/my-username/go | |
# add the go bin path to be able to execute our programs |
Redis is Database whereas RabbitMQ was designed as a message router or message-orientated-middleware (mom), so I'm sure if you look for benchmarks, you'll find that RabbitMQ will outperform Redis when it comes to message routing.
RabbitMQ is written in Erlang which was specifically designed by the telecom industry to route messages, you get clustering out of the box due to it being written in Erlang which means in a clustered environment, RabbitMQ will outperform Redis even further.
Furthermore, you get guaranteed delivery of messages due to the AMQP protocol, in other words, if the network drops while consuming the message, the consumer won't be able to say thanks for the message, so the consumer will drop the message and Rabbit will requeue the message, if you publish a message and the queue didn't say thanks to the publisher due to network problems or timeouts, Rabbit will drop the message and the publisher will keep on trying to publish the message. You can have publish retries with backoff policies, so
import asyncio | |
import time | |
def timeit(func): | |
async def process(func, *args, **params): | |
if asyncio.iscoroutinefunction(func): | |
print('this function is a coroutine: {}'.format(func.__name__)) | |
return await func(*args, **params) | |
else: |