Skip to content

Instantly share code, notes, and snippets.

@bergundy
bergundy / client.js
Created May 11, 2021 07:51
grpc-js mTLS connection failure
const path = require('path');
const fs = require('fs');
const grpc = require('@grpc/grpc-js'); // No error if replaced with grpc
const Client = grpc.makeGenericClientConstructor({}, 'WorkflowService', {});
const credentials = grpc.credentials.createSsl(
fs.readFileSync(path.join(__dirname, 'certs/cluster/ca/server-intermediate-ca.pem')),
fs.readFileSync(path.join(__dirname, 'certs/client/development/client-development-namespace.key')),
fs.readFileSync(path.join(__dirname, 'certs/client/development/client-development-namespace.pem'))
@bergundy
bergundy / r-streams.md
Last active February 15, 2017 12:05
Redis streams notes and proposals

Some notes on RCP-11

  1. Support polling on multiple streams in one command to avoid having a TCP connection per stream (similar to BLPOP) Potentially, this list could be very long, e.g. a distributed chat server where each stream represents a chat log.

  2. Support compaction similar to what's done in Kafka, with the current design there's currently no way to do that AFAIK.

  3. TREAD's GROUP feature is a very simple compared to Kafka consumer groups and will suit many cases. What it doesn't guarantee that messages with the same key will be sent to the same consumer in the group. This prevents consumers from being able to run fast distributed stateful aggregations like count / groupby.

@bergundy
bergundy / stdin_byte_reader.py
Last active December 19, 2015 06:49
An example of how to use coroutines with IOStream.read and timeouts
import sys
import functools
import termios
import socket
from tornado import gen, ioloop, iostream
from datetime import timedelta
class StdinReader(object):
import motor
import toro
import time
import logging
from tornado import ioloop, gen
def sleep(seconds, io_loop = None):
io_loop = io_loop or ioloop.IOLoop.instance()
return gen.Task(io_loop.add_timeout, time.time() + seconds)
@bergundy
bergundy / echo.py
Created August 27, 2012 21:39
tornado_subprocess
import sys
while True:
l = raw_input()
sys.stdout.write(l+"\n")
sys.stdout.flush()
@bergundy
bergundy / reconnect_test.py
Created August 7, 2012 10:09
Pika reconnect test
import os
import pika
from time import sleep
from subprocess import check_call, call, check_output
from pika.spec import PORT as DEFAULT_PORT
from pika.reconnection_strategies import SimpleReconnectionStrategy
#from pika.adapters.select_connection import SelectConnection as Connection
from pika.adapters.tornado_connection import TornadoConnection as Connection
from tornado.util import b
import socket
import sys
MB = 0x100000
dlen = 5 * MB
data = b("A") * dlen + "\r\n"
port = 16661
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.netutil import TCPServer
from tornado.gen import engine, Task
from tornado.util import b
import socket
import time
import sys
import re
import itertools
import logging
from apscheduler.triggers.cron import CronTrigger
from tornado.ioloop import IOLoop
from datetime import datetime
class CronCallback(object):
"""Schedules the given callback to be called periodically.