-
Notifications
You must be signed in to change notification settings - Fork 347
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
JSRPC: Service bindings and stateless class syntax #1658
Changes from all commits
f276170
757fe9c
f563fda
1b2e821
5c8fb60
fa2c691
2b86ec0
2c8b6b2
49315cd
7db1dc6
1142b24
e02bc6d
6881b42
3ebd72b
34022fe
7da6093
67ccd35
63a44b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export class DurableObject { | ||
public constructor(ctx: unknown, env: unknown); | ||
|
||
public ctx: unknown; | ||
public env: unknown; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these readonly? |
||
} | ||
|
||
export class WorkerEntrypoint { | ||
public constructor(ctx: unknown, env: unknown); | ||
|
||
public ctx: unknown; | ||
public env: unknown; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright (c) 2024 Cloudflare, Inc. | ||
// Licensed under the Apache 2.0 license found in the LICENSE file or at: | ||
// https://opensource.org/licenses/Apache-2.0 | ||
|
||
// TODO(cleanup): C++ built-in modules do not yet support named exports, so we must define this | ||
// wrapper module that simply re-exports the classes from the built-in module. | ||
|
||
import entrypoints from 'cloudflare-internal:workers'; | ||
|
||
export const WorkerEntrypoint = entrypoints.WorkerEntrypoint; | ||
export const DurableObject = entrypoints.DurableObject; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2023 Cloudflare, Inc. | ||
// Licensed under the Apache 2.0 license found in the LICENSE file or at: | ||
// https://opensource.org/licenses/Apache-2.0 | ||
|
||
import assert from 'node:assert'; | ||
|
||
// This class does not extend `DurableObject`, but because we have the `js_rpc` compat flag on, | ||
// it'll still accept RPC. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You deleted the "js-rpc-disabled" test, should something like that still exist? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As of this commit, the main |
||
export class DurableObjectExample { | ||
constructor() {} | ||
|
||
foo() { | ||
return 123; | ||
} | ||
} | ||
|
||
export default { | ||
async test(ctrl, env, ctx) { | ||
let id = env.ns.idFromName("foo"); | ||
let obj = env.ns.get(id); | ||
assert.strictEqual(await obj.foo(), 123); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually kinda think the internal file could still be
entrypoints
, and the publiccloudflare:workers
file could export a bunch of stuff from a fewcloudflare-internal
files?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe but it doesn't matter, the file is internal and ideally I'd like to remove it entirely when built-in modules (defined in C++) start supporting named exports properly.