Skip to content

Commit a05438a

Browse files
author
Guy Bedford
authored
rename fastly:runtime to fastly:compute (#959)
1 parent 6bf90b9 commit a05438a

File tree

12 files changed

+43
-43
lines changed

12 files changed

+43
-43
lines changed
File renamed without changes.
File renamed without changes.

integration-tests/js-compute/fixtures/app/src/runtime.js renamed to integration-tests/js-compute/fixtures/app/src/compute.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { pass, ok, strictEqual, assertThrows } from './assertions-throwing.js';
22
import { routes } from './routes.js';
3-
import { purgeSurrogateKey, vCpuTime } from 'fastly:runtime';
3+
import { purgeSurrogateKey, vCpuTime } from 'fastly:compute';
44

5-
routes.set('/runtime/get-vcpu-ms', () => {
5+
routes.set('/compute/get-vcpu-ms', () => {
66
const cpuTime = vCpuTime();
77
strictEqual(typeof cpuTime, 'number');
88
ok(cpuTime > 0);
@@ -18,7 +18,7 @@ routes.set('/runtime/get-vcpu-ms', () => {
1818
return pass('ok');
1919
});
2020

21-
routes.set('/runtime/purge-surrogate-key-invalid', () => {
21+
routes.set('/compute/purge-surrogate-key-invalid', () => {
2222
assertThrows(
2323
() => {
2424
purgeSurrogateKey();
@@ -29,12 +29,12 @@ routes.set('/runtime/purge-surrogate-key-invalid', () => {
2929
return pass('ok');
3030
});
3131

32-
routes.set('/runtime/purge-surrogate-key-hard', () => {
32+
routes.set('/compute/purge-surrogate-key-hard', () => {
3333
purgeSurrogateKey('test');
3434
return pass('ok');
3535
});
3636

37-
routes.set('/runtime/purge-surrogate-key-soft', () => {
37+
routes.set('/compute/purge-surrogate-key-soft', () => {
3838
purgeSurrogateKey('test', true);
3939
return pass('ok');
4040
});

integration-tests/js-compute/fixtures/app/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import "./cache-override.js";
1313
import "./cache-core.js";
1414
import "./cache-simple.js";
1515
import "./client.js";
16+
import "./compute.js";
1617
import "./config-store.js";
1718
import "./console.js";
1819
import "./crypto.js";
@@ -44,7 +45,6 @@ import "./request-method.js";
4445
import "./response-json.js";
4546
import "./response-redirect.js";
4647
import "./response.js";
47-
import "./runtime.js";
4848
import "./secret-store.js";
4949
import "./server.js";
5050
import "./tee.js";

integration-tests/js-compute/fixtures/app/tests.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,17 +4250,17 @@
42504250
"body": "ok"
42514251
}
42524252
},
4253-
"GET /runtime/get-vcpu-ms": {
4253+
"GET /compute/get-vcpu-ms": {
42544254
"downstream_response": {
42554255
"body": "ok",
42564256
"status": 200
42574257
}
42584258
},
4259-
"GET /runtime/purge-surrogate-key-invalid": {},
4260-
"GET /runtime/purge-surrogate-key-hard": {
4259+
"GET /compute/purge-surrogate-key-invalid": {},
4260+
"GET /compute/purge-surrogate-key-hard": {
42614261
"environments": ["compute"]
42624262
},
4263-
"GET /runtime/purge-surrogate-key-soft": {
4263+
"GET /compute/purge-surrogate-key-soft": {
42644264
"environments": ["compute"]
42654265
}
42664266
}

runtime/fastly/builtins/cache-simple.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ bool SimpleCache::purge(JSContext *cx, unsigned argc, JS::Value *vp) {
737737
return false;
738738
}
739739

740-
auto purge_res = host_api::Runtime::purge_surrogate_key(surrogate_key, false);
740+
auto purge_res = host_api::Compute::purge_surrogate_key(surrogate_key, false);
741741
if (auto *err = purge_res.to_err()) {
742742
HANDLE_ERROR(cx, *err);
743743
return false;

runtime/fastly/builtins/fastly.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ bool Fastly::env_get(JSContext *cx, unsigned argc, JS::Value *vp) {
220220
return true;
221221
}
222222

223-
bool runtime_get_vcpu_time(JSContext *cx, unsigned argc, JS::Value *vp) {
223+
bool compute_get_vcpu_time(JSContext *cx, unsigned argc, JS::Value *vp) {
224224
JS::CallArgs args = CallArgsFromVp(argc, vp);
225-
auto res = host_api::Runtime::get_vcpu_ms();
225+
auto res = host_api::Compute::get_vcpu_ms();
226226
if (auto *err = res.to_err()) {
227227
HANDLE_ERROR(cx, *err);
228228
return false;
@@ -231,7 +231,7 @@ bool runtime_get_vcpu_time(JSContext *cx, unsigned argc, JS::Value *vp) {
231231
return true;
232232
}
233233

234-
bool runtime_purge_surrogate_key(JSContext *cx, unsigned argc, JS::Value *vp) {
234+
bool compute_purge_surrogate_key(JSContext *cx, unsigned argc, JS::Value *vp) {
235235
JS::CallArgs args = CallArgsFromVp(argc, vp);
236236
if (!args.requireAtLeast(cx, "purgeSurrogateKey", 1)) {
237237
return false;
@@ -246,7 +246,7 @@ bool runtime_purge_surrogate_key(JSContext *cx, unsigned argc, JS::Value *vp) {
246246
if (soft_val.isBoolean()) {
247247
soft = soft_val.toBoolean();
248248
}
249-
auto purge_res = host_api::Runtime::purge_surrogate_key(surrogate_key_chars, soft);
249+
auto purge_res = host_api::Compute::purge_surrogate_key(surrogate_key_chars, soft);
250250
if (auto *err = purge_res.to_err()) {
251251
HANDLE_ERROR(cx, *err);
252252
return false;
@@ -449,34 +449,34 @@ bool install(api::Engine *engine) {
449449
return false;
450450
}
451451

452-
// fastly:runtime
453-
RootedObject runtime_builtin(engine->cx(), JS_NewObject(engine->cx(), nullptr));
454-
auto runtime_purge_surrogate_key_fn =
455-
JS_NewFunction(engine->cx(), &runtime_purge_surrogate_key, 1, 0, "purgeSurrogateKey");
456-
RootedObject runtime_purge_surrogate_key_obj(
457-
engine->cx(), JS_GetFunctionObject(runtime_purge_surrogate_key_fn));
458-
RootedValue runtime_purge_surrogate_key_val(engine->cx(),
459-
ObjectValue(*runtime_purge_surrogate_key_obj));
452+
// fastly:compute
453+
RootedObject compute_builtin(engine->cx(), JS_NewObject(engine->cx(), nullptr));
454+
auto compute_purge_surrogate_key_fn =
455+
JS_NewFunction(engine->cx(), &compute_purge_surrogate_key, 1, 0, "purgeSurrogateKey");
456+
RootedObject compute_purge_surrogate_key_obj(
457+
engine->cx(), JS_GetFunctionObject(compute_purge_surrogate_key_fn));
458+
RootedValue compute_purge_surrogate_key_val(engine->cx(),
459+
ObjectValue(*compute_purge_surrogate_key_obj));
460460

461-
if (!JS_SetProperty(engine->cx(), runtime_builtin, "purgeSurrogateKey",
462-
runtime_purge_surrogate_key_val)) {
461+
if (!JS_SetProperty(engine->cx(), compute_builtin, "purgeSurrogateKey",
462+
compute_purge_surrogate_key_val)) {
463463
return false;
464464
}
465-
if (!JS_SetProperty(engine->cx(), fastly, "purgeSurrogateKey", runtime_purge_surrogate_key_val)) {
465+
if (!JS_SetProperty(engine->cx(), fastly, "purgeSurrogateKey", compute_purge_surrogate_key_val)) {
466466
return false;
467467
}
468-
auto runtime_vcpu_time_get =
469-
JS_NewFunction(engine->cx(), &runtime_get_vcpu_time, 0, 0, "vCpuTime");
470-
RootedObject runtime_vcpu_time_get_obj(engine->cx(), JS_GetFunctionObject(runtime_vcpu_time_get));
471-
RootedValue runtime_vcpu_time_get_val(engine->cx(), ObjectValue(*runtime_vcpu_time_get_obj));
472-
if (!JS_SetProperty(engine->cx(), runtime_builtin, "vCpuTime", runtime_vcpu_time_get_val)) {
468+
auto compute_vcpu_time_get =
469+
JS_NewFunction(engine->cx(), &compute_get_vcpu_time, 0, 0, "vCpuTime");
470+
RootedObject compute_vcpu_time_get_obj(engine->cx(), JS_GetFunctionObject(compute_vcpu_time_get));
471+
RootedValue compute_vcpu_time_get_val(engine->cx(), ObjectValue(*compute_vcpu_time_get_obj));
472+
if (!JS_SetProperty(engine->cx(), compute_builtin, "vCpuTime", compute_vcpu_time_get_val)) {
473473
return false;
474474
}
475-
if (!JS_SetProperty(engine->cx(), fastly, "vCpuTime", runtime_vcpu_time_get_val)) {
475+
if (!JS_SetProperty(engine->cx(), fastly, "vCpuTime", compute_vcpu_time_get_val)) {
476476
return false;
477477
}
478-
RootedValue runtime_builtin_val(engine->cx(), JS::ObjectValue(*runtime_builtin));
479-
if (!engine->define_builtin_module("fastly:runtime", runtime_builtin_val)) {
478+
RootedValue compute_builtin_val(engine->cx(), JS::ObjectValue(*compute_builtin));
479+
if (!engine->define_builtin_module("fastly:compute", compute_builtin_val)) {
480480
return false;
481481
}
482482

runtime/fastly/host-api/fastly.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ int device_detection_lookup(const char *user_agent, size_t user_agent_len, const
750750
size_t buf_len, size_t *nwritten);
751751

752752
WASM_IMPORT("fastly_compute_runtime", "get_vcpu_ms")
753-
int runtime_get_vcpu_ms(uint64_t *vcpu_ms);
753+
int compute_get_vcpu_ms(uint64_t *vcpu_ms);
754754

755755
} // namespace fastly
756756
#ifdef __cplusplus

runtime/fastly/host-api/host_api.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,19 +2745,19 @@ Result<HostString> DeviceDetection::lookup(std::string_view user_agent) {
27452745
return res;
27462746
}
27472747

2748-
Result<uint64_t> Runtime::get_vcpu_ms() {
2748+
Result<uint64_t> Compute::get_vcpu_ms() {
27492749
Result<uint64_t> res;
27502750
uint64_t ret;
27512751
fastly::fastly_host_error err;
2752-
if (!convert_result(fastly::runtime_get_vcpu_ms(&ret), &err)) {
2752+
if (!convert_result(fastly::compute_get_vcpu_ms(&ret), &err)) {
27532753
res.emplace_err(err);
27542754
} else {
27552755
res.emplace(ret);
27562756
}
27572757
return res;
27582758
}
27592759

2760-
Result<std::optional<HostString>> Runtime::purge_surrogate_key(std::string_view key, bool soft) {
2760+
Result<std::optional<HostString>> Compute::purge_surrogate_key(std::string_view key, bool soft) {
27612761
Result<std::optional<HostString>> res;
27622762

27632763
auto host_key = string_view_to_world_string(key);

runtime/fastly/host-api/host_api_fastly.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ class DeviceDetection final {
798798
static Result<HostString> lookup(std::string_view user_agent);
799799
};
800800

801-
class Runtime final {
801+
class Compute final {
802802
public:
803803
static Result<uint64_t> get_vcpu_ms();
804804
/// Purge the given surrogate key.

0 commit comments

Comments
 (0)