Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement support for service bindings #1026

Closed
threepointone opened this issue May 16, 2022 · 2 comments · Fixed by #906 or #1025
Closed

feat: implement support for service bindings #1026

threepointone opened this issue May 16, 2022 · 2 comments · Fixed by #906 or #1025
Assignees
Labels
enhancement New feature or request

Comments

@threepointone
Copy link
Contributor

As announced in https://blog.cloudflare.com/service-bindings-ga/, this issue tracks first class integration in wrangler.

@threepointone threepointone moved this to Untriaged in workers-sdk May 16, 2022
@threepointone threepointone moved this from Untriaged to In Review in workers-sdk May 16, 2022
@threepointone threepointone self-assigned this May 16, 2022
threepointone pushed a commit that referenced this issue May 16, 2022
This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:

```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now
```

And in your worker, you can call it like so:

```js
export default {
  fetch(req, env, ctx) {
    return env.MYWORKER.fetch(new Request("./some-path"));
  },
};
```

Fixes #1026
@threepointone threepointone added the enhancement New feature or request label May 16, 2022
threepointone pushed a commit that referenced this issue May 17, 2022
This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:

```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now
```

And in your worker, you can call it like so:

```js
export default {
  fetch(req, env, ctx) {
    return env.MYWORKER.fetch(new Request("./some-path"));
  },
};
```

Fixes #1026
threepointone pushed a commit that referenced this issue May 17, 2022
This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:

```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now
```

And in your worker, you can call it like so:

```js
export default {
  fetch(req, env, ctx) {
    return env.MYWORKER.fetch(new Request("./some-path"));
  },
};
```

Fixes #1026
threepointone pushed a commit that referenced this issue May 17, 2022
This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:

```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now
```

And in your worker, you can call it like so:

```js
export default {
  fetch(req, env, ctx) {
    return env.MYWORKER.fetch(new Request("http://domain/some-path"));
  },
};
```

Fixes #1026
threepointone added a commit that referenced this issue May 17, 2022
This adds experimental support for service bindings, aka worker-to-worker bindings. It's lets you "call" a worker from another worker, without incurring any network cost, and (ideally) with much less latency. To use it, define a `[services]` field in `wrangler.toml`, which is a map of bindings to worker names (and environment). Let's say you already have a worker named "my-worker" deployed. In another worker's configuration, you can create a service binding to it like so:

```toml
[[services]]
binding = "MYWORKER"
service = "my-worker"
environment = "production" # optional, defaults to the worker's `default_environment` for now
```

And in your worker, you can call it like so:

```js
export default {
  fetch(req, env, ctx) {
    return env.MYWORKER.fetch(new Request("http://domain/some-path"));
  },
};
```

Fixes #1026

Co-authored-by: Daniel Rivas <[email protected]>
Repository owner moved this from In Review to Done in workers-sdk May 17, 2022
@sodabrew
Copy link

Hi! I want to call out that this API remains undocumented at api.cloudflare.com, which is ostensibly blocking my PR to cloudflare-go: cloudflare/cloudflare-go#849

Would greatly appreciate API docs for use cases where a customer is not using wrangler.

@threepointone
Copy link
Contributor Author

Hi! I'll route your request to the team, we're not directly in charge of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants