Skip to main content

Configuring the Clients

In every LittleHorse SDK, there is an LHConfig class or struct that handles the configuration required for allowing your clients and Task Workers to talk to LittleHorse Server.

Creating the LHConfig

You can create a config object in three ways (this is the same for LHClientConfig and LHWorkerConfig):

  1. With no arguments, eg. new LHClientConfig(). This loads all configurations from the environment variables.
  2. Passing in a properties object, eg. new LHClientConfig(properties). This uses the configuration from the provided Properties object.
  3. Passing in a path to a properties file, eg. new LHClientConfig("/opt/littlehorse.config"). This uses the configuration from the provided file.

The java class can be found at:

import io.littlehorse.sdk.common.config.LHConfig;

Client Config Options

All of our SDK's share common configuration options. They are listed below:

    • This is the host name that the client should use to connect to the LH Server. It is equivalent to bootstrap.servers in Kafka; on LittleHorse Cloud this host always points to a Load Balancer.
    • This is the port that the client should connect to.
    • This is the client ID. This should be unique for every client.
    • This is the path to the Client Private Key. Used for mTLS authentication.
    • This is the path to the Client Public Key (Certificate). Used for mTLS authentication.
    • This is the path to the CA Certificate. Used for TLS.
    • This is the OAuth client ID. Used for OAuth authorization.
    • Optional OAuth2 Client Secret. Used by the Worker to identify itself at an Authorization Server. Client Credentials Flow.
    • Optional Access Token URL provided by the OAuth Authorization Server. Used by the Worker to obtain a token using client credentials flow. It is mandatory if LHC_OAUTH_CLIENT_ID and LHC_OAUTH_CLIENT_SECRET are provided.

The following configurations are used for the Task Workers (in addition to the above configuration options for all):

    • The number of worker threads in the Threadpool which executes Task Runs.
    • The version of this Task Worker. This is an optional config which is useful for keeping track of when you release new versions of your Task Workers.
    • The name of the Listener to connect to on the LH Server. This defaults to PLAIN.

The following is specific for lhctl cli:

    • Optional Authorization Server URL. Used by the client to obtain a token using OAuth 2 authorization code credentials flow. It is used by OIDC to discover the server endpoints. It is mandatory if LHC_OAUTH_CLIENT_ID is provided.

Configuring the CLI

By default, lhctl looks for a configuration file at ${HOME}/.config/littlehorse.config. This configuration file tells lhctl where and how to connect to the LittleHorse Servers. An example littlehorse.config file looks like:



The LHC_API_HOST and LHC_API_PORT determine the endpoint that lhctl connects to. The LHW_SERVER_CONNECT_LISTENER is a config used by the Task Worker to tell the servers which listener to advertise to it. More details can be found in the configuration docs.

If you have properly installed lhctl and configured it to point to a running LittleHorse Server, you should be able to run the following command:

-> lhctl search wfSpec
"results": []

Getting a GRPC Client

In an effort to not reinvent the wheel, LittleHorse exposes a grpc API to its users. The LHConfig allows you to get a grpc client.

You can get an async grpc stub as follows:

LHConfig config = new LHConfig();
LittleHorseStub client = config.getAsyncStub();

You can get a blocking grpc stub as follows:

LHConfig config = new LHConfig();
LittleHorseBlockingStub client = config.getBlockingStub();