Skip to content

Commit 44d0731

Browse files
committed
Remove RPC content
1 parent 752b9ac commit 44d0731

File tree

2 files changed

+51
-62
lines changed

2 files changed

+51
-62
lines changed

src/content/docs/workers/runtime-apis/rpc/index.mdx

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ title: Remote-procedure call (RPC)
44
head: []
55
description: The built-in, JavaScript-native RPC system built into Workers and
66
Durable Objects.
7+
78
---
89

9-
import { DirectoryListing, Render, Stream, WranglerConfig } from "~/components";
10+
import { DirectoryListing, Render, Stream, WranglerConfig } from "~/components"
1011

1112
:::note
1213
To use RPC, [define a compatibility date](/workers/configuration/compatibility-dates) of `2024-04-03` or higher, or include `rpc` in your [compatibility flags](/workers/configuration/compatibility-flags/#nodejs-compatibility-flag).
1314
:::
1415

1516
Workers provide a built-in, JavaScript-native [RPC (Remote Procedure Call)](https://en.wikipedia.org/wiki/Remote_procedure_call) system, allowing you to:
1617

17-
- Define public methods on your Worker that can be called by other Workers on the same Cloudflare account, via [Service Bindings](/workers/runtime-apis/bindings/service-bindings/rpc)
18-
- Define public methods on [Durable Objects](/durable-objects) that can be called by other workers on the same Cloudflare account that declare a binding to it.
19-
- Define public methods on [Model Context Protocol (MCP) Servers](/agents/model-context-protocol/mcp-server/) that are automatically translated to MCP [tools](/agents/model-context-protocol/mcp-server/tools/) that can be called by MCP clients.
18+
* Define public methods on your Worker that can be called by other Workers on the same Cloudflare account, via [Service Bindings](/workers/runtime-apis/bindings/service-bindings/rpc)
19+
* Define public methods on [Durable Objects](/durable-objects) that can be called by other workers on the same Cloudflare account that declare a binding to it.
2020

2121
The RPC system is designed to feel as similar as possible to calling a JavaScript function in the same Worker. In most cases, you should be able to write code in the same way you would if everything was in a single Worker.
2222

@@ -42,11 +42,11 @@ As an exception to Structured Clone, application-defined classes (or objects wit
4242

4343
The RPC system also supports a number of types that are not Structured Cloneable, including:
4444

45-
- Functions, which are replaced by stubs that call back to the sender.
46-
- Application-defined classes that extend `RpcTarget`, which are similarly replaced by stubs.
47-
- [ReadableStream](/workers/runtime-apis/streams/readablestream/) and [WriteableStream](/workers/runtime-apis/streams/writablestream/), with automatic streaming flow control.
48-
- [Request](/workers/runtime-apis/request/) and [Response](/workers/runtime-apis/response/), for conveniently representing HTTP messages.
49-
- RPC stubs themselves, even if the stub was received from a third Worker.
45+
* Functions, which are replaced by stubs that call back to the sender.
46+
* Application-defined classes that extend `RpcTarget`, which are similarly replaced by stubs.
47+
* [ReadableStream](/workers/runtime-apis/streams/readablestream/) and [WriteableStream](/workers/runtime-apis/streams/writablestream/), with automatic streaming flow control.
48+
* [Request](/workers/runtime-apis/request/) and [Response](/workers/runtime-apis/response/), for conveniently representing HTTP messages.
49+
* RPC stubs themselves, even if the stub was received from a third Worker.
5050

5151
## Functions
5252

@@ -81,33 +81,35 @@ main = "./src/counter.js"
8181
import { WorkerEntrypoint, RpcTarget } from "cloudflare:workers";
8282

8383
class Counter extends RpcTarget {
84-
#value = 0;
84+
#value = 0;
8585

86-
increment(amount) {
87-
this.#value += amount;
88-
return this.#value;
89-
}
86+
increment(amount) {
87+
this.#value += amount;
88+
return this.#value;
89+
}
9090

91-
get value() {
92-
return this.#value;
93-
}
91+
get value() {
92+
return this.#value;
93+
}
9494
}
9595

9696
export class CounterService extends WorkerEntrypoint {
97-
async newCounter() {
98-
return new Counter();
99-
}
97+
async newCounter() {
98+
return new Counter();
99+
}
100100
}
101101

102102
export default {
103-
fetch() {
104-
return new Response("ok");
105-
},
106-
};
103+
fetch() {
104+
return new Response("ok")
105+
}
106+
}
107107
```
108108

109109
The method `increment` can be called directly by the client, as can the public property `value`:
110110

111+
112+
111113
<WranglerConfig>
112114

113115
```toml
@@ -122,18 +124,18 @@ services = [
122124

123125
```js
124126
export default {
125-
async fetch(request, env) {
126-
using counter = await env.COUNTER_SERVICE.newCounter();
127+
async fetch(request, env) {
128+
using counter = await env.COUNTER_SERVICE.newCounter();
127129

128-
await counter.increment(2); // returns 2
129-
await counter.increment(1); // returns 3
130-
await counter.increment(-5); // returns -2
130+
await counter.increment(2); // returns 2
131+
await counter.increment(1); // returns 3
132+
await counter.increment(-5); // returns -2
131133

132-
const count = await counter.value; // returns -2
134+
const count = await counter.value; // returns -2
133135

134-
return new Response(count);
135-
},
136-
};
136+
return new Response(count);
137+
}
138+
}
137139
```
138140

139141
:::note
@@ -187,24 +189,24 @@ This works when calling properties of objects returned by RPC methods as well. F
187189
import { WorkerEntrypoint } from "cloudflare:workers";
188190

189191
export class MyService extends WorkerEntrypoint {
190-
async foo() {
191-
return {
192-
bar: {
193-
baz: () => "qux",
194-
},
195-
};
196-
}
192+
async foo() {
193+
return {
194+
bar: {
195+
baz: () => "qux"
196+
}
197+
}
198+
}
197199
}
198200
```
199201

200202
```js
201203
export default {
202-
async fetch(request, env) {
203-
using foo = env.MY_SERVICE.foo();
204-
let baz = await foo.bar.baz();
205-
return new Response(baz);
206-
},
207-
};
204+
async fetch(request, env) {
205+
using foo = env.MY_SERVICE.foo();
206+
let baz = await foo.bar.baz();
207+
return new Response(baz);
208+
}
209+
}
208210
```
209211

210212
If the initial RPC ends up throwing an exception, then any pipelined calls will also fail with the same exception
@@ -242,17 +244,13 @@ Currently, this proxying only lasts until the end of the Workers' execution cont
242244

243245
In this video, we explore how Cloudflare Workers support Remote Procedure Calls (RPC) to simplify communication between Workers. Learn how to implement RPC in your JavaScript applications and build serverless solutions with ease. Whether you're managing microservices or optimizing web architecture, this tutorial will show you how to quickly set up and use Cloudflare Workers for RPC calls. By the end of this video, you'll understand how to call functions between Workers, pass functions as arguments, and implement user authentication with Cloudflare Workers.
244246

245-
<Stream
246-
id="d506935b6767fd07626adbec46d41e6d"
247-
title="Introduction to Workers RPC"
248-
thumbnail="2.5s"
249-
/>
247+
<Stream id="d506935b6767fd07626adbec46d41e6d" title="Introduction to Workers RPC" thumbnail="2.5s" />
250248

251249
## More Details
252250

253251
<DirectoryListing />
254252

255253
## Limitations
256254

257-
- [Smart Placement](/workers/configuration/smart-placement/) is currently ignored when making RPC calls. If Smart Placement is enabled for Worker A, and Worker B declares a [Service Binding](/workers/runtime-apis/bindings) to it, when Worker B calls Worker A via RPC, Worker A will run locally, on the same machine.
258-
- The maximum serialized RPC limit is 1 MB. Consider using [`ReadableStream`](/workers/runtime-apis/streams/readablestream/) when returning more data.
255+
* [Smart Placement](/workers/configuration/smart-placement/) is currently ignored when making RPC calls. If Smart Placement is enabled for Worker A, and Worker B declares a [Service Binding](/workers/runtime-apis/bindings) to it, when Worker B calls Worker A via RPC, Worker A will run locally, on the same machine.
256+
* The maximum serialized RPC limit is 1 MB. Consider using [`ReadableStream`](/workers/runtime-apis/streams/readablestream/) when returning more data.

src/content/docs/workers/runtime-apis/rpc/mcp-tools.mdx

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)