Skip to main content

Selectors

What it is?#

Selectors are optional data that you can pass with your Session creation call to filter Deployments that are going to be selected to link them.

What it does?#

Selectors can have different attributes based on your needs

  • Filter Deployment with specific Tag to link the Session
  • Tag your Session to add extra Data
  • Inject Environment Variable in the Deployment in the case of auto-deploying Application Version

See Example

How it helps?#

  • Simplify the App Version Management.
    Using the same Application Version to deploy different context.
  • Easy usage and integration with Matchmaker.
    No need to support complex model, pass the extra data directly in your request and match the session in the right deployment.

How to use it?#

Selectors and Environment Variable
When doing your a POST to deploy a session, you can now include selectors to identify your Session and this will filter potential Deployment by finding only Deployment that match all the Selectors. For Application Version with auto-deploy activated, when no matching deployment is found, those Selectors can inject environment variables to the new Deployment to add extra context. Optionally, you can use Selectors to simply tag the Session without affecting the filtering of the Deployment.

Warning : The filtering is only occuring with the Tag and won't be affected by the environment variables you want to inject. Given 2 Sessions with the same Tag but different environment variables will result in a Deployment with only the environment variable of the first session linked to the Deployment.

Tag Only
You can use the Selector to tag the session by specifying "tag_only": true. This will only add tag to session without filtering the Deployment and will not inject environment variable anyhow. This is usefull to simply identify or add information to your Session

Example#

Imagine your Application named my-game is loading dynamically your map assets from your Environment Variable with the key GAME_MAP_ID. Using the session would be complicated since you would have to manage different Application Version to match the Session's Deployment. Every new map would required more management and more complexity! Fear no more! With Selectors you can use the same Application Version to link correctly Session to Deployment with the right map loaded by environment variable.

Creating a Session with the following

{
"app_name": "my-game",
"version_name": "v1",
"ip_list": ["1.2.3.4"],
"selectors": [
{
"tag": "Ranked"
},
{
"tag": "Map A",
"env": {
"key": "GAME_MAP_ID",
"value": "1"
}
},
{
"tag": "id-123",
"tag_only": true
}
]
}

This will try to find a Deployment with the matching Tags Ranked and Map A to link the session. If the Application Version auto-deploy option is activated and no Deployment have been found, it will create a new Deployment with the Tags Ranked and Map A to inject GAME_MAP_ID=1 as environment variable.

But if you do another call with the following

{
"app_name": "my-game",
"version_name": "v1",
"ip_list": ["4.3.2.1"],
"selectors": [
{
"tag": "Ranked"
},
{
"tag": "Map B",
"env": {
"key": "GAME_MAP_ID",
"value": "2"
}
},
{
"tag": "id-abc",
"tag_only": true
}
]
}

This will result in a new Deployment for the Tags Ranked and Map B with GAME_MAP_ID=2