Project

thronglets

0.0
No release in over 3 years
Microservices with Ruby and Temporal
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Thronglets

Gem Version Gem Downloads GitHub Workflow Status Maintainability


  • Why Use Thronglets?
  • Use Cases
  • Overview
  • Key Features
  • Installation
  • Directory Structure
  • Core Components
    • Workflows
    • Activities
    • Command Line Interface
  • Input/Output Validation
  • Development Mode
  • Error Handling
  • Best Practices
  • Support
  • License
  • Code of conduct
  • Contribution guide

Why Use Thronglets?

Decoupling a monolith is complex and risky without the right tools. Thronglets gives you insight into your codebase, helps you plan a phased decomposition strategy, and reduces the cognitive and operational overhead of large-scale refactoring efforts.

Use Cases

  • Legacy systems modernization
  • Microservice migration strategies
  • Technical debt management
  • Domain-driven design alignment

Overview

Thronglets is an open-source Ruby toolkit designed to help engineering teams modernize and decompose monolithic applications into modular, scalable services. Built on top of Temporal, it provides a structured approach to breaking down legacy Ruby applications, with a particular focus on Ruby on Rails monoliths.

Key Features

  1. Workflow Management

    • Built-in workflow orchestration using Temporal
    • Support for long-running processes
    • Automatic workflow registration and management
  2. Activity Management

    • Structured activity definitions
    • Input/Output validation
    • Automatic activity registration
  3. Code Organization

    • Conventional directory structure
    • Automatic code loading with Zeitwerk
    • Hot-reloading capabilities

Installation

gem 'thronglets'

Or install via command line:

gem install thronglets

Requirements:

  • Ruby >= 3.2
  • Temporal server running

Directory Structure

Thronglets expects the following directory structure:

app/
├── activities/     # Activity definitions
├── actors/        # Actor classes
├── workflows/     # Workflow definitions
├── models/        # Domain models
└── models/concerns/  # Shared concerns

Core Components

1. Workflows

Workflows are the core orchestration units in Thronglets. They inherit from Thronglets::Workflow:

class MyWorkflow < Thronglets::Workflow
  input do
    # Define input schema using dry-schema
  end

  output do
    # Define output schema using dry-schema
  end

  def call
    # Implement workflow logic
  end
end

2. Activities

Activities are the individual units of work, inheriting from Thronglets::Activity:

class MyActivity < Thronglets::Activity
  input do
    # Define input schema
  end

  output do
    # Define output schema
  end

  def call
    # Implement activity logic
  end
end

3. Command Line Interface

Thronglets provides a CLI with several commands:

# Display version
thronglets -v

# Start worker
thronglets -w

# Start in listen mode (auto-reload)
thronglets -l

# Start console
thronglets -c

Input/Output Validation

Thronglets uses dry-schema for input/output validation:

class MyWorkflow < Thronglets::Workflow
  input do
    required(:name).filled(:string)
    required(:age).filled(:integer)
  end

  output do
    required(:success).filled(:bool)
    required(:data).hash
  end
end

Development Mode

For development:

  1. Start in listen mode: thronglets -l
  2. Make code changes
  3. Automatic reload happens on file changes
  4. Use console mode for exploration: thronglets -c

Error Handling

Thronglets provides structured error handling:

  • InputValidationError for invalid inputs
  • OutputValidationError for invalid outputs
  • Automatic error formatting to JSON
  • Standardized error responses

Best Practices

  1. Code Organization

    • Keep activities atomic and focused
    • Use workflows for orchestration
    • Leverage input/output schemas
  2. Development Workflow

    • Use listen mode during development
    • Implement proper input/output validation
    • Follow the directory structure conventions
  3. Error Handling

    • Always validate inputs and outputs
    • Use proper error classes
    • Implement proper error recovery in workflows

Support and Contributing

Support

If you want to report a bug, or have ideas, feedback or questions about the gem, let me know via GitHub issues and I will do my best to provide a helpful answer. Happy hacking!

License

The gem is available as open source under the terms of the MIT License.

Code of conduct

Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Contribution guide

Pull requests are welcome!