vmware-labs / wasm-workers-server

🚀 Develop and run serverless applications on WebAssembly

Home Page:https://workers.wasmlabs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fetch from other workers and internals

Angelmmiguel opened this issue · comments

Is your feature request related to a problem? Please describe.

The fetch feature allows you to retrieve data from an external service. However, you cannot query other worker in your project. In some cases, you may need to call a different worker to get some information.

Describe the solution you'd like

I want that workers can perform calls other workers. This is useful to retrieve information from another endpoint before sending the data to the client. If we combine this with the ability of defining workers that are not exposed publicly (internal), you have a way to share an API endpoint only for internal usage.

The workers can call others based on the URL path, as they are calling an URL to the same domain (like /fixed or /api/v1/hello). By default, workers cannot call others unless you explicitly enable it via configuration:

name = "fetch"
version = "1"

[features]
[features.fetch]
allowed_domains = ["https://example.com"]
allowed_workers = ["/test"]

You can specify the all keyword to allow query any worker:

name = "fetch"
version = "1"

[features]
[features.fetch]
allowed_domains = ["https://example.com"]
allowed_workers = ["all"]

Internal workers

To define a worker that only other workers can query, use the internal property:

name = "fetch"
version = "1"
internal = true

[features]
[features.fetch]
allowed_domains = ["https://example.com"]

Describe alternatives you've considered

No response

Additional context

No response