Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: RUES HTTP server | RUES Domain Layer Implementation #3302

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

welf
Copy link
Contributor

@welf welf commented Dec 30, 2024

WIP: RUES Domain Layer Implementation

Summary

This PR implements the core domain layer for the RUES server, focusing on type definitions, processing pipelines with validation rules, and error handling. It follows Hexagonal Architecture principles and strict code quality guidelines.

Documentation

cd rusk and run cargo doc --open. Then navigate to http module, and then navigate to domain module.

Tests (currently, 166 tests and 177 doc tests)

run cargo test --release --features testwallet -p rusk -- http::domain --nocapture --color=always --show-output --include-ignored

Changes by Module

🔧 Core Types (domain/types/)

  • Topic - String-based topic representation
  • RuesPath - Path structure with modern/legacy support
  • RuesHeaders - Protocol headers with serialization
  • SessionId - 16-byte session identifier
  • Version - Semantic versioning support
  • IdentifierBytes - Base type for binary identifiers
  • Strong typing for:
    • Block hashes (32 bytes)
    • Transaction hashes (32 bytes)
    • Contract IDs (variable length)

🚦 Validation (domain/validation/)

  • Core validation framework

    • ValidationRule trait
    • ValidationContext with metrics
    • Rule composition support
  • Identifier validation

    • Session ID format
    • Block hash format
    • Transaction hash format
    • Contract ID format
  • Header validation

    • Content-Type validation
    • Version header validation
    • Content-Location format validation
    • Session header validation
    • Accept header validation
  • Path validation

    • Target validation
    • Topic validation
    • Path format validation

❌ Error Handling (domain/error/)

  • Rich error context
  • Error categories
    • Validation errors
    • Processing errors
    • Protocol errors
    • Resource errors
    • Conversion errors
    • Serialization errors
  • Error attributes
  • Thread-safe context

🏭 Factory (domain/factory/)

  • Construction control of types private to domain module (needed in processors and in doc tests and examples)
  • Domain type creation
  • Safe identifier creation

📝 Formats (domain/formats/)

  • Binary format handling
  • JSON format handling
  • GraphQL format handling
  • Path format handling
  • Text format handling

🔄 Processing (domain/processing/)

  • Core processing traits
  • Flow control mechanisms with rate limiting features
  • Processing metrics
  • Context handling
  • Processing pipeline (to chain multiple processors)
  • Pipeline stages

Testing Coverage

  • Identifier validation tests
  • Header validation tests
  • Version handling tests
  • Error context tests
  • Processing framework tests
  • Format handling tests
  • Pipeline tests

Documentation

  • Type documentation
  • Validation rules documentation
  • Error handling documentation
  • Processing framework documentation
  • Format handling documentation
  • Pipeline documentation

Future Work

  • Complete path validation
  • Implement format handlers
  • Complete processing pipeline
  • Add more comprehensive tests
  • Add benchmarks
  • Add more examples

Breaking Changes

None - this is a new implementation.

Dependencies Added

  • serde and serde_json for serialization
  • thiserror for error handling
  • bytes for binary data
  • parking_lot for efficient locks
  • metrics for monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant