Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
service_orchestrator
Advanced tools
ServiceOrchestrator is a lightweight dependency injection framework, greatly inspired by the awesome Morphine gem.
Compared to Morphine, it automatically wires dependencies between services thanks to some simple conventions.
If you wonder if you need this library, please check out my article about Services in Rails.
Install the gem and add it to the application's Gemfile by executing:
$ bundle add service_orchestrator
The framework is composed of 2 main Ruby classes:
ServiceOrchestrator::Container
which registers all the services and wires the dependencies.ServiceOrchestrator::Service
that any service with dependencies inherits from.Conventions
First, declare a container in order to register all your services.
class ApplicationContainer < ServiceOrchestrator::Container
register :onboarding, 'OnBoardingService'
register :analytics_tracker, 'AmplitudeAnalyticsTrackerService'
private
register :amplitude_sdk do
AmplitudeSDK.new(api_key: Rails.application.credentials.amplitude.api_key)
end
end
Then, declare your services.
class AmplitudeAnalyticsTrackerService < ServiceOrchestrator::Service
dependency :amplitude_sdk
def call(event_name:, properties: {})
amplitude_sdk.send_event(event_name, properties)
end
class OnboardingService < ServiceOrchestrator::Service
dependency :analytics_tracker
def call(attributes:)
User.create(attributes).tap do |user|
analytics_tracker.call(:new_user, { email: user.email })
end
end
end
Create an instance of a container to get access to your services.
container = ApplicationContainer.new
container.onboarding.call({ email: 'john@doe.net', name: 'John' })
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/nocoffeehq/service_orchestrator.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that service_orchestrator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.