This package contains utility for running various functionality inside a Fluid Framework environment.
Allows some execution to be made on a container given a provided ODSP snapshot.
If package is installed globally:
node fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFile=result.txt --telemetryFile=telemetryFile.txt
If working directly on this package:
node bin/fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFile=result.txt --telemetryFile=telemetryFile.txt
The Code Loader bundle should provide defined exports required for this functionality. For more details on what exports are needed, see codeLoaderBundle.ts.
You may notice the command line argument codeLoader
is optional. If you choose not to provide a value for codeLoader
, you must extend this library
and provide a IFluidFileConverter
implementation to the fluidRunner(...)
method.
import { fluidRunner } from "@fluidframework/fluid-runner";
fluidRunner({ /* IFluidFileConverter implementation here */ });
Note: Only one of
codeLoader
orfluidRunner(...)
argument is allowed. If both or none are provided, an error will be thrown at the start of execution.
The input file is expected to be an ODSP snapshot. For some examples, see the files in the localOdspSnapshots folder.
There is an optional command line option telemetryFormat
that allows you to specify the telemetry output format. The naming provided to this option is strict and must match an option in OutputFormat.
The default format is currently JSON
There is an optional command line option telemetryProp
that allows you to specify additional properties that will be added to every telemetry entry. The format follows these rules:
- every key must be a string
- values may be either a string or a number
- keys and values cannot be empty
Example of valid usages:
--telemetryProp prop1 value1 --telemetryProp prop2 10.5
--telemetryProp " prop1 " " value1 " prop2 value2
--telemetryProp prop1 "aaa=bbb" prop2 "aaa\"bbb"
No trimming of white-space inside quotes
Example of invalid usages:
--telemetryProp "10" value1
--telemetryProp prop1
--telemetryProp= // this will be treated as ['']
The code around exportFile
can be consumed in multiple different layers. It is not necessary to run all this code fully as is, and the following are some interesting code bits involved in this workflow:
createLogger(...)
- Creates and wraps an
IFileLogger
and adds some useful telemetry data to every entry
- Creates and wraps an
createContainerAndExecute(...)
- This is the core logic for running some action based on a local ODSP snapshot
getSnapshotFileContent(...)
- Reads a local ODSP snapshot from both JSON and binary formats for usage in
createContainerAndExecute(...)
- Reads a local ODSP snapshot from both JSON and binary formats for usage in
For an example of a consumption path that differs slightly to exportFile(...)
, see parseBundleAndExportFile(...)
. In addition to running the same logic as exportFile
method, it implements the logic around parsing a dynamically provided bundle path into an IFluidFileConverter
object.