Developing a basic NATS application
We started learning Tuxedo by developing a TOUPPER
service first. We will do the same for NATS to compare where it is similar to Tuxedo and see what the main differences are.
Let's create a toupper.py
application with the following content:
import asyncio from nats.aio.client import Client nc = Client() async def TOUPPER(msg): await nc.publish(msg.reply, msg.data.decode().upper().encode()) async def run(loop): await nc.connect( servers=["nats://host.docker.internal:4222"], loop=loop ) await nc.subscribe("TOUPPER", cb=TOUPPER) try: msg = await nc.request( "TOUPPER", ...