adding data-services

This commit is contained in:
Bojan Kucera 2025-06-03 07:42:48 -04:00
parent e3bfd05b90
commit 405b818c86
139 changed files with 55943 additions and 416 deletions

42
libs/event-bus/README.md Normal file
View file

@ -0,0 +1,42 @@
# Event Bus Library
A Redis-based event bus implementation for inter-service communication in the stock-bot project.
## Features
- Publish/subscribe pattern for asynchronous messaging
- Support for typed events based on `@stock-bot/shared-types`
- Reliable message delivery
- Channel-based subscriptions
## Usage
```typescript
import { createEventBus } from '@stock-bot/event-bus';
import { MarketDataEvent } from '@stock-bot/shared-types';
// Create an event bus instance
const eventBus = createEventBus({
redisHost: 'localhost',
redisPort: 6379
});
// Subscribe to market data events
eventBus.subscribe('market.data', async (event: MarketDataEvent) => {
console.log(`Received price update for ${event.data.symbol}: ${event.data.price}`);
});
// Publish an event
await eventBus.publish('market.data', {
type: 'MARKET_DATA',
data: {
symbol: 'AAPL',
price: 150.25,
bid: 150.20,
ask: 150.30,
volume: 1000000,
timestamp: new Date()
},
timestamp: new Date()
});
```