diff --git a/examples/c/c-default/wit/component-name.wit b/examples/c/c-default/wit/component-name.wit index 0cfdb45..f66441a 100644 --- a/examples/c/c-default/wit/component-name.wit +++ b/examples/c/c-default/wit/component-name.wit @@ -8,7 +8,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/examples/c/c-example-http/wit/component-name.wit b/examples/c/c-example-http/wit/component-name.wit index 6a62103..b5bbd1f 100644 --- a/examples/c/c-example-http/wit/component-name.wit +++ b/examples/c/c-example-http/wit/component-name.wit @@ -9,7 +9,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/examples/go/go-default-minimal/go.sum b/examples/go/go-default-minimal/go.sum index 63a3b41..9dd8eef 100644 --- a/examples/go/go-default-minimal/go.sum +++ b/examples/go/go-default-minimal/go.sum @@ -1,2 +1,2 @@ -github.com/golemcloud/golem-go v0.7.0 h1:8zpNeAtEDJsJllqHUmjji/lyplSJ0kI3v7vN97/N8zs= -github.com/golemcloud/golem-go v0.7.0/go.mod h1:VLL22qVo5R2+jGLO43tLPpPjf2WrA6B7GQoqXKnSODo= +github.com/golemcloud/golem-go v1.1.0 h1:By+OBuRu4c3WTuf2OKh71yY7rgOyLXzUgr7Y+98BjGk= +github.com/golemcloud/golem-go v1.1.0/go.mod h1:VLL22qVo5R2+jGLO43tLPpPjf2WrA6B7GQoqXKnSODo= diff --git a/examples/go/go-default/go.sum b/examples/go/go-default/go.sum index 63a3b41..9dd8eef 100644 --- a/examples/go/go-default/go.sum +++ b/examples/go/go-default/go.sum @@ -1,2 +1,2 @@ -github.com/golemcloud/golem-go v0.7.0 h1:8zpNeAtEDJsJllqHUmjji/lyplSJ0kI3v7vN97/N8zs= -github.com/golemcloud/golem-go v0.7.0/go.mod h1:VLL22qVo5R2+jGLO43tLPpPjf2WrA6B7GQoqXKnSODo= +github.com/golemcloud/golem-go v1.1.0 h1:By+OBuRu4c3WTuf2OKh71yY7rgOyLXzUgr7Y+98BjGk= +github.com/golemcloud/golem-go v1.1.0/go.mod h1:VLL22qVo5R2+jGLO43tLPpPjf2WrA6B7GQoqXKnSODo= diff --git a/examples/go/go-default/wit/component-name.wit b/examples/go/go-default/wit/component-name.wit index 9c5377c..65721e9 100644 --- a/examples/go/go-default/wit/component-name.wit +++ b/examples/go/go-default/wit/component-name.wit @@ -8,7 +8,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/examples/go/go-multi-rpc/README.md b/examples/go/go-multi-rpc/README.md index 45fadf8..73a084f 100644 --- a/examples/go/go-multi-rpc/README.md +++ b/examples/go/go-multi-rpc/README.md @@ -44,7 +44,7 @@ In the example 3 simple counter components are defined, which can be familiar fr - **component one** delegates the add call to **component two** and **three** too, - and **component two** delegates to **component three**. -In both cases the _current worker name_ will be used as _target worker name_ too. +In both cases the _current worker name_ will be used as _target worker name_ too. Apart from _worker name_, remote calls also require the **target components' deployed ID**. For this the example uses environment variables, and uses the `lib/cfg` subpackage (which is shared between the components) to extract it. @@ -92,7 +92,7 @@ After adding a new component the `build` command will also include it. ## Using Worker to Worker RPC calls -### Under the hood +### Under the hood Under the hood the _magefile_ commands below (and for build) use generic `golem-cli stubgen` subcommands: - `golem-cli stubgen build` for creating remote call _stub WIT_ definitions and _WASM components_ for the stubs @@ -142,7 +142,7 @@ interface component-one-api { world component-one { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies @@ -176,7 +176,7 @@ import ( func (i *Impl) Add(value uint64) { std.Init(std.Packages{Os: true, NetHttp: true}) - + componentTwo := binding.NewComponentTwoApi(binding.GolemRpc0_1_0_TypesUri{Value: "uri"}) defer componentTwo.Drop() componentTwo.BlockingAdd(value) diff --git a/examples/go/go-multi-rpc/component-template/component/wit/component.wit b/examples/go/go-multi-rpc/component-template/component/wit/component.wit index 1e7b6cf..8346aa4 100644 --- a/examples/go/go-multi-rpc/component-template/component/wit/component.wit +++ b/examples/go/go-multi-rpc/component-template/component/wit/component.wit @@ -9,7 +9,7 @@ interface comp-name-api { world comp-name { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/components/component-one/wit/component-one.wit b/examples/go/go-multi-rpc/components/component-one/wit/component-one.wit index d9befa1..e12ba38 100644 --- a/examples/go/go-multi-rpc/components/component-one/wit/component-one.wit +++ b/examples/go/go-multi-rpc/components/component-one/wit/component-one.wit @@ -9,7 +9,7 @@ interface component-one-api { world component-one { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-three/component-three.wit b/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-three/component-three.wit index 7bd3d9c..afa68e9 100644 --- a/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-three/component-three.wit +++ b/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-three/component-three.wit @@ -9,7 +9,7 @@ interface component-three-api { world component-three { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-two/component-two.wit b/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-two/component-two.wit index bb81e6d..906a02a 100644 --- a/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-two/component-two.wit +++ b/examples/go/go-multi-rpc/components/component-one/wit/deps/pack-ns_component-two/component-two.wit @@ -9,7 +9,7 @@ interface component-two-api { world component-two { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/components/component-three/wit/component-three.wit b/examples/go/go-multi-rpc/components/component-three/wit/component-three.wit index 7bd3d9c..afa68e9 100644 --- a/examples/go/go-multi-rpc/components/component-three/wit/component-three.wit +++ b/examples/go/go-multi-rpc/components/component-three/wit/component-three.wit @@ -9,7 +9,7 @@ interface component-three-api { world component-three { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/components/component-two/wit/component-two.wit b/examples/go/go-multi-rpc/components/component-two/wit/component-two.wit index 6ed354b..19cb60c 100644 --- a/examples/go/go-multi-rpc/components/component-two/wit/component-two.wit +++ b/examples/go/go-multi-rpc/components/component-two/wit/component-two.wit @@ -9,7 +9,7 @@ interface component-two-api { world component-two { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/components/component-two/wit/deps/pack-ns_component-three/component-three.wit b/examples/go/go-multi-rpc/components/component-two/wit/deps/pack-ns_component-three/component-three.wit index 7bd3d9c..afa68e9 100644 --- a/examples/go/go-multi-rpc/components/component-two/wit/deps/pack-ns_component-three/component-three.wit +++ b/examples/go/go-multi-rpc/components/component-two/wit/deps/pack-ns_component-three/component-three.wit @@ -9,7 +9,7 @@ interface component-three-api { world component-three { // Golem dependencies - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; // WASI dependencies diff --git a/examples/go/go-multi-rpc/go.sum b/examples/go/go-multi-rpc/go.sum index 95966ad..6c84d28 100644 --- a/examples/go/go-multi-rpc/go.sum +++ b/examples/go/go-multi-rpc/go.sum @@ -1,5 +1,5 @@ -github.com/golemcloud/golem-go v0.7.0 h1:8zpNeAtEDJsJllqHUmjji/lyplSJ0kI3v7vN97/N8zs= -github.com/golemcloud/golem-go v0.7.0/go.mod h1:VLL22qVo5R2+jGLO43tLPpPjf2WrA6B7GQoqXKnSODo= +github.com/golemcloud/golem-go v1.1.0 h1:By+OBuRu4c3WTuf2OKh71yY7rgOyLXzUgr7Y+98BjGk= +github.com/golemcloud/golem-go v1.1.0/go.mod h1:VLL22qVo5R2+jGLO43tLPpPjf2WrA6B7GQoqXKnSODo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= diff --git a/examples/js/js-default-minimal/rollup.config.mjs b/examples/js/js-default-minimal/rollup.config.mjs index 156d854..5225a1f 100644 --- a/examples/js/js-default-minimal/rollup.config.mjs +++ b/examples/js/js-default-minimal/rollup.config.mjs @@ -1,11 +1,11 @@ import resolve from "@rollup/plugin-node-resolve"; export default { - input: 'src/main.js', - output: { - file: 'out/main.js', - format: 'esm' - }, - external: ["golem:api/host@0.2.0"], - plugins: [resolve()], -}; \ No newline at end of file + input: "src/main.js", + output: { + file: "out/main.js", + format: "esm", + }, + external: ["golem:api/host@1.1.0"], + plugins: [resolve()], +}; diff --git a/examples/js/js-default/rollup.config.mjs b/examples/js/js-default/rollup.config.mjs index 156d854..5225a1f 100644 --- a/examples/js/js-default/rollup.config.mjs +++ b/examples/js/js-default/rollup.config.mjs @@ -1,11 +1,11 @@ import resolve from "@rollup/plugin-node-resolve"; export default { - input: 'src/main.js', - output: { - file: 'out/main.js', - format: 'esm' - }, - external: ["golem:api/host@0.2.0"], - plugins: [resolve()], -}; \ No newline at end of file + input: "src/main.js", + output: { + file: "out/main.js", + format: "esm", + }, + external: ["golem:api/host@1.1.0"], + plugins: [resolve()], +}; diff --git a/examples/js/js-default/wit/main.wit b/examples/js/js-default/wit/main.wit index 0dfef32..1271341 100644 --- a/examples/js/js-default/wit/main.wit +++ b/examples/js/js-default/wit/main.wit @@ -8,7 +8,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/examples/js/js-example-fetch/rollup.config.mjs b/examples/js/js-example-fetch/rollup.config.mjs index 156d854..5225a1f 100644 --- a/examples/js/js-example-fetch/rollup.config.mjs +++ b/examples/js/js-example-fetch/rollup.config.mjs @@ -1,11 +1,11 @@ import resolve from "@rollup/plugin-node-resolve"; export default { - input: 'src/main.js', - output: { - file: 'out/main.js', - format: 'esm' - }, - external: ["golem:api/host@0.2.0"], - plugins: [resolve()], -}; \ No newline at end of file + input: "src/main.js", + output: { + file: "out/main.js", + format: "esm", + }, + external: ["golem:api/host@1.1.0"], + plugins: [resolve()], +}; diff --git a/examples/js/js-example-fetch/wit/main.wit b/examples/js/js-example-fetch/wit/main.wit index 24d7fd6..6444823 100644 --- a/examples/js/js-example-fetch/wit/main.wit +++ b/examples/js/js-example-fetch/wit/main.wit @@ -8,6 +8,6 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; export api; } diff --git a/examples/python/python-default/wit/component-name.wit b/examples/python/python-default/wit/component-name.wit index 0cfdb45..f66441a 100644 --- a/examples/python/python-default/wit/component-name.wit +++ b/examples/python/python-default/wit/component-name.wit @@ -8,7 +8,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/examples/ts/ts-default-minimal/rollup.config.mjs b/examples/ts/ts-default-minimal/rollup.config.mjs index e1cb34a..c421b4c 100644 --- a/examples/ts/ts-default-minimal/rollup.config.mjs +++ b/examples/ts/ts-default-minimal/rollup.config.mjs @@ -2,11 +2,11 @@ import typescript from "rollup-plugin-typescript2"; import resolve from "@rollup/plugin-node-resolve"; export default { - input: 'src/main.ts', - output: { - file: 'out/main.js', - format: 'esm' - }, - external: ["golem:api/host@0.2.0"], - plugins: [resolve(), typescript()], -}; \ No newline at end of file + input: "src/main.ts", + output: { + file: "out/main.js", + format: "esm", + }, + external: ["golem:api/host@1.1.0"], + plugins: [resolve(), typescript()], +}; diff --git a/examples/ts/ts-default/rollup.config.mjs b/examples/ts/ts-default/rollup.config.mjs index e1cb34a..c421b4c 100644 --- a/examples/ts/ts-default/rollup.config.mjs +++ b/examples/ts/ts-default/rollup.config.mjs @@ -2,11 +2,11 @@ import typescript from "rollup-plugin-typescript2"; import resolve from "@rollup/plugin-node-resolve"; export default { - input: 'src/main.ts', - output: { - file: 'out/main.js', - format: 'esm' - }, - external: ["golem:api/host@0.2.0"], - plugins: [resolve(), typescript()], -}; \ No newline at end of file + input: "src/main.ts", + output: { + file: "out/main.js", + format: "esm", + }, + external: ["golem:api/host@1.1.0"], + plugins: [resolve(), typescript()], +}; diff --git a/examples/ts/ts-default/wit/main.wit b/examples/ts/ts-default/wit/main.wit index 0dfef32..1271341 100644 --- a/examples/ts/ts-default/wit/main.wit +++ b/examples/ts/ts-default/wit/main.wit @@ -8,7 +8,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/examples/ts/ts-example-fetch/rollup.config.mjs b/examples/ts/ts-example-fetch/rollup.config.mjs index e1cb34a..c421b4c 100644 --- a/examples/ts/ts-example-fetch/rollup.config.mjs +++ b/examples/ts/ts-example-fetch/rollup.config.mjs @@ -2,11 +2,11 @@ import typescript from "rollup-plugin-typescript2"; import resolve from "@rollup/plugin-node-resolve"; export default { - input: 'src/main.ts', - output: { - file: 'out/main.js', - format: 'esm' - }, - external: ["golem:api/host@0.2.0"], - plugins: [resolve(), typescript()], -}; \ No newline at end of file + input: "src/main.ts", + output: { + file: "out/main.js", + format: "esm", + }, + external: ["golem:api/host@1.1.0"], + plugins: [resolve(), typescript()], +}; diff --git a/examples/ts/ts-example-fetch/wit/main.wit b/examples/ts/ts-example-fetch/wit/main.wit index 24d7fd6..6444823 100644 --- a/examples/ts/ts-example-fetch/wit/main.wit +++ b/examples/ts/ts-example-fetch/wit/main.wit @@ -8,6 +8,6 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; export api; } diff --git a/examples/ts/ts-multi-rpc/README.md b/examples/ts/ts-multi-rpc/README.md new file mode 100644 index 0000000..5ae8cb8 --- /dev/null +++ b/examples/ts/ts-multi-rpc/README.md @@ -0,0 +1,205 @@ +# Golem TypeScript Example with Multiple Components and Worker to Worker RPC Communication + +## Building + +The project uses a custom Typescript build file: [build.ts](build.ts), ran through [tsx](https://nodejs.org/en/learn/getting-started/nodejs-with-typescript#running-typescript-code-with-tsx). The `build.ts` file handles **generating stubs**, **building**, **deploying** and **testing**; and also handles _"up to date" checks_ based on _modification times_. Build commands can be run using `npx tsx build.ts ` (or without _npx_, if _tsx_ is available globally), but all commands have `npm run ` wrappers, in the examples we will use the latter. + +To see the available commands use: + +```shell +npm run help + +> help +> npx tsx build.ts + +Available commands: + fmt: format using prettier + lint: lint project using eslint + fix: format, lint and fix project using prettier and eslint + build: build all components + updateRpcStubs: update stubs based on componentDependencies + generateNewComponent: generates new component from template, expects + deploy: deploy (create or update) all components + deployComponent: deploy (create or update) the specified component, expects + test: run tests + clean: clean outputs and generated code +``` + +For building the project for the first time (or after `clean`) use the following commands: + +```shell +npm install +npm run updateRpcStubs +npm run build +``` + +After this, using the `build` command is enough, unless there are changes in the RPC dependencies, +in that case `updateRpcStubs` is needed again. + +Note that multiple commands can be used in one invocation (if they do not have parameters), e.g.: + +```shell +npm run updateRpcStubs build +``` + +The final components that are usable by golem are placed in the `out/components` folder. + +## Deploying and testing the example + +In the example 3 simple counter components are defined, which can be familiar from the smaller examples. To showcase the remote calls, the counters `add` functions are connected, apart from increasing their own counter: + +- **component one** delegates the add call to **component two** and **three** too, +- and **component two** delegates to **component three**. + +In both cases the _current worker name_ will be used as _target worker name_ too. + +Apart from _worker name_, remote calls also require the **target components' deployed ID**. For this the example uses environment variables, and uses the `lib/cfg` subpackage (which is shared between the components) to extract it. + +The examples assume a configured default `golem-cli` profile, and will use that. + +To test, first we have to build the project as seen in the above: + +```shell +npm run updateRpcStubs build +``` + +Then we can deploy our components with `golem-cli`, for which a wrapper command is provided: + +```shell +npm run deploy +``` + +Note that `npm run deployComponent ` can be used to deploy (or update) only one component. + +Once the components are deployed, a simple example integration test suite can be used to test the components. + +Note that after deploy it might still take some time for the components to be prepared inside golem, which for TypeScript can take about 30-50 seconds, so invoking workers or running the tests immediately after deploy might have to wait for this preparation. + +Once the components are deployed, a simple example integration test suite can be used to test the components. +The tests are in the [/test/integration.test.ts](/test/integration.test.ts) test file, and can be run with: + +```shell +npm run test +``` + +The first test simply tests if our components metadata is available through `golem-cli component get`. + +The second test will: + +- get the _component URNs_ with `golem-cli component get` +- generates a _random worker name_, so our tests are starting from a clean state +- adds 1 - 1 worker for component one and component two with the required _environment variables_ containing the other workers' _component ids_ +- then makes various component invocations with `golem-cli worker invoke-and-await` and tests if the counters - after increments - are holding the right value according to the delegated `add` function calls. + +## Adding Components + +Use the `generateNewComponent` command to add new components to the project: + +```shell +npm run generateNewComponent component-four +``` + +The above will create a new component in the `src/components/component-four` directory based on the template at [/component-template/component](/component-template/component). + +After adding a new component the `build` command will also include it. + +## Using Worker to Worker RPC calls + +### Under the hood + +Under the hood the `build.ts` commands below use generic `golem-cli stubgen` subcommands: + +- `golem-cli stubgen build` for creating remote call _stub WIT_ definitions and _WASM components_ for the stubs +- `golem-cli stubgen add-stub-dependency` for adding the _stub WIT_ definitions to a _component's WIT_ dependencies +- `golem-cli stubgen compose` for _composing_ components with the stub components + +### Commands and required manual steps + +The dependencies between components are defined in the [build-config.ts](build-config.ts) build script: + +```typescript +// Defines worker to worker RPC dependencies +const componentDependencies: Dependencies = { + "component-one": ["component-two", "component-three"], + "component-two": ["component-three"], +}; +``` + +After changing dependencies the `updateRpcStubs` command can be used to create the necessary stubs: + +```shell +npm run updateRpcStubs +``` + +The command will create stubs for the dependency projects in the `/out/stub` directory and will also place the required stub _WIT_ interfaces on the dependant component's `wit/deps` directory. + +To actually use the dependencies in a project it also has to be manually imported in the component's world. + +E.g. with the above definitions the following import has to be **manually** added to `/components/component-one/wit/component-one.wit`: + +```wit +import pack-ns:component-two-stub; +import pack-ns:component-three-stub; +``` + +So the component definition should like similar to this: + +```wit +package pack-ns:component-one; + +// See https://component-model.bytecodealliance.org/design/wit.html for more details about the WIT syntax + +interface component-one-api { + add: func(value: u64); + get: func() -> u64; +} + +world component-one { + // Golem dependencies + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; + + // WASI dependencies + import wasi:blobstore/blobstore; + // . + // . + // . + // other dependencies + import wasi:sockets/instance-network@0.2.0; + + // Project Component dependencies + import pack-ns:component-two-stub; + import pack-ns:component-three-stub; + + export component-one-api; +} +``` + +After this `build` command can be used to update bindings, which now should include the +required functions for calling other components. + +Here's an example that delegates the `Add` call to another component and waits for the result: + +```go +import {ComponentTwoApi} from "./generated/component-two"; +import {ComponentThreeApi} from "golem:component-three-stub/stub-component-three"; + +let state = BigInt(0); + +export const componentTwoApi: ComponentTwoApi = { + add(value: bigint) { + console.log(`Adding ${value} to the counter`); + + console.log("Calling component three"); + const componentThree = new ComponentThreeApi({value: "urn"}); + componentThree.blockingAdd(value); + + state += value; + }, + get() { + return state; + } +}; +``` + +Once a remote call is in place, the `build` command will also compose the stub components into the caller component. diff --git a/examples/ts/ts-multi-rpc/component-template/component/wit/main.wit.template b/examples/ts/ts-multi-rpc/component-template/component/wit/main.wit.template index a1c84f4..d815e99 100644 --- a/examples/ts/ts-multi-rpc/component-template/component/wit/main.wit.template +++ b/examples/ts/ts-multi-rpc/component-template/component/wit/main.wit.template @@ -8,6 +8,13 @@ interface comp-name-api { } world comp-name { +<<<<<<< HEAD +======= + // Golem dependencies + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; + +>>>>>>> main // WASI dependencies import wasi:blobstore/blobstore; import wasi:blobstore/container; diff --git a/examples/ts/ts-multi-rpc/src/components/component-one/main.ts b/examples/ts/ts-multi-rpc/src/components/component-one/main.ts index a42ab97..ff04584 100644 --- a/examples/ts/ts-multi-rpc/src/components/component-one/main.ts +++ b/examples/ts/ts-multi-rpc/src/components/component-one/main.ts @@ -2,7 +2,7 @@ import { ComponentOneApi } from "./binding/component-one"; import { ComponentTwoApi } from "pack-ns:component-two-stub/stub-component-two"; import { ComponentThreeApi } from "pack-ns:component-three-stub/stub-component-three"; import * as cfg from "../../lib/cfg"; -import { getSelfMetadata } from "golem:api/host@0.2.0"; +import { getSelfMetadata } from "golem:api/host@1.1.0"; let state = BigInt(0); diff --git a/examples/ts/ts-multi-rpc/src/components/component-one/wit/deps/pack-ns_component-three/main.wit b/examples/ts/ts-multi-rpc/src/components/component-one/wit/deps/pack-ns_component-three/main.wit new file mode 100644 index 0000000..f6183b8 --- /dev/null +++ b/examples/ts/ts-multi-rpc/src/components/component-one/wit/deps/pack-ns_component-three/main.wit @@ -0,0 +1,39 @@ +package pack-ns:component-three; + +// See https://component-model.bytecodealliance.org/design/wit.html for more details about the WIT syntax + +interface component-three-api { + add: func(value: u64); + get: func() -> u64; +} + +world component-three { + // Golem dependencies + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; + + // WASI dependencies + import wasi:blobstore/blobstore; + import wasi:blobstore/container; + import wasi:cli/environment@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:http/types@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/poll@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:logging/logging; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:sockets/instance-network@0.2.0; + + // Project Component dependencies + // import pack-ns:name-stub/stub-name; + + export component-three-api; +} diff --git a/examples/ts/ts-multi-rpc/src/components/component-one/wit/deps/pack-ns_component-two/main.wit b/examples/ts/ts-multi-rpc/src/components/component-one/wit/deps/pack-ns_component-two/main.wit new file mode 100644 index 0000000..dd8b3ac --- /dev/null +++ b/examples/ts/ts-multi-rpc/src/components/component-one/wit/deps/pack-ns_component-two/main.wit @@ -0,0 +1,39 @@ +package pack-ns:component-two; + +// See https://component-model.bytecodealliance.org/design/wit.html for more details about the WIT syntax + +interface component-two-api { + add: func(value: u64); + get: func() -> u64; +} + +world component-two { + // Golem dependencies + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; + + // WASI dependencies + import wasi:blobstore/blobstore; + import wasi:blobstore/container; + import wasi:cli/environment@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:http/types@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/poll@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:logging/logging; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:sockets/instance-network@0.2.0; + + // Project Component dependencies + import pack-ns:component-three-stub/stub-component-three; + + export component-two-api; +} diff --git a/examples/ts/ts-multi-rpc/src/components/component-one/wit/main.wit b/examples/ts/ts-multi-rpc/src/components/component-one/wit/main.wit index 09b9345..401549c 100644 --- a/examples/ts/ts-multi-rpc/src/components/component-one/wit/main.wit +++ b/examples/ts/ts-multi-rpc/src/components/component-one/wit/main.wit @@ -9,7 +9,12 @@ interface component-one-api { world component-one { // Golem dependencies +<<<<<<< HEAD import golem:api/host@0.2.0; +======= + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; +>>>>>>> main // WASI dependencies import wasi:blobstore/blobstore; diff --git a/examples/ts/ts-multi-rpc/src/components/component-three/wit/main.wit b/examples/ts/ts-multi-rpc/src/components/component-three/wit/main.wit index 9f9016e..60e1695 100644 --- a/examples/ts/ts-multi-rpc/src/components/component-three/wit/main.wit +++ b/examples/ts/ts-multi-rpc/src/components/component-three/wit/main.wit @@ -9,7 +9,12 @@ interface component-three-api { world component-three { // Golem dependencies +<<<<<<< HEAD import golem:api/host@0.2.0; +======= + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; +>>>>>>> main // WASI dependencies import wasi:blobstore/blobstore; diff --git a/examples/ts/ts-multi-rpc/src/components/component-two/main.ts b/examples/ts/ts-multi-rpc/src/components/component-two/main.ts index 381c5fd..353fb3b 100644 --- a/examples/ts/ts-multi-rpc/src/components/component-two/main.ts +++ b/examples/ts/ts-multi-rpc/src/components/component-two/main.ts @@ -1,7 +1,7 @@ import { ComponentTwoApi } from "./binding/component-two"; import { ComponentThreeApi } from "pack-ns:component-three-stub/stub-component-three"; import * as cfg from "../../lib/cfg"; -import { getSelfMetadata } from "golem:api/host@0.2.0"; +import { getSelfMetadata } from "golem:api/host@1.1.0"; let state = BigInt(0); diff --git a/examples/ts/ts-multi-rpc/src/components/component-two/wit/deps/pack-ns_component-three/main.wit b/examples/ts/ts-multi-rpc/src/components/component-two/wit/deps/pack-ns_component-three/main.wit new file mode 100644 index 0000000..f6183b8 --- /dev/null +++ b/examples/ts/ts-multi-rpc/src/components/component-two/wit/deps/pack-ns_component-three/main.wit @@ -0,0 +1,39 @@ +package pack-ns:component-three; + +// See https://component-model.bytecodealliance.org/design/wit.html for more details about the WIT syntax + +interface component-three-api { + add: func(value: u64); + get: func() -> u64; +} + +world component-three { + // Golem dependencies + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; + + // WASI dependencies + import wasi:blobstore/blobstore; + import wasi:blobstore/container; + import wasi:cli/environment@0.2.0; + import wasi:clocks/wall-clock@0.2.0; + import wasi:clocks/monotonic-clock@0.2.0; + import wasi:filesystem/preopens@0.2.0; + import wasi:filesystem/types@0.2.0; + import wasi:http/types@0.2.0; + import wasi:http/outgoing-handler@0.2.0; + import wasi:io/error@0.2.0; + import wasi:io/poll@0.2.0; + import wasi:io/streams@0.2.0; + import wasi:logging/logging; + import wasi:random/random@0.2.0; + import wasi:random/insecure@0.2.0; + import wasi:random/insecure-seed@0.2.0; + import wasi:sockets/ip-name-lookup@0.2.0; + import wasi:sockets/instance-network@0.2.0; + + // Project Component dependencies + // import pack-ns:name-stub/stub-name; + + export component-three-api; +} diff --git a/examples/ts/ts-multi-rpc/src/components/component-two/wit/main.wit b/examples/ts/ts-multi-rpc/src/components/component-two/wit/main.wit index 0eacc11..25c050e 100644 --- a/examples/ts/ts-multi-rpc/src/components/component-two/wit/main.wit +++ b/examples/ts/ts-multi-rpc/src/components/component-two/wit/main.wit @@ -9,7 +9,12 @@ interface component-two-api { world component-two { // Golem dependencies +<<<<<<< HEAD import golem:api/host@0.2.0; +======= + import golem:api/host@1.1.0; + import golem:rpc/types@0.1.0; +>>>>>>> main // WASI dependencies import wasi:blobstore/blobstore; diff --git a/examples/zig/zig-default/wit/component-name.wit b/examples/zig/zig-default/wit/component-name.wit index a812387..98ed474 100644 --- a/examples/zig/zig-default/wit/component-name.wit +++ b/examples/zig/zig-default/wit/component-name.wit @@ -6,7 +6,7 @@ interface api { } world component-name { - import golem:api/host@0.2.0; + import golem:api/host@1.1.0; import golem:rpc/types@0.1.0; import wasi:blobstore/blobstore; diff --git a/src/lib.rs b/src/lib.rs index 4cf30ac..1530bff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -267,6 +267,7 @@ fn parse_example( let mut wit_deps: Vec = vec![]; if metadata.requires_golem_host_wit.unwrap_or(false) { wit_deps.push(Path::new("golem").to_path_buf()); + wit_deps.push(Path::new("golem-1.1").to_path_buf()); wit_deps.push(Path::new("wasm-rpc").to_path_buf()); } if metadata.requires_wasi.unwrap_or(false) {