Services

Description

Services encapsulate larger features in our backend code. A service contains related companions, models, actors, and jobs.

All communication with a service goes through a set of service modules. All communication with a service is strictly through serializable data structures (not ActiveRecord objects).

  • Services live in app/services
  • Services do not contain controllers or views
  • Do not access service models directly (use service modules)

Drawbacks of services

  1. Since all data is exchanged with data structures, we cannot efficiently use ActiveRecord to do joins or preloading
  2. The overhead of converting all data to and from data structures requires extra code

Technology Status at Wunder

Discouraged. If the domain concept is highly decoupled from other parts of the app, a service may be appropriate, but usually Segments are an easier way to achieve encapsulation.

Notes/Resources