Configuring the Official Iron Cache Client Libraries

Many of the client libraries make use of a global configuration scheme for all of Iron.io services. This approach lets you set and manage your tokens and project IDs in a centralized manner and make them available across all of Iron.io's services, even across workspaces.

This scheme allows you to spend less time on configuration issues and more on writing code. It also supports the design pattern that calls for strict separation of configuration information from application code.

The two most common variables used in configuration are the project ID and the token. The project ID is a unique identifier for your project and can be found in the HUD. The token is one of your OAuth2 tokens, which can be found on their own page in the HUD.

Table of Contents

Quick Start

Set the following environment variables:

IRON_TOKEN=MY_TOKEN
IRON_PROJECT_ID=MY_PROJECT_ID

The IRON_PROJECT_ID you use will be the default project to use. You can always override this in your code.

That's it, now you can get started.

The Client's Environment Variables

The environment variables the scheme looks for are all of the same formula: the camel-cased product name is switched to an underscore ("IronWorker" becomes "IRON_WORKER") and converted to be all capital letters. For the global environment variables, "IRON" is used by itself. The value being loaded is then joined by an underscore to the name, and again capitalised. For example, to retrieve the OAuth token, the client looks for "IRON_TOKEN".

In the case of product-specific variables (which override global variables), it would be "IRON_WORKER_TOKEN" (for IronWorker).

Configuration using iron.json (deprecated)

You can follow the old configuration scheme and set project_id, token and other parameters in iron.json file but using only environment variables is more preferred.