Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
Once OKAPI gateway receives incoming request, it scans module descriptors to define modules able to handle the request in further. Then, Okapi decides how to call the module depending on the "interfaceType" value in module's descriptor.
...
'internal' refers to Okapi's internal module. This is a code that is linked into Okapi, and not a real module at all. All the `/_/` services like '/_/proxy', '/_/discovery', `/_/tenant` are internal modules.
"multiple" interface type
Usually, Okapi proxy allows exactly one module at once to provide a given interface. To enable Okapi to dispatch the request to any number of modules with the same interface just use "interfaceType": "multiple" in the "Provides" section of the ModuleDescriptor. It allows Okapi to deploy any number of modules with the same rest API endpoints.
Next up, the user of the interface must choose module to call by specifying HTTP header X-Okapi-Module-Id.
Also, Okapi provides an endpoint to get the list of modules what implements predefined interface: _/proxy/tenants/{tenant}/interfaces/{interface}.
...
- Lets define and register(_/proxy/modules) to Okapi module descriptor for the "Module1":
then, deploy corresponding desriptor for the "Module1" to Okapi (_/proxy/discovery), nothing special in this section. - Let's define and register(_/proxy/modules) to Okapi module descriptor for the "Module2":
NOTE: keep the same "id" field in "provides" section to unite all the modules with the same interface!
then, deploy corresponding descriptor for the "Module2" to Okapi (_/proxy/discovery), nothing special in this section. - Don't forget to enable modules given above to the tenant ("diku" in our case);
- For now, "Module 1" and "Module 2" are listening to the same interface, it's necessary to specify X-Okapi-Module-Id header to call one of them:
If you will try to call /service endpoint without specifiing module-id header, you will get 404 "No suitable module found for path /service" - Okapi offers a facility which returns list of modules that implement a given interface for a tenant (_/proxy/tenants/{tenantId}/interfaces/{interfaceId}).
So, calling _/proxy/tenants/diku/interfaces/simple-multiple-interface you will receive:
All the sources for the both of the "Module1" and "Module2" mentioned before are pushed into github repo
https://github.com/Igor-Gorchakov/folio-multi-interface-dispatcher.Running in cluster mode
If the Folio application is deployed in cluster mode, a couple of instances of the same module may run. And if the module, being deployed with interface Type = multiple, has a couple of instances, we can't exactly identify which one instance will receive the incoming request. In most production deployments there will be load-balancing and failover between the module and Okapi, the way Okapi dispatches request is implementation-defined.
...