import { IActorRegistrationOptions, IActorSuite } from '@darlean/base';
import { ActorRunner, ActorRunnerBuilder } from './running';
export interface IPersistenceSpecifierCfg {
    specifier: string;
    compartment: string;
}
export interface IPersistenceHandlerCfg {
    compartment: string;
    actorType: string;
}
export interface IFileSystemCompartmentCfg {
    compartment: string;
    partitionKeyLen?: number;
    sortKeyLen?: number;
    shardCount?: number;
    nodes?: string[];
    basePath?: string;
    subPath?: string;
}
export interface IFileSystemPersistenceCfg {
    enabled?: boolean;
    maxShardCount?: number;
    compartments: IFileSystemCompartmentCfg[];
}
export interface IPersistenceCfg {
    enabled?: boolean;
    specifiers: IPersistenceSpecifierCfg[];
    handlers: IPersistenceHandlerCfg[];
    fs: IFileSystemPersistenceCfg;
}
export interface IActorLockCfg {
    enabled?: boolean;
    apps?: string[];
    redundancy?: number;
}
export interface IActorRegistryCfg {
    enabled?: boolean;
    apps?: string[];
}
/**
 * Configuration for runtime apps that provide a DMB (Darlean Message Bus) server.
 */
export interface IDmbServerCfg {
    /**
     * Enables or disables whether this application launches a DMB server. Default is `false`.
     * Can be overruled by `dmb-server-enabled` command-line argument and `DMB_SERVER_ENABLED`
     * environment variable set to `true` or `false`.
     */
    enabled?: boolean;
    /**
     * Port number of the cluster port for the first DMB server on a given host. A cluster port is a port on
     * which other DMB servers in the cluster connect (regular clients do *not* connect to the cluster port).
     * Subsequent DMB servers on the same host are automatically assigned incrementing cluster port numbers.
     * Default value is 5500. Can be uverrules by `dmb-cluster-port-base` command-line argument and `DMB_CLUSTER_PORT_BASE`
     * environment variable set to `true` or `false`.
     */
    clusterPortBase?: number;
}
/**
 * Configuration for apps that want to connect as client to the Darlean Message Bus.
 */
export interface IDmbClientCfg {
    /**
     * List of host names or IP addresses, one for each item in {@link IApplicationCfg.runtimeApps}. Can
     * be overruled by `dmb-hosts` command-line argument and `DMB_HOSTS` environment variable set to a comma-separated
     * list of host names.
     */
    hosts?: string[];
    /**
     * Port number for the first DMB server on a given host. Subsequent DMB servers on the same host
     * are automatically assigned incrementing port numbers. Default value is 4500. Can be overruled by
     * `dmb-base-port` command-line argument and `DMB_BASE_PORT` environment variable.
     */
    basePort?: number;
}
/**
 * Configuration for when this application acts as a runtime application.
 */
export interface IRuntimeCfg {
    /**
     * Enables or disables the provided runtime functionalities. Can be overruled by
     * `runtime-enabled` command-line argument or `RUNTIME_ENABLED` environment variable set to `true` or `false`.
     * @default By default, the runtime functionality is *not* enabled.
     */
    enabled?: boolean;
    /**
     * Configuration of persistence.
     */
    persistence?: IPersistenceCfg;
    /**
     * Configuration of the actor lock.
     */
    actorLock?: IActorLockCfg;
    /**
     * Configuration of the actor registry.
     */
    actorRegistry?: IActorRegistryCfg;
    /**
     * Configuration of the DMB message bus server.
     */
    dmb?: IDmbServerCfg;
}
/**
 * Configuration of messaging.
 */
export interface IMessagingCfg {
    /**
     * List of messaging transports that are tried in the order listed. Currently, only an empty array or
     * an array with one element with value 'dmb' is allowed. Can be overruled by the `messaging-transports` command-line
     * argument or the `MESSAGING_TRANSPORTS` environment parameter, that are either a comma-separated list of transports
     * (currently only 'dmb' is allowed) or the word 'none'.
     *
     * @default When explicitly no transports are provided (by means of an empty array or `none` as value for the command-line argument or
     * environment parameter), an {@link InProcessTransport} instance is used which allows in-process communication
     * (but not communication between processes). Otherwise, when the transports are not explicitly assigned and are also not explicitly
     * cleared, the {@link NatsTransport} (on which DMB is currently based) is used.
     */
    transports: Array<'dmb'>;
    /**
     * Client configuration of the Darlean Message Bus.
     */
    dmb?: IDmbClientCfg;
}
/**
 * Root configuration object for the configuration of a Darlean application.
 *
 * Many of the settings can be overruled by command-line arguments or environment variables. See
 * {@link ConfigRunnerBuilder} for more details.
 */
