@avanio/variable-util-tachyon
v1.3.1
Published
tachyon store for variables
Readme
@avanio/variable-util-tachyon
Tachyon storage driver loader for @avanio/variable-util
Installation
To install the necessary dependencies, run:
npm install @avanio/variable-util-tachyon @avanio/variable-util @avanio/logger-like tachyon-driveExample
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'Serialization
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.
