Conversation
Emits one `transition.micro_case` event per transition when the new `config.notifications` flag is on AND transitions are enabled. Payload exposes use_case_class, attributes, result_type, result_kind, result_data, and accessible_attributes — plain Ruby values, no Result instance, safe for JSON-encoding subscribers. `activesupport` stays out of runtime deps. The new `Micro::Case::Result::Notifications` module probes `defined?(::ActiveSupport::Notifications)` at require time and redefines `publish` to a no-op when unavailable, so the transition hot path stays branch-free. Setting `config.notifications = true` while AS::Notifications is not loaded raises the new `Micro::Case::Error::NotificationsUnavailable` (fail-fast at boot rather than silently dropping events). Default is off — existing callers get no behavior change. Additive only: Transitions::MapEverything, result.transitions, and Result.new(custom_mapper) are unchanged. CHANGELOG entry under [Unreleased]; both READMEs gain a top-level Observability section with subscriber recipes and the synchronous-subscriber cost warning. Closes #5. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Micro::Case::Result::Notificationsmodule that publishes onetransition.micro_caseActiveSupport::Notificationsevent per transition, when both transitions and the newconfig.notificationsflag are enabled. Payload exposes:use_case_class,:attributes,:result_type,:result_kind(:success|:failure),:result_data, and:accessible_attributes— plain Ruby values, safe for JSON-encoding subscribers (OTEL, structured logs, StatsD, Rack::MiniProfiler, etc.).activesupportstays out of runtime deps. The module probesdefined?(::ActiveSupport::Notifications)at require time and redefinespublishto a no-op when unavailable, so the transition hot path stays branch-free. Settingnotifications = truewhile AS::Notifications is not loaded raises the newMicro::Case::Error::NotificationsUnavailable(fail-fast at boot rather than silently dropping events). Default is off — existing callers get no behavior change.Transitions::MapEverything,result.transitions, andResult.new(custom_mapper)are unchanged. CHANGELOG entry under[Unreleased]; both READMEs (EN + pt-BR) gain a top-level Observability section with the Rack::MiniProfiler-step andRails.loggersubscriber recipes, plus the synchronous-subscriber cost warning.Test plan
bundle exec rake test— 811 runs, 0 failures (default bundle, AS::Notifications absent → unavailable-path tests run, happy-path tests skip)BUNDLE_GEMFILE=gemfiles/rails_8_1.gemfile bundle exec rake test— 1058 runs, 0 failures (AS::Notifications loaded → full happy-path tests run, unavailable-path tests skip)ENABLE_TRANSITIONS=false bundle exec rake test— 0 failures (transitions off → no events fire even with config flag on)ENABLE_TRANSITIONS=false BUNDLE_GEMFILE=gemfiles/rails_8_1.gemfile bundle exec rake test— 0 failuresbundle exec rake matrixacross the Ruby × Rails ×ENABLE_TRANSITIONSaxes in CI🤖 Generated with Claude Code