Application host selection

Selecting an host version

In the architecture of a Stormancer cluster, the app host is the component that makes the interface between a cluster node and the server app logic. The host is a process that is started by the grid node, connects to it, then compiles and run the server app code. As hosts are isolated processes, it would be possible to create hosts for multiple server app languages. However currently only a C# host is provided.

When starting an application, the grid must select an host both compatible with the application and the grid itself. To do that, it extracts:

  • The version of the Stormancer.Abstractions.Host nuget package the grid node (in Stormancer.Server.Node) depends on. This package contains APIs and types shared between the grid and the host. A version of this package represents a version of the “protocol” the grid node understands when communicating with an host process. The version follows semantic versioning.

  • The version of the Stormancer.Abstractions.Server the server application depends on. This package represents the set of APIs the server application depends on.

The node then gathers all known hosts in host package sources that are compatible with both dependencies above. For instance:

../_images/host-version.png

Then the node executes the filtering rules specified on the application on the compatible host versions to extract a filtered host candidates list.

Finally The latest version in the host candidates list is selected to start the application server.

Locking

If locking is enabled and the currently locked host version is in the compatibility list, instead of the latest compatible version, the locked version is selected.

If the locked version is not in the compatibility list, the latest compatible version is selected and set as locked version.

To enable locking, set host.lock to true in the application object:

PUT: /_app/{accountId}/{appName}
{
    "hosts":{
        "lock":true
    }
}

Host package sources

The grid configuration contains the list of nuget sources it is going to use to locate compatible hosts for the server application. Te node gathers all compatible nodes in all the provided sources. Tokens can be specified in the list to extract package sources from environment variables or other token sources:

"hosting": {
  "packages": {
    "applications": "{sharedDirectory}/apps",
    "hostSources": [
      "https://api.nuget.org/v3/index.json",
      "{localPackageSource}"
    ],

Filtering

Host filters are set per application and follow the filter json syntax:

PUT: /_app/{accountId}/{appName}
{
    "hosts":{
        "filter":{
            // host version must be greater or equal than 5.2.1 and lesser than 5.3
            "must":[
                {
                    "range":{
                        "field":"version",
                        "type":">=",
                        "value":"5.2.1"
                    }
                },
                {
                    "range":{
                        "field":"version",
                        "type":"<",
                        "value":"5.3.0"
                    }
                }

            ]

        }
    }
}