Module: Fractor

Defined in:
lib/fractor.rb,
lib/fractor/cli.rb,
lib/fractor/work.rb,
lib/fractor/logger.rb,
lib/fractor/worker.rb,
lib/fractor/version.rb,
lib/fractor/workflow.rb,
lib/fractor/supervisor.rb,
lib/fractor/work_queue.rb,
lib/fractor/work_result.rb,
lib/fractor/result_cache.rb,
lib/fractor/workflow/job.rb,
lib/fractor/config_schema.rb,
lib/fractor/configuration.rb,
lib/fractor/priority_work.rb,
lib/fractor/error_reporter.rb,
lib/fractor/signal_handler.rb,
lib/fractor/wrapped_ractor.rb,
lib/fractor/error_formatter.rb,
lib/fractor/queue_persister.rb,
lib/fractor/workflow/logger.rb,
lib/fractor/wrapped_ractor3.rb,
lib/fractor/wrapped_ractor4.rb,
lib/fractor/error_statistics.rb,
lib/fractor/execution_tracer.rb,
lib/fractor/shutdown_handler.rb,
lib/fractor/workflow/builder.rb,
lib/fractor/workflow/helpers.rb,
lib/fractor/callback_registry.rb,
lib/fractor/continuous_server.rb,
lib/fractor/main_loop_handler.rb,
lib/fractor/result_aggregator.rb,
lib/fractor/supervisor_logger.rb,
lib/fractor/main_loop_handler3.rb,
lib/fractor/main_loop_handler4.rb,
lib/fractor/performance_monitor.rb,
lib/fractor/priority_work_queue.rb,
lib/fractor/workflow/visualizer.rb,
lib/fractor/persistent_work_queue.rb,
lib/fractor/workflow/retry_config.rb,
lib/fractor/error_report_generator.rb,
lib/fractor/workflow/chain_builder.rb,
lib/fractor/workflow/retry_strategy.rb,
lib/fractor/workflow/circuit_breaker.rb,
lib/fractor/workflow/execution_hooks.rb,
lib/fractor/workflow/execution_trace.rb,
lib/fractor/workflow/workflow_result.rb,
lib/fractor/work_distribution_manager.rb,
lib/fractor/workflow/workflow_context.rb,
lib/fractor/workflow/dead_letter_queue.rb,
lib/fractor/workflow/structured_logger.rb,
lib/fractor/workflow/workflow_executor.rb,
lib/fractor/workflow/execution_strategy.rb,
lib/fractor/workflow/retry_orchestrator.rb,
lib/fractor/workflow/workflow_validator.rb,
lib/fractor/performance_report_generator.rb,
lib/fractor/performance_metrics_collector.rb,
lib/fractor/workflow/pre_execution_context.rb,
lib/fractor/workflow/execution/job_executor.rb,
lib/fractor/workflow/circuit_breaker_registry.rb,
lib/fractor/workflow/execution/result_builder.rb,
lib/fractor/workflow/job_dependency_validator.rb,
lib/fractor/workflow/circuit_breaker_orchestrator.rb,
lib/fractor/workflow/type_compatibility_validator.rb,
lib/fractor/workflow/execution/dependency_resolver.rb,
lib/fractor/workflow/execution/fallback_job_handler.rb,
lib/fractor/workflow/execution/workflow_execution_logger.rb,
sig/fractor.rbs

Overview

Fractor: Function-driven Ractors framework

Defined Under Namespace

Modules: ConfigSchema, QueuePersister, RactorLogger Classes: CallbackRegistry, Cli, ClosedQueueError, Configuration, ConfigurationError, ContinuousServer, ErrorFormatter, ErrorReportGenerator, ErrorReporter, ErrorStatistics, ExecutionTracer, InputMismatchError, MainLoopHandler, MainLoopHandler3, MainLoopHandler4, OutputMismatchError, PerformanceMetricsCollector, PerformanceMonitor, PerformanceReportGenerator, PersistentWorkQueue, PriorityWork, PriorityWorkQueue, ResultAggregator, ResultCache, ShutdownHandler, ShutdownSignal, SignalHandler, Supervisor, SupervisorLogger, Work, WorkDistributionManager, WorkQueue, WorkResult, Worker, Workflow, WorkflowCycleError, WorkflowError, WorkflowExecutionError, WorkflowValidationError, WrappedRactor, WrappedRactor3, WrappedRactor4

Constant Summary collapse

RUBY_4_0_OR_HIGHER =

Version check constant - computed once at load time for performance Avoids expensive Gem::Version.new calls in hot paths

RUBY_VERSION >= "4.0.0"
WINDOWS_RUBY_34 =

Windows Ruby 3.4.x check - for platform-specific workarounds This is only relevant on Windows and Ruby 3.4.x

RUBY_PLATFORM.match?(/mswin|mingw|cygwin/) &&
RUBY_VERSION >= "3.4.0" && RUBY_VERSION < "3.5.0"
VERSION =

Fractor version

Returns:

  • (String)
"0.1.11"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerLogger

Get the Fractor logger instance

Returns:

  • (Logger)

    Logger instance



11
12
13
# File 'lib/fractor/logger.rb', line 11

def logger
  @logger ||= create_default_logger
end

Class Method Details

.configConfiguration

Access the global configuration instance.

Returns:



100
101
102
# File 'lib/fractor.rb', line 100

def self.config
  Configuration.config
end

.configure {|Configuration| ... } ⇒ Object

Configure Fractor with a block.

Examples:

Fractor.configure do |config|
  config.debug = true
  config.logger = Logger.new(STDOUT)
  config.default_worker_timeout = 60
end

Yields:



73
74
75
# File 'lib/fractor.rb', line 73

def self.configure(&)
  Configuration.configure(&)
end

.configure_from_envObject

Load configuration from environment variables. Environment variables should be prefixed with FRACTOR_.

Examples:

# Set environment variables
# export FRACTOR_DEBUG=true
# export FRACTOR_DEFAULT_WORKER_TIMEOUT=60

Fractor.configure_from_env


93
94
95
# File 'lib/fractor.rb', line 93

def self.configure_from_env
  Configuration.configure_from_env
end

.configure_from_file(file_path) ⇒ Object

Load configuration from a YAML file.

Parameters:

  • file_path (String)

    Path to the YAML configuration file



80
81
82
# File 'lib/fractor.rb', line 80

def self.configure_from_file(file_path)
  Configuration.configure_from_file(file_path)
end

.debug_enabled?Boolean

Check if debug logging is enabled

Returns:

  • (Boolean)


29
30
31
# File 'lib/fractor/logger.rb', line 29

def debug_enabled?
  @logger&.debug?
end

.disable_loggingObject

Disable logging entirely



24
25
26
# File 'lib/fractor/logger.rb', line 24

def disable_logging
  @logger = create_disabled_logger
end

.enable_logging(level = Logger::DEBUG) ⇒ Logger

Enable debug logging to STDOUT

Returns:

  • (Logger)

    The configured logger



17
18
19
20
21
# File 'lib/fractor/logger.rb', line 17

def enable_logging(level = Logger::DEBUG)
  main_logger = create_logger_for_output($stdout, level)
  @logger = main_logger
  main_logger
end

.reset_logger!Object

Reset logger state (internal method, use reset! instead)



116
117
118
# File 'lib/fractor.rb', line 116

def self.reset_logger!
  @logger = nil if defined?(@logger)
end