@avanio/variable-util
    Preparing search index...

    Module @avanio/variable-util-tachyon

    @avanio/variable-util-tachyon

    TypeScript npm version Maintainability Code Coverage variable-util to npmjs

    To install the necessary dependencies, run:

    npm install @avanio/variable-util-tachyon @avanio/variable-util @avanio/logger-like tachyon-drive
    
    import { MemoryStorageDriver } from "tachyon-drive";
    import {
    TachyonConfigLoader,
    tachyonConfigJsonStringSerializer,
    } from "./tachyonConfigLoader";
    import { env, getConfigVariable, stringParser } from "@avanio/variable-util";

    // As example create a memory storage driver with a JSON string serializer
    const driver = new MemoryStorageDriver(
    "MemoryStorageDriver",
    tachyonConfigJsonStringSerializer,
    null,
    );
    // Create a TachyonConfigLoader instance
    const tachyonConfigLoader = new TachyonConfigLoader(driver);
    tachyonConfigLoader.set("SOME_ENV", "override value"); // Set a configuration variable

    // Get the loader function
    const tachyonEnv = tachyonConfigLoader.getLoader;

    // Using the tachyon loader to get a configuration variable (or using ConfigMap)
    const value = await getConfigVariable(
    "SOME_ENV",
    [tachyonEnv(), env()],
    stringParser(),
    );
    console.log(value); // 'override value'

    TachyonConfigLoader have two serializer objects, one for JSON string and one for JSON string Buffer.

    • tachyonConfigJsonStringSerializer - Serializes the configuration data to a JSON string.
    • tachyonConfigJsonBufferSerializer - Serializes the configuration data to a JSON string as Buffer.
    • tachyonConfigJsonArrayBufferSerializer - Serializes the configuration data to a JSON string as ArrayBuffer.

    Loaders

    TachyonConfigLoaderOptions
    TachyonConfigStoreType

    Other

    TachyonConfigLoader
    dataSchema

    Serializers

    tachyonConfigJsonArrayBufferSerializer
    tachyonConfigJsonBufferSerializer
    tachyonConfigJsonStringSerializer