pilot-core
This is our internal library that implements patterns we use in all our projects. We’ll present two modules: toolkit for event-based architecture and our robust service objects (operations). pilot-core
has much more than that, and we’re extremely proud of what we were able to achieve there. We’re aiming at providing the best possible developer experience. The complexity of the domain we’re dealing with is extremely high, so good tooling is crucial to tackle it and remain productive as an engineer.
We needed a robust and progressive system to encapsulate application-level logic. The progressive part is especially interesting. We’ll show it in the examples below:
It’s the most basic form, it’s just a typical service object. Let’s consider a service that creates counterparty records (required by our payment providers):
class Counterparty::Create < Operation
def perform
# ...
end
end
Counterparty::Create.new(customer_id: cid, name: contractor.name).perform
By default, our operations wrap the perform
method in a DB transaction. It’s desired in 95% of cases, but you can turn it off:
class Counterparty::Create < Operation
self.transactional = false
end