Skip to main content
The RPC datasource connects Forest back-ends to each other over RPC (Remote Procedure Call). Use it to expose a remote data source in your back-office, or to split one back-end across multiple services (microservices) that a main back-end aggregates into a single admin panel.

Node.js

In Node.js, the RPC datasource connects to a remote data source and exposes its data and operations in your back-office.

Ruby (distributed back-ends)

In Ruby, the RPC datasource lets you distribute your Forest back-end across multiple microservices. Each service runs its own RPC back-end, and a main back-end aggregates them into a unified admin panel. Why use RPC?
  • Microservices architecture: your application is split into multiple services, each owning its data.
  • Team isolation: each team manages their own Forest configuration.
  • Independent deployment: update one service without redeploying the entire admin panel.
  • Scalability: distribute load across multiple agents.
RPC architecture: a main agent connected to several RPC agents

Main back-end

The main back-end aggregates multiple RPC back-ends into a single Forest interface. It behaves exactly like a classic back-end with multiple datasources: once connected, you can define relations across datasources transparently.
The auth_secret option is optional. If not specified, it defaults to your Forest project’s auth_secret. Override it to use a different shared secret for RPC communication.
The ReconciliateRpc plugin must be added in the main back-end. It relies on collection names matching across all back-ends, so if you rename collections in your RPC back-ends, keep all back-ends synchronized.

Introspection caching

By default, the main back-end introspects each RPC back-end at startup. Caching the introspection schema makes startup faster, lets the main back-end boot even if an RPC back-end is temporarily unavailable, and supports asynchronous deployments. RPC back-ends automatically generate a .forestadmin-rpc-schema.json file in development mode; pass it when adding a datasource:
Regenerate the cached schema when an RPC back-end’s collections change.

RPC back-end

An RPC back-end exposes its collections to the main back-end via the RPC protocol.
Run the installation command with the auth_secret from your main Forest project:
This creates config/initializers/forest_admin_rpc_agent.rb, lib/forest_admin_rpc_agent/create_rpc_agent.rb, and mounts the RPC routes in config/routes.rb. The generated back-end looks like:
You can use all standard customization methods (computed fields, actions, segments, etc.) on your RPC back-end collections.

Cross-RPC relations

When an RPC back-end needs to reference collections from another RPC back-end, import them by adding an RPC datasource that references the other back-end, then use mark_collections_as_rpc: true to indicate those collections are provisioned elsewhere.
For finer control over which collections are marked, call mark_collections_as_rpc manually:
Supported cross-RPC relation types: add_many_to_one_relation, add_one_to_many_relation, add_one_to_one_relation, and add_many_to_many_relation.

Source code

This connector is open source. Browse the code or contribute on GitHub: