mirror of
https://github.com/fluencelabs/examples
synced 2024-12-04 03:00:18 +00:00
add hello world
This commit is contained in:
parent
bc1240376a
commit
f5edd3cc3e
15
aqua-examples/hello-world-with-cli/.fluence/app.yaml
Normal file
15
aqua-examples/hello-world-with-cli/.fluence/app.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
# yaml-language-server: $schema=schemas/app.yaml.json
|
||||
|
||||
# Defines what exactly is already deployed and where. This config is automatically generated by Fluence CLI after you deploy services defined in [fluence.yaml](./fluence.md) using `fluence deploy` or remove previously deployed services using `fluence remove`. In most of the cases you are not expected to modify this by hand
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/app.md
|
||||
|
||||
version: 3
|
||||
services:
|
||||
hello_world:
|
||||
default:
|
||||
- blueprintId: f45f4c8bb62865402dbb6c027915fbf118bd51c13c38c22ab28a87c33139bd71
|
||||
serviceId: c98a0ce8-a0ea-43ad-9e31-8074867409b7
|
||||
peerId: 12D3KooWJd3HaMJ1rpLY1kQvcjRPEvnDwcXrH8mJvk7ypcZXqXGE
|
||||
keyPairName: auto-generated
|
||||
timestamp: 2023-02-13T06:23:39.880Z
|
@ -0,0 +1,15 @@
|
||||
export App
|
||||
|
||||
data ServiceIdsItem:
|
||||
blueprintId: string
|
||||
peerId: string
|
||||
serviceId: string
|
||||
|
||||
data Hello_worldDeploys:
|
||||
default: []ServiceIdsItem
|
||||
|
||||
data Services:
|
||||
hello_world: Hello_worldDeploys
|
||||
|
||||
service App("App"):
|
||||
services: -> Services
|
@ -0,0 +1,5 @@
|
||||
module HelloWorld declares *
|
||||
|
||||
service HelloWorld:
|
||||
hello_fluence() -> string
|
||||
hello_world() -> string
|
@ -0,0 +1,8 @@
|
||||
# yaml-language-server: $schema=schemas/project-secrets.yaml.json
|
||||
|
||||
# Defines project's secret keys that are used only in the scope of this particular Fluence project. You can manage project's keys using commands from `fluence key` group of commands
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/project-secrets.md
|
||||
|
||||
version: 0
|
||||
keyPairs: []
|
@ -0,0 +1,89 @@
|
||||
{
|
||||
"type": "object",
|
||||
"$id": "https://fluence.dev/schemas/app.yaml",
|
||||
"title": "app.yaml",
|
||||
"description": "Defines what exactly is already deployed and where. This config is automatically generated by Fluence CLI after you deploy services defined in [fluence.yaml](./fluence.md) using `fluence deploy` or remove previously deployed services using `fluence remove`. In most of the cases you are not expected to modify this by hand",
|
||||
"properties": {
|
||||
"services": {
|
||||
"type": "object",
|
||||
"title": "Services",
|
||||
"description": "A map of the deployed services",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"title": "Deployment results",
|
||||
"description": "Service names as keys and Deployment results as values",
|
||||
"additionalProperties": {
|
||||
"title": "A list of deployed services",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "Deployed service info",
|
||||
"properties": {
|
||||
"peerId": {
|
||||
"type": "string"
|
||||
},
|
||||
"serviceId": {
|
||||
"type": "string"
|
||||
},
|
||||
"blueprintId": {
|
||||
"type": "string"
|
||||
},
|
||||
"keyPairName": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"peerId",
|
||||
"serviceId",
|
||||
"blueprintId",
|
||||
"keyPairName"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
},
|
||||
"required": []
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "string",
|
||||
"description": "ISO timestamp of the time when the services were deployed"
|
||||
},
|
||||
"relays": {
|
||||
"title": "Relays",
|
||||
"description": "Relays that you can connect to to find the peers where services are deployed",
|
||||
"type": [
|
||||
"string",
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"title": "Network name",
|
||||
"enum": [
|
||||
"kras",
|
||||
"stage",
|
||||
"testnet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"title": "Multi addresses",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nullable": true
|
||||
},
|
||||
"version": {
|
||||
"type": "number",
|
||||
"const": 3
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"version",
|
||||
"services",
|
||||
"timestamp"
|
||||
]
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
{
|
||||
"type": "object",
|
||||
"$id": "https://fluence.dev/schemas/fluence-lock.yaml",
|
||||
"title": "fluence-lock.yaml",
|
||||
"description": "Defines a lock file for Fluence Project dependencies. When dependencies are installed - their exact versions are saved here.",
|
||||
"properties": {
|
||||
"npm": {
|
||||
"type": "object",
|
||||
"title": "npm dependencies",
|
||||
"description": "A map of the exact npm dependency versions. CLI ensures dependencies are installed each time you run aqua",
|
||||
"required": [],
|
||||
"nullable": true
|
||||
},
|
||||
"cargo": {
|
||||
"type": "object",
|
||||
"title": "Cargo dependencies",
|
||||
"description": "A map of the exact cargo dependency versions. CLI ensures dependencies are installed each time you run commands that depend on Marine or Marine REPL",
|
||||
"required": [],
|
||||
"nullable": true
|
||||
},
|
||||
"version": {
|
||||
"type": "number",
|
||||
"const": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"version"
|
||||
]
|
||||
}
|
@ -0,0 +1,272 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"services": {
|
||||
"title": "Services",
|
||||
"description": "A map with service names as keys and Service configs as values. You can have any number of services listed here (According to JSON schema they are called 'additionalProperties') as long as service name keys start with a lowercase letter and contain only letters numbers and underscores. You can use `fluence service add` command to add a service to this config",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"title": "Service config",
|
||||
"description": "Service names as keys (must start with a lowercase letter and contain only letters numbers and underscores) and Service config (defines where the service is and how to deploy it) as values",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"get": {
|
||||
"type": "string",
|
||||
"description": "Path to service directory or URL to the tar.gz archive with the service"
|
||||
},
|
||||
"deploy": {
|
||||
"type": "array",
|
||||
"title": "Deployment list",
|
||||
"description": "List of deployments for the particular service",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "Deployment",
|
||||
"description": "A small config for a particular deployment. You can have specific overrides for each and specific deployment properties like count, distribution, etc.",
|
||||
"properties": {
|
||||
"keyPairName": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The name of the Key Pair to use. It is resolved in the following order (from the lowest to the highest priority):\n1. \"defaultKeyPairName\" property from user-secrets.yaml\n1. \"defaultKeyPairName\" property from project-secrets.yaml\n1. \"keyPairName\" property from the top level of fluence.yaml\n1. \"keyPairName\" property from the \"services\" level of fluence.yaml\n1. \"keyPairName\" property from the individual \"deploy\" property item level of fluence.yaml"
|
||||
},
|
||||
"deployId": {
|
||||
"type": "string",
|
||||
"description": "This id can be used in Aqua to access actually deployed peer and service ids. The ID must start with a lowercase letter and contain only letters, numbers, and underscores."
|
||||
},
|
||||
"count": {
|
||||
"type": "number",
|
||||
"minimum": 1,
|
||||
"nullable": true,
|
||||
"description": "Number of services to deploy. Default: 1 or if \"peerIds\" property is provided - exactly the number of peerIds"
|
||||
},
|
||||
"peerId": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Peer id or peer id name to deploy to. Default: Peer ids from the \"relay\" property of fluence.yaml are selected for each deploy. Named peerIds can be listed in \"peerIds\" property of fluence.yaml)"
|
||||
},
|
||||
"peerIds": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"nullable": true,
|
||||
"title": "Peer ids",
|
||||
"description": "Peer ids or peer id names to deploy to. Overrides \"peerId\" property. Named peerIds can be listed in \"peerIds\" property of fluence.yaml)"
|
||||
},
|
||||
"distribution": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"even",
|
||||
"random"
|
||||
],
|
||||
"nullable": true,
|
||||
"description": "\"even\" distribution is used by default, means that the services will be deployed evenly across the listed peers. \"random\" distribution means that the services will be deployed randomly across the listed peers."
|
||||
},
|
||||
"overrideModules": {
|
||||
"type": "object",
|
||||
"title": "Overrides",
|
||||
"description": "A map of modules to override",
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"title": "Module overrides",
|
||||
"description": "Module names as keys and overrides for the module config as values",
|
||||
"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\")",
|
||||
"nullable": true
|
||||
},
|
||||
"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
|
||||
},
|
||||
"get": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Path to module directory or URL to the tar.gz archive with the module"
|
||||
}
|
||||
},
|
||||
"required": [],
|
||||
"nullable": true
|
||||
},
|
||||
"nullable": true,
|
||||
"required": []
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"deployId"
|
||||
]
|
||||
}
|
||||
},
|
||||
"keyPairName": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The name of the Key Pair to use. It is resolved in the following order (from the lowest to the highest priority):\n1. \"defaultKeyPairName\" property from user-secrets.yaml\n1. \"defaultKeyPairName\" property from project-secrets.yaml\n1. \"keyPairName\" property from the top level of fluence.yaml\n1. \"keyPairName\" property from the \"services\" level of fluence.yaml\n1. \"keyPairName\" property from the individual \"deploy\" property item level of fluence.yaml"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"get",
|
||||
"deploy"
|
||||
]
|
||||
},
|
||||
"required": [],
|
||||
"nullable": true
|
||||
},
|
||||
"relays": {
|
||||
"title": "Relays",
|
||||
"description": "List of Fluence Peer multi addresses or a name of the network. This multi addresses are used for connecting to the Fluence network when deploying. Peer ids from these addresses are also used for deploying in case if you don't specify \"peerId\" or \"peerIds\" property in the deployment config. Default: kras",
|
||||
"type": [
|
||||
"string",
|
||||
"array",
|
||||
"null"
|
||||
],
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"title": "Network name",
|
||||
"enum": [
|
||||
"kras",
|
||||
"stage",
|
||||
"testnet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "array",
|
||||
"title": "Multi addresses",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
],
|
||||
"nullable": true
|
||||
},
|
||||
"peerIds": {
|
||||
"title": "Peer ids",
|
||||
"description": "A map of named peerIds. Example:\n\nMY_PEER: 12D3KooWCMr9mU894i8JXAFqpgoFtx6qnV1LFPSfVc3Y34N4h4LS",
|
||||
"type": "object",
|
||||
"nullable": true,
|
||||
"required": [],
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"description": "Peer id names as keys and the actual peer ids as values"
|
||||
}
|
||||
},
|
||||
"keyPairName": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "The name of the Key Pair to use. It is resolved in the following order (from the lowest to the highest priority):\n1. \"defaultKeyPairName\" property from user-secrets.yaml\n1. \"defaultKeyPairName\" property from project-secrets.yaml\n1. \"keyPairName\" property from the top level of fluence.yaml\n1. \"keyPairName\" property from the \"services\" level of fluence.yaml\n1. \"keyPairName\" property from the individual \"deploy\" property item level of fluence.yaml"
|
||||
},
|
||||
"version": {
|
||||
"type": "number",
|
||||
"const": 2
|
||||
},
|
||||
"dependencies": {
|
||||
"type": "object",
|
||||
"title": "Dependencies",
|
||||
"nullable": true,
|
||||
"description": "A map of dependency versions",
|
||||
"properties": {
|
||||
"npm": {
|
||||
"type": "object",
|
||||
"title": "npm dependencies",
|
||||
"nullable": true,
|
||||
"description": "A map of npm dependency versions. CLI ensures dependencies are installed each time you run aqua",
|
||||
"required": []
|
||||
},
|
||||
"cargo": {
|
||||
"type": "object",
|
||||
"title": "Cargo dependencies",
|
||||
"nullable": true,
|
||||
"description": "A map of cargo dependency versions. CLI ensures dependencies are installed each time you run commands that depend on Marine or Marine REPL",
|
||||
"required": []
|
||||
}
|
||||
},
|
||||
"required": []
|
||||
},
|
||||
"aquaInputPath": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Path to the aqua file or directory with aqua files that you want to compile by default"
|
||||
},
|
||||
"aquaOutputTSPath": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Default compilation target dir from aqua to ts"
|
||||
},
|
||||
"aquaOutputJSPath": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Default compilation target dir from aqua to js. Overrides \"aquaOutputTSPath\" property"
|
||||
},
|
||||
"appTSPath": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Path to the directory where you want to generate app.ts after deployment. If you run registerApp() function in your typescript code after initializing FluenceJS client you will be able to access ids of the deployed services in aqua"
|
||||
},
|
||||
"appJSPath": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Path to the directory where you want to generate app.js after deployment. If you run registerApp() function in your javascript code after initializing FluenceJS client you will be able to access ids of the deployed services in aqua"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"version"
|
||||
],
|
||||
"$id": "https://fluence.dev/schemas/fluence.yaml",
|
||||
"title": "fluence.yaml",
|
||||
"description": "Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use `fluence init` command to generate a template for new Fluence project"
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
{
|
||||
"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"
|
||||
]
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
{
|
||||
"$id": "https://fluence.dev/schemas/project-secrets.yaml",
|
||||
"title": "project-secrets.yaml",
|
||||
"type": "object",
|
||||
"description": "Defines project's secret keys that are used only in the scope of this particular Fluence project. You can manage project's keys using commands from `fluence key` group of commands",
|
||||
"properties": {
|
||||
"keyPairs": {
|
||||
"title": "Key Pairs",
|
||||
"description": "Key Pairs available for the particular project",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"title": "Key Pair",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"peerId": {
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"publicKey": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"peerId",
|
||||
"secretKey",
|
||||
"publicKey",
|
||||
"name"
|
||||
]
|
||||
}
|
||||
},
|
||||
"defaultKeyPairName": {
|
||||
"type": "string",
|
||||
"nullable": true,
|
||||
"description": "Key pair with this name will be used for the deployment by default. You can override it with flags or by using keyPair properties in fluence.yaml"
|
||||
},
|
||||
"version": {
|
||||
"type": "number",
|
||||
"const": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"version",
|
||||
"keyPairs"
|
||||
]
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
{
|
||||
"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. For Fluence CLI, **service** - is a directory which contains this config. 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": {
|
||||
"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\")",
|
||||
"nullable": true
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"get"
|
||||
]
|
||||
},
|
||||
"properties": {
|
||||
"facade": {
|
||||
"type": "object",
|
||||
"title": "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\")",
|
||||
"nullable": true
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"get"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"facade"
|
||||
]
|
||||
},
|
||||
"version": {
|
||||
"type": "number",
|
||||
"const": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"version",
|
||||
"name",
|
||||
"modules"
|
||||
]
|
||||
}
|
10
aqua-examples/hello-world-with-cli/.fluence/tmp/deploy.json
Normal file
10
aqua-examples/hello-world-with-cli/.fluence/tmp/deploy.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"default": {
|
||||
"modules": [
|
||||
{
|
||||
"name": "hello_world",
|
||||
"path": "/Users/bebo/localdev/raw-examples/aqua-examples/hello-world-with-cli/services/modules/hello_world/target/wasm32-wasi/release/hello_world.wasm"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
9
aqua-examples/hello-world-with-cli/.gitignore
vendored
Normal file
9
aqua-examples/hello-world-with-cli/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
.fluence
|
||||
**/node_modules
|
||||
**/target/
|
||||
.repl_history
|
||||
.vscode/settings.json
|
||||
src/ts/src/aqua
|
||||
src/js/src/aqua
|
12
aqua-examples/hello-world-with-cli/fluence-lock.yaml
Normal file
12
aqua-examples/hello-world-with-cli/fluence-lock.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
# yaml-language-server: $schema=.fluence/schemas/fluence-lock.yaml.json
|
||||
|
||||
# Defines a lock file for Fluence Project dependencies. When dependencies are installed - their exact versions are saved here.
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence-lock.md
|
||||
|
||||
version: 0
|
||||
cargo:
|
||||
marine: 0.12.7
|
||||
npm:
|
||||
"@fluencelabs/aqua-lib": 0.6.0
|
||||
"@fluencelabs/aqua": 0.9.4
|
19
aqua-examples/hello-world-with-cli/fluence.yaml
Normal file
19
aqua-examples/hello-world-with-cli/fluence.yaml
Normal file
@ -0,0 +1,19 @@
|
||||
# yaml-language-server: $schema=.fluence/schemas/fluence.yaml.json
|
||||
|
||||
# Defines Fluence Project, most importantly - what exactly you want to deploy and how. You can use `fluence init` command to generate a template for new Fluence project
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/fluence.md
|
||||
|
||||
version: 2
|
||||
aquaInputPath: src/aqua/main.aqua
|
||||
dependencies:
|
||||
npm:
|
||||
"@fluencelabs/aqua-lib": 0.6.0
|
||||
"@fluencelabs/aqua": 0.9.4
|
||||
cargo:
|
||||
marine: 0.12.7
|
||||
services:
|
||||
hello_world:
|
||||
get: services
|
||||
deploy:
|
||||
- deployId: default
|
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "hello_world"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
name = "hello_world"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
marine-rs-sdk = "0.7.1"
|
||||
|
||||
[dev-dependencies]
|
||||
marine-rs-sdk-test = "0.8.1"
|
@ -0,0 +1,9 @@
|
||||
# yaml-language-server: $schema=../../../.fluence/schemas/module.yaml.json
|
||||
|
||||
# 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
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/module.md
|
||||
|
||||
version: 0
|
||||
type: rust
|
||||
name: hello_world
|
@ -0,0 +1,18 @@
|
||||
#![allow(non_snake_case)]
|
||||
use marine_rs_sdk::marine;
|
||||
use marine_rs_sdk::module_manifest;
|
||||
|
||||
module_manifest!();
|
||||
|
||||
pub fn main() {}
|
||||
|
||||
|
||||
#[marine]
|
||||
pub fn hello_world() -> String {
|
||||
format!("Hi, World")
|
||||
}
|
||||
|
||||
#[marine]
|
||||
pub fn hello_fluence() -> String {
|
||||
format!("Hi, Fluence")
|
||||
}
|
11
aqua-examples/hello-world-with-cli/services/service.yaml
Normal file
11
aqua-examples/hello-world-with-cli/services/service.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
# yaml-language-server: $schema=../.fluence/schemas/service.yaml.json
|
||||
|
||||
# Defines a [Marine service](https://fluence.dev/docs/build/concepts/#services), most importantly the modules that the service consists of. For Fluence CLI, **service** - is a directory which contains this config. You can use `fluence service new` command to generate a template for new service
|
||||
|
||||
# Documentation: https://github.com/fluencelabs/fluence-cli/tree/main/docs/configs/service.md
|
||||
|
||||
version: 0
|
||||
name: hello_world
|
||||
modules:
|
||||
facade:
|
||||
get: modules/hello_world
|
13
aqua-examples/hello-world-with-cli/src/aqua/main.aqua
Normal file
13
aqua-examples/hello-world-with-cli/src/aqua/main.aqua
Normal file
@ -0,0 +1,13 @@
|
||||
aqua Main
|
||||
|
||||
-- import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||
import App from "deployed.app.aqua"
|
||||
import HelloWorld from "services/hello_world.aqua"
|
||||
-- export App, hello_fluence
|
||||
|
||||
func hello_fluence() -> string:
|
||||
services <- App.services()
|
||||
on services.hello_world.default!.peerId:
|
||||
HelloWorld services.hello_world.default!.serviceId
|
||||
res <- HelloWorld.hello_fluence()
|
||||
<- res
|
Loading…
Reference in New Issue
Block a user