Skip to content

Instantly share code, notes, and snippets.

Avatar

Waldemar Quevedo wallyqs

View GitHub Profile
View gist:8c10dbe8981d55f04198fd2dc92ac98e
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="module">
import { connect, StringCodec } from "/nats.mjs";
document.addEventListener("DOMContentLoaded", function() {
@wallyqs
wallyqs / stan-simple-ft.yaml
Last active Oct 14, 2020
Simple STAN + FT setup on AKS
View stan-simple-ft.yaml
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: stan-ssd-ft
annotations:
volume.beta.kubernetes.io/storage-class: "azurefile"
spec:
accessModes:
- ReadWriteMany
@wallyqs
wallyqs / stan-simple.yaml
Created Oct 8, 2020
STAN + AKS + Storage
View stan-simple.yaml
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: stan-disk
annotations:
volume.beta.kubernetes.io/storage-class: "managed-premium"
spec:
accessModes:
- ReadWriteOnce
@wallyqs
wallyqs / azure-stan-ft.md
Last active Oct 5, 2020
Azure File + STAN + Helm
View azure-stan-ft.md

First need to create a PVC (PersistentVolumeClaim), in Azure we can use azurefile to get a volume with ReadWriteMany:

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: stan-efs
  annotations:
View threads-asyncio.py
import asyncio
import nats
import concurrent.futures
import time
def train(msg):
print("->> Train task started...", msg.data)
time.sleep(1) # seconds
print("<<- Train task done...", msg.data)
return f"DONE: {msg.data.decode()}"
@wallyqs
wallyqs / ractor-nats.rb
Last active Sep 26, 2020
NATS + Ruby3 Ractors
View ractor-nats.rb
require 'socket'
module NATS
VERSION = '2.0.0'
class Subscription
def initialize(ractor)
@ractor = ractor
end
@wallyqs
wallyqs / nats-async-for.py
Created Sep 24, 2020
nats.py async for experiments
View nats-async-for.py
import asyncio
import nats
async def run():
nc = await nats.connect(servers=["nats://localhost:4222"])
# Using list comprehension like syntax with limited interest
sub1 = await nc.subscribe("foo")
await nc.publish("foo", b'First')
await nc.publish("foo", b'Second')
@wallyqs
wallyqs / stan-block-device.yaml
Last active Sep 10, 2020
STAN + Block Device
View stan-block-device.yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: stan-config
data:
stan.conf: |
port: 4222
http: 8222
View python-async-future.py
import asyncio
from nats.aio.client import Client as NATS
async def run(loop):
nc = NATS()
await nc.connect("nats://demo.nats.io:4222", loop=loop)
future = asyncio.Future()
async def cb(msg):
You can’t perform that action at this time.