Skip to content

Individual Handler Files & Advanced Error Handling #52

Description

@takker99

Problem Statement:
Complete the modularization by splitting function code handlers into individual files and implementing advanced error handling patterns for production use.

Goals:

  • Individual handler files for each function code
  • Rust-style Result type error handling throughout
  • Request queue/scheduler for RTU protocol
  • Advanced error recovery and retry mechanisms

Tasks:

Individual Handler Files

  • Create src/handlers/ directory structure
  • Implement individual files:
    • src/handlers/read-coils.ts (FC 01)
    • src/handlers/read-discrete-inputs.ts (FC 02)
    • src/handlers/read-holding-registers.ts (FC 03)
    • src/handlers/read-input-registers.ts (FC 04)
    • src/handlers/write-single-coil.ts (FC 05)
    • src/handlers/write-single-register.ts (FC 06)
    • src/handlers/write-multiple-coils.ts (FC 15)
    • src/handlers/write-multiple-registers.ts (FC 16)
  • Update frame builder/parser to use handler files
  • Implement handler registry for dynamic loading

Advanced Error Handling

  • Implement Result<T, E> type system throughout codebase
  • Replace Promise rejections with Result returns
  • Add error recovery strategies (retry, timeout, fallback)
  • Implement detailed error context (device info, timing, etc.)

Request Scheduler

  • Create src/scheduler/request-scheduler.ts
  • Implement RTU request serialization
  • Add request prioritization and queuing
  • Implement timeout and retry logic
  • Add request cancellation support

Testing & Performance

  • Add comprehensive handler tests
  • Add scheduler tests with timing verification
  • Add error handling scenario tests
  • Performance benchmarks for new architecture
  • Memory usage optimization

Acceptance Criteria:

  • All function codes have individual handler files
  • Result type system implemented without breaking changes
  • Request scheduler handles concurrent requests properly
  • Error recovery mechanisms work reliably
  • Performance is maintained or improved
  • Full test coverage for new components

Dependencies:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions