Citing dependencies

Dependency resolution is one of Architect's most valuable additions to service-oriented applications, and referencing network dependencies is just as easy as installing dependencies via your favorite package manager. Either modify the service config directly to include the dependency name and version, or use our CLI to make the modifications on your behalf:

# Checks to make sure the service exists in the registry and appends
# the reference to your architect.json file
$ architect install hipster-shop-demo/paymentservice
// architect.json
{
    "dependencies": {
        "hipster-shop-demo/paymentservice": "latest"
    }
}

Unlike a package manager, dependencies can't be resolved simply by installing the service because the service needs to be running independently before it can receive calls. For this reason, Architect resolves the dependency relationships with each deployment, both locally and remotely.

Making calls to dependencies

With parameter mapping

The best way to migrate an existing service to use Architect to broker connections to dependencies is through parameter mapping. Architect already injects the host and port used to connect to related services into each service at deploy time, but existing applications often expect to receive these values via their own parameter names. If a service already expects to receive the location of a dependency at a specific parameter, the best way to enrich the service is through parameter mapping:

{
    "dependencies": {
        "architect/payments-service": "latest"
    },
    "parameters": {
        "PAYMENTS_SERVICE_HOST": {
            "default": {
                "valueFrom": {
                    "dependency": "architect/payments-service:latest",
                    "value": "$HOST:$PORT"
                }
            }
        }
    }
}

The above manifest tells Architect that by default the $PAYMENTS_SERVICE_HOST should be populated from the host and port of the dependency, architect/payments-service, in each environment. Mappings like this are a great way for services that already connect to dependencies to leverage Architect without any code changes.

With the SDK

In addition to parameter mapping, Architect also maintains a set of SDKs designed for use with the platform that can aid in brokering connections to dependencies. The SDKs don't require parameter mapping in order to connect, and some of them support Architect's experimental codegen features for gRPC.