mirror of
https://github.com/fluencelabs/examples
synced 2025-04-24 18:22:15 +00:00
76 lines
3.8 KiB
JSON
76 lines
3.8 KiB
JSON
{
|
|
"type": "object",
|
|
"$id": "https://fluence.dev/schemas/module.yaml",
|
|
"title": "module.yaml",
|
|
"description": "Defines [Marine Module](https://fluence.dev/docs/build/concepts/#modules). For Fluence CLI, **module** - is a directory which contains this config and either a precompiled .wasm Marine module or a source code of the module written in Rust which can be compiled into a .wasm Marine module. You can use `fluence module new` command to generate a template for new module",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"enum": [
|
|
"rust",
|
|
"compiled"
|
|
],
|
|
"nullable": true,
|
|
"default": "compiled",
|
|
"description": "Module type \"compiled\" is for the precompiled modules. Module type \"rust\" is for the source code written in rust which can be compiled into a Marine module"
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"description": "\"name\" property from the Cargo.toml (for module type \"rust\") or name of the precompiled .wasm file (for module type \"compiled\")"
|
|
},
|
|
"maxHeapSize": {
|
|
"type": "string",
|
|
"nullable": true,
|
|
"description": "Max size of the heap that a module can allocate in format: [number][whitespace?][specificator?] where ? is an optional field and specificator is one from the following (case-insensitive):\n\nK, Kb - kilobyte\n\nKi, KiB - kibibyte\n\nM, Mb - megabyte\n\nMi, MiB - mebibyte\n\nG, Gb - gigabyte\n\nGi, GiB - gibibyte\n\nCurrent limit is 4 GiB"
|
|
},
|
|
"loggerEnabled": {
|
|
"type": "boolean",
|
|
"nullable": true,
|
|
"description": "Set true to allow module to use the Marine SDK logger"
|
|
},
|
|
"loggingMask": {
|
|
"type": "number",
|
|
"nullable": true,
|
|
"description": "Used for logging management. Example:\n```rust\nconst TARGET_MAP: [(&str, i64); 4] = [\n(\"instruction\", 1 << 1),\n(\"data_cache\", 1 << 2),\n(\"next_peer_pks\", 1 << 3),\n(\"subtree_complete\", 1 << 4),\n];\npub fn main() {\nuse std::collections::HashMap;\nuse std::iter::FromIterator;\n\nlet target_map = HashMap::from_iter(TARGET_MAP.iter().cloned());\n\nmarine_rs_sdk::WasmLoggerBuilder::new()\n .with_target_map(target_map)\n .build()\n .unwrap();\n}\n#[marine]\npub fn foo() {\nlog::info!(target: \"instruction\", \"this will print if (loggingMask & 1) != 0\");\nlog::info!(target: \"data_cache\", \"this will print if (loggingMask & 2) != 0\");\n}\n```\n"
|
|
},
|
|
"volumes": {
|
|
"type": "object",
|
|
"nullable": true,
|
|
"required": [],
|
|
"title": "Volumes",
|
|
"description": "A map of accessible files and their aliases. Aliases should be used in Marine module development because it's hard to know the full path to a file. (This property replaces the legacy \"mapped_dirs\" property so there is no need to duplicate the same paths in \"preopenedFiles\" dir)"
|
|
},
|
|
"preopenedFiles": {
|
|
"type": "array",
|
|
"title": "Preopened files",
|
|
"description": "A list of files and directories that this module could access with WASI",
|
|
"items": {
|
|
"type": "string"
|
|
},
|
|
"nullable": true
|
|
},
|
|
"envs": {
|
|
"type": "object",
|
|
"title": "Environment variables",
|
|
"nullable": true,
|
|
"required": [],
|
|
"description": "environment variables accessible by a particular module with standard Rust env API like this: std::env::var(IPFS_ADDR_ENV_NAME).\n\nPlease note that Marine adds three additional environment variables. Module environment variables could be examined with repl"
|
|
},
|
|
"mountedBinaries": {
|
|
"title": "Mounted binaries",
|
|
"type": "object",
|
|
"nullable": true,
|
|
"required": [],
|
|
"description": "A map of binary executable files that module is allowed to call. Example: curl: /usr/bin/curl"
|
|
},
|
|
"version": {
|
|
"type": "number",
|
|
"const": 0
|
|
}
|
|
},
|
|
"required": [
|
|
"version",
|
|
"name"
|
|
]
|
|
}
|