Disponible
amalgame-nats
Client NATS Core sur TCP brut, sans bibliothèque externe.
Vue d'ensemble
Client NATS Core écrit directement sur le protocole texte (CONNECT, PUB, SUB, MSG, PING). Aucune bibliothèque C embarquée. Il fonctionne avec nats-server, sans TLS ni authentification.
Caractéristiques
- ✓Protocole NATS Core en texte pur
- ✓Pub/sub avec sujets et wildcards (
*/>), un abonnement actif par connexion - ✓Request/reply pattern (RPC-style)
- ✓Queue groups — load balancing entre subscribers
Prévu en v3 : TLS, authentification, plusieurs abonnements par connexion.
Exemple
Exemple minimal d'utilisation — recopiable tel quel après l'install.
amc package add nats
import Amalgame.Messaging.NATS
public class Program {
public static void Main(string[] args) {
let n = NATS.Open("localhost", 4222)
if (!NATS.IsOpen(n)) {
Console.WriteLine("connect failed: " + NATS.LastError(n))
return
}
NATS.Subscribe(n, "orders.*")
NATS.Publish(n, "orders.new", "id=42")
if (NATS.WaitMessage(n, 5000)) {
Console.WriteLine(NATS.LastSubject(n) + ": " + NATS.LastPayload(n))
}
let reply: string = NATS.Request(n, "service.echo", "ping", 2000)
Console.WriteLine("reply: " + reply)
NATS.Close(n)
}
}
En bref
- Licence : Apache-2.0
- Installation :
amc package add nats - Code source : amalgame-lang/amalgame-messaging-nats
- Index officiel : amalgame-lang/packages-index