Skip to content

udayj/tally_client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tally Client

A WebSocket-based stock query service that connects to Tally servers to retrieve real-time inventory information.

Overview

This Rust application maintains a persistent WebSocket connection to receive stock queries, performs fuzzy matching against an items database, queries a Tally server via HTTP for stock details, and returns formatted responses.

Features

  • WebSocket Integration: Maintains persistent connection with automatic reconnection
  • Fuzzy Matching: Uses RapidFuzz for intelligent item name matching
  • Health Monitoring: Implements ping/pong heartbeat mechanism
  • Configurable: JSON-based configuration for URLs and file paths
  • Type-safe Error Handling: Custom error types with proper context

Configuration

Create a config.json file in the same directory as the executable:

{
  "websocket_url": "wss://your-websocket-server.com/ws",
  "tally_url": "http://localhost:9000",
  "items_file_path": "items.txt"
}

Configuration Fields

  • websocket_url: WebSocket server endpoint for receiving stock queries
  • tally_url: Tally server HTTP endpoint - usually a local instance of Tally Prime
  • items_file_path: Path to the items list file (defaults to items.txt)

Building

Prerequisites

  • Rust toolchain (1.89 or later)
  • Cargo package manager

Build for Current Platform

cargo build --release

The compiled binary will be in target/release/tally_client.

Cross-Compile for Windows

From Linux/macOS

  1. Install the Windows target:
rustup target add x86_64-pc-windows-gnu
  1. Install MinGW-w64 (platform-specific):

On macOS:

brew install mingw-w64

On Ubuntu/Debian:

sudo apt install mingw-w64
  1. Build for Windows:
cargo build --release --target x86_64-pc-windows-gnu

The Windows executable will be in target/x86_64-pc-windows-gnu/release/tally_client.exe.

From Windows

Simply run:

cargo build --release

The executable will be in target\release\tally_client.exe.

Deployment

Windows Deployment

  1. Copy the following files to your deployment directory:

    • tally_client.exe (from build output)
    • config.json (configured for your environment)
    • items.txt (your items database)
  2. Update config.json with your server URLs

  3. Run the executable:

tally_client.exe

Items File Format

The items.txt file should contain one item name per line:

Item Name 1
Item Name 2
Item Name 3

Protocol

Stock Request Format

The client expects JSON messages via WebSocket:

{
  "id": "unique-request-id",
  "query": "item search query"
}

Stock Response Format

{
  "id": "unique-request-id",
  "stock_info": "Formatted stock information",
  "error": null
}

Or in case of error:

{
  "id": "unique-request-id",
  "stock_info": "",
  "error": "Error description"
}

Connection Management

  • Ping Interval: 30 seconds
  • Reconnect Delay: 5 seconds after disconnect
  • HTTP Timeout: 10 seconds for Tally requests

These values are defined as constants in the code

Project Structure

tally_client/
├── src/
│   ├── main.rs           # Application entry point
│   ├── lib.rs            # Config and error types
│   ├── tally_client.rs   # Core client logic
│   ├── matcher.rs        # Fuzzy matching
│   └── parser.rs         # XML response parsing
├── templates/
│   └── stock_query.xml   # Tally XML query template
├── config.json           # Runtime configuration
├── items.txt             # Items database
└── Cargo.toml            # Dependencies

License

MIT

About

Simple Tally Client for Stock Queries

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages