8000 GitHub - nicwaller/udp_pubsub: A publish/subscribe message bus using UDP broadcast packets
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nicwaller/udp_pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

udp_pubsub

A publish/subscribe message bus using UDP broadcast packets.

image

Why

The publish-subscribe channel is a useful design pattern, and there are great tools like Redis Pub/Sub to support it, but sometimes I just want something very lightweight.

The usual ways of designing inter-process communication (IPC) don't allow the fan-out afforded by publish-subscribe channels. Unix domain sockets and unix pipes are both designed to work with a single listener.

How

UDP broadcast is actually perfect for this. The publisher sends broadcast packets on a known port, and any process on any host of the local network broadcast segment can become a subscriber just by listening for packets on that same port.

The thing that makes this work with multiple processes on the same host is use of SO_REUSEPORT.

Usage

(pushd publisher && go build && ./publisher) &
(pushd subscriber && go build && ./subscriber)

Limitations

Broadcasting to 255.255.255.255 really does send to every machine on the local broadcast segment of the network. This behaviour may be desirable (or not) depending on your needs and your network architecture.

About

A publish/subscribe message bus using UDP broadcast packets

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0