export interface IApplicationCfg {
    /**
     * The id under which this application is known in the cluster. Must either be set here,
     * or overruled by the `app-id` command-line argument or `APP_ID` environment setting.
     * @default `app`.
     */
    appId?: string;
    /**
     * List of application id's that together provide the runtime of the Darlean cluster
     * (that is, provide the actor registry and actor lock, and optionally provide the
     * Darlean Message Bus, persistence and other services).
     * Must either be set here, or overruled by the `runtime-apps` command-line argument or the
     * `RUNTIME_APPS` environment variable with a comma-separated list of application id's.
     * @default an array consisting of just the {@link appId}.
     */
    runtimeApps?: string[];
    /**
     * Optional configuration when this application acts as runtime.
     */
    runtime?: IRuntimeCfg;
    /**
     * Configuration of the message bus that allows inter-application communication.
     */
    messaging?: IMessagingCfg;
    /**
     * Prefix (including path) of the pidFile for this process. When set, the application creates a pid file
     * and checks during startup whether it is not already running. The value can be overruled
     * with the `pid-file-prefix` command-line argument and the `PID_FILE_PREFIX` environment variable, both of which
     * can be set to `none` to disable the pidFile functionality.
     * @default `'./pid/'`
     */
    pidFilePrefix?: string;
    /**
     * Prefix (including path) of the runFile for this process. When set, the application creates a run file
     * at start up, and automatically stops itself gracefully when the file is no longer present. The value can be overruled
     * with the `run-file-prefix` command-line argument and the `RUN_FILE_PREFIX` environment variable, both of which
     * can be set to `none` to disable the runFile functionality. When not set, the {@link pidFilePrefix} is used as run file prefix.
     */
    runFilePrefix?: string;
}
/**
 * Builds an {@link ActorRunner} instance based on configuration settings, command-line
 * arguments and environment variables.
 *
 * Command-line arguments have priority, followed by environment variables, with the provided
 * configuration data as fall-back.
 *
 * **Command-line arguments** must by default be prefixed with `--darlean-`. So, when the documentation
 * mentions a command-line argument `app-id`, it must by default be provided as `--darlean-app-id`.
 * The value must be provided as after the `=` sign: `--darlean-app-id=client03`. When
 * multiple vales are expected, they must be comma-separated.
 *
 * **Environment variables** must by default be prefixed with `DARLEAN_`. So, when the documentation
 * mentions an environment variable `APP_ID`, it must by default be provided as `DARLEAN_APP_ID`.
 * When multiple values are expected, they must be comma-separated.
 *
 * The argument and environment variable prefix can be configured in the constructor.
 *
 * @see {@link IApplicationCfg} for an overview of all the available configuration items.
 */
export declare class ConfigRunnerBuilder {
    private config;
    private actors;
    private envPrefix;
    private argPrefix;
    private overrides;
    private appId;
    constructor(config?: IApplicationCfg, envPrefix?: string, argPrefix?: string);
    /**
     * Registers an individual actor that must be hosted by the actor runner.
     * @param options The options for the actor.
     * @returns The builder
     */
    registerActor<T extends object>(options: IActorRegistrationOptions<T>): ConfigRunnerBuilder;
    /**
     * Registers a suite of actors that must be hosted by the actor runner.
     * @param suite The suite to be registered
     * @returns The builder
     */
    registerSuite(suite: IActorSuite): ConfigRunnerBuilder;
    getAppId(): string;
    build(): ActorRunner;
    protected configureHostActorLock(builder: ActorRunnerBuilder, runtime: IRuntimeCfg | undefined, runtimeApps: string[]): void;
    protected configureHostActorRegistry(builder: ActorRunnerBuilder, runtime: IRuntimeCfg | undefined, runtimeApps: string[]): void;
    protected configurePersistence(builder: ActorRunnerBuilder, runtime: IRuntimeCfg | undefined): void;
    protected configureFsPersistence(builder: ActorRunnerBuilder, runtime: IRuntimeCfg | undefined): void;
    protected configureActors(builder: ActorRunnerBuilder): void;
    protected configureTransports(builder: ActorRunnerBuilder, config: IApplicationCfg, allInOne: boolean, runtimeApps: string[], appId: string): void;
    protected configureDmbServer(runner: ActorRunner, config: IApplicationCfg, runtimeApps: string[], appId: string): void;
    protected configurePidAndRun(appId: string, runner: ActorRunner, config: IApplicationCfg): void;
    protected fetchString(envName: string, argName: string): string | undefined;
    protected fetchNumber(envName: string, argName: string): number | undefined;
    protected fetchArray(envName: string, argName: string): string[] | undefined;
    protected derivePortOffsets(hosts: string[]): number[];
    protected deriveHosts(dmb: IDmbClientCfg | undefined, appIds: string[]): string[];
    protected deriveConfig(): IApplicationCfg;
    protected loadOverrides(): void;
}
