{
  "type": "object",
  "$id": "https://fluence.dev/schemas/service.yaml",
  "title": "service.yaml",
  "description": "Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), most importantly the modules that the service consists of. You can use `fluence service new` command to generate a template for new service",
  "properties": {
    "name": {
      "type": "string",
      "description": "Service name. Currently it is used for the service name only when you add service to fluence.yaml using \"add\" command. But this name can be overridden to any other with the --name flag or manually in fluence.yaml"
    },
    "modules": {
      "title": "Modules",
      "description": "Service must have a facade module. Each module properties can be overridden by the same properties in the service config",
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "title": "Module",
        "properties": {
          "get": {
            "type": "string",
            "description": "Either path to the module directory or URL to the tar.gz archive which contains the content of the module directory"
          },
          "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"
          },
          "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"
          }
        },
        "required": [
          "get"
        ]
      },
      "properties": {
        "facade": {
          "type": "object",
          "title": "Module",
          "properties": {
            "get": {
              "type": "string",
              "description": "Either path to the module directory or URL to the tar.gz archive which contains the content of the module directory"
            },
            "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"
            },
            "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"
            }
          },
          "required": [
            "get"
          ]
        }
      },
      "required": [
        "facade"
      ]
    },
    "version": {
      "type": "number",
      "const": 0
    }
  },
  "required": [
    "version",
    "name",
    "modules"
  ]
}
