@tremendo-studio/flyio-broadcast
v1.0.6
Published
A utility library for broadcasting messages between Fly.io app instances.
Downloads
5
Maintainers
Readme
flyio Broadcast
flyio-broadcast
is a utility library for broadcasting messages between Fly.io app instances using internal DNS resolution.
Features
- Instance Discovery: Automatically resolves the IP addresses of all instances of your Fly.io application.
- Broadcast Messaging: Sends messages to all discovered instances via HTTP.
Installation
npm install @tremendo-studio/flyio-broadcast
Usage
- Create a Broadcaster
To get started, create a broadcaster by specifying your Fly.io application name and the path where your instances will listen for broadcast messages.
import { createBroadcaster } from "@tremendo-studio/flyio-broadcast"
const broadcaster = createBroadcaster("my-app-name", "/api/sync")
- Broadcast a Message You can broadcast a message to all running instances of your application:
const result = await broadcaster.broadcast(JSON.stringify({ message: "Hello from another instance!" }))
console.log(result)
- Get All Instance IPs
const ips = await broadcaster.getIPs()
console.log(ips)