district5/service-dispatch-helper

District5 Service Dispatcher Library

2.0.0 2024-04-15 13:58 UTC

This package is auto-updated.

Last update: 2024-04-16 15:00:03 UTC


README

About

This library is designed to facilitate a microservice architecture that is split using subdomains whilst keeping instance costs down during development / early stage. It allows you to split your application into microservices while running them within the same containerised images (or for example within the same GCP App Engine instance).

Installing

This library requires no other libraries.

  • Require in your composer
    • "district5/service-dispatch-helper": "*"

Usage

When calling the helper function, you should pass it the base domain name you are working on that all the subdomains hang from. For example, if our domains are api.district5.co.uk and www.district5.co.uk, we want api-service to map to the api microservice, and web-service to map to the main app. This could be achieved with the following:

$baseDomain = 'd5.gs';
$serviceMap = [
        'api' => 'api-service',
        'www' => 'web-service'
    ];

$selector = new \District5\ServiceDispatch\ServiceSelector($serviceMap);
$service = $selector->getServiceFromServerSubdomain('district5.co.uk');