Skip to content

Bidirectional event delivery client with WebSocket and Webhook transports.

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENCE.md
Notifications You must be signed in to change notification settings

edgefoundryinc/talon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@sygnl/talon

Bidirectional event delivery client with WebSocket and Webhook transports.

Install

npm install @sygnl/talon

Quick Start

WebSocket (Bidirectional)

import { TalonClient, WebSocketTransport } from '@sygnl/talon';

const talon = new TalonClient({
  transport: new WebSocketTransport('wss://edge.example.com'),
  autoConnect: true
});

// Send events TO edge
await talon.send({ event: 'purchase', order_id: '123', total: 99.99 });

// Receive updates FROM edge
talon.on('attribution_updated', (data) => {
  console.log('Attribution:', data);
});

talon.on('context_synced', (data) => {
  console.log('Context synced:', data);
});

Webhook (Fire-and-forget)

import { TalonClient, WebhookTransport } from '@sygnl/talon';

const talon = new TalonClient({
  transport: new WebhookTransport('https://edge.example.com/webhook')
});

await talon.send({ event: 'page_view', url: '/products' });

API

TalonClient

const talon = new TalonClient({
  transport: WebSocketTransport | WebhookTransport,
  autoConnect?: boolean,
  debug?: boolean
});

// Methods
await talon.connect();
await talon.disconnect();
await talon.send(event);
talon.on(eventName, handler);
talon.off(eventName, handler);
talon.isConnected(); // boolean

Transports

WebSocketTransport - Bidirectional, auto-reconnect

new WebSocketTransport(url, {
  reconnect?: boolean,
  reconnectInterval?: number,
  maxReconnectAttempts?: number
});

WebhookTransport - One-way HTTP POST

new WebhookTransport(url, {
  method?: 'POST' | 'PUT',
  retries?: number
});

Connection States

  • disconnected - Not connected
  • connecting - Connection in progress
  • connected - Ready to send/receive
  • reconnecting - Attempting to reconnect

License

Apache-2.0

About

Bidirectional event delivery client with WebSocket and Webhook transports.

Topics

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENCE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published