An instance of the acklo client, which can be used for connecting to acklo, retrieving remote configuration for your app, and adding listeners for live updates to your app's configuration.

For extended documentation and getting started guides, check out acklo docs.

example
// Create a new instance
const acklo = new AckloClient({
  applicationKey: "[YOUR APPLICATION KEY]",
  environmentName: "local"
});

// Connect to acklo
await acklo.connect();

// Get a config value
acklo.get("config.port");

Hierarchy

  • AckloClient

Index

Constructors

constructor

  • Create an instance of the acklo client.

    Once the instance has been created you will be able to get configuration values for your application, however these will not be the latest values configured on the acklo dashboard. In order to get the latest values you'll first need to connect to acklo by calling connect on your instance.

    Most of the properties used to configure the instance can also be set as environment variables. There are more details on this in the ClientConfigurationProperties docs.

    example
    // Create the instance
    const acklo = new AckloClient({
      applicationKey: "[YOUR APPLICATION KEY]",
      environmentName: "local"
    });
    
    // This will be the default port configured in your acklo configuration file.
    acklo.get('config.port_number');
    
    // Connect to acklo...
    await acklo.connect()
    
    // Now that you've established a connection to acklo, this will be the latest value
    // for `config.port_number` as configured on the acklo dashboard.
    acklo.get('config.port_number');
    
    throws

    MissingRequiredConfigurationValuesError when a required configuration property is missing.

    throws

    MissingConfigTemplateFile when the acklo config template file could not be found.

    throws

    InvalidConfigTemplateFile when the acklo config template file is invalid.

    Parameters

    Returns AckloClient

Methods

connect

  • connect(options?: { continueAfterConnectionError: boolean }): Promise<AckloClient>
  • Establish a connection to acklo.

    Once the connection has been established you'll be able to get the latest configuration values from the acklo dashboard and set up listeners so you get notified the instant that a configuration value changes.

    example
    // Using async/await
    const acklo = await new AckloClient({
      applicationKey: "[YOUR APPLICATION KEY]",
      environmentName: "local"
    }).connect();
    
    // Using promises
    const acklo =
      new AckloClient({
        applicationKey: "[YOUR APPLICATION KEY]",
        environmentName: "local"
      })
     .connect()
     .then(() => console.log("Connected successfully"))
     .catch(err => console.error("Failed to connect", err));
    
    throws

    ConnectionError for any connection errors if you have set the continueAfterConnectionError option to true.

    Parameters

    • options: { continueAfterConnectionError: boolean } = ...
      • continueAfterConnectionError: boolean

        Whether to continue execution without throwing after an error in conencting to acklo has occurred. Default is true.

    Returns Promise<AckloClient>

disconnect

  • Disconnect from acklo.

    Once you've disconnected you will no longer receive configuration updates from acklo. It's recommended that you call this method when your application is shutting down (e.g. when it receives SIGTERM) in order to gracefully close any open sockets the acklo client has established.

    example
    const acklo = await new AckloClient({
      applicationKey: "[YOUR APPLICATION KEY]",
      environmentName: "local"
    }).connect();
    
    await acklo.disconnect();
    

    Returns Promise<AckloClient>

get

  • get(id: string): ConfigTemplateValueType
  • Returns the latest config value for the given property.

    This will return the default values specified in your acklo configuration file (acklo.config.yml) until the client has been successfully connected to acklo by using the connect method.

    undefined will be returned if you try to get a value for a config property that does not exist.

    example
    acklo.get("config.port");
    

    Returns:

    3000
    

    Parameters

    • id: string

      the ID of the config value you want to get (e.g. "config.port")

    Returns ConfigTemplateValueType

getConfig

  • getConfig(): ConfigTemplateValues
  • Returns the latest config for your application.

    This will return the default values specified in your acklo configuration file (acklo.config.yml) until the client has been successfully connected to acklo by using the connect method.

    example
    acklo.getConfig();
    

    Returns:

    {
      "config.port": 3000,
      "config.greeting": "Howdy, partner",
      "feature_switch.new_homepage": true
    }
    

    Returns ConfigTemplateValues

getConfigRaw

  • getConfigRaw(): ConfigTemplateValuesRaw
  • Returns the latest config for your application, but unlike getConfig does not try to coerce the values stored on the acklo backend to native Javascript types (i.e. booleans, numbers, etc). Instead it returns all values as strings and lets you do your own coercion.

    Unless you have a good reason to use this method, you probably want getConfig instead.

    This will return the default values specified in your acklo configuration file (acklo.config.yml) until the client has been successfully connected to acklo by using the connect method.

    example
    acklo.getConfigRaw();
    

    Returns:

    {
      "config.port": "3000",
      "config.greeting": "Howdy, partner",
      "feature_switch.new_homepage": "true"
    }
    

    Returns ConfigTemplateValuesRaw

getInstanceName

  • getInstanceName(): undefined | string
  • Returns the name of this application instance as displayed on the acklo dashboard.

    This will only return a value once the client has been successfully connected to acklo by using the connect method.

    The instance name is randomly generated by acklo and is a combination of some recognizable words and random characters.

    example
    acklo.getInstanceName();
    

    Returns:

    "ins-delicate-feather-qpcw"
    

    Returns undefined | string

getInstanceUrl

  • getInstanceUrl(): undefined | string
  • Returns the URL at which you can see this instance on the acklo dashboard.

    This will only return a value once the client has been successfully connected to acklo by using the connect method.

    example
    acklo.getInstanceUrl()
    

    Returns:

    "https://acklo.app/dashboard/applications/my-app/local/instances/a438372d-2dba-46dc-ada2-3ae043e2c8c3"
    

    Returns undefined | string

getRaw

  • getRaw(id: string): undefined | string
  • Returns the latest config value for the given property, but unlike get does not try to coerce the values stored on the acklo backend to native JavaScript types (i.e. booleans, numbers, etc). Instead it returns all values as strings and lets you do your own coercion.

    Unless you have a good reason to use this method, you probably want get instead.

    This will return the default values specified in your acklo configuration file (acklo.config.yml) until the client has been successfully connected to acklo by using the connect method.

    undefined will be returned if you try to get a value for a config property that does not exist.

    example
    acklo.get("config.port");
    

    Returns:

    "3000"
    

    Parameters

    • id: string

    Returns undefined | string

onConfigUpdate

  • onConfigUpdate(callback: (updates: ConfigTemplateValueUpdates) => void): void
  • Registers the given callback to run as soon as an update is made to this application's config. This allows you to react immediately to configuration changes without needing to poll the get method.

    example
    // Where "config.port" has been updated to 4000.
    acklo.onConfigUpdate(updates => {
      console.log(`my new port is: ${updates["config.port"].newValue}`);
      // Prints
      // my new port is: 4000
    });
    

    Parameters

    • callback: (updates: ConfigTemplateValueUpdates) => void
        • (updates: ConfigTemplateValueUpdates): void
        • Parameters

          • updates: ConfigTemplateValueUpdates

          Returns void

    Returns void

Generated using TypeDoc