MCPcopy Create free account
hub / github.com/apache/trafficserver / canary

Method canary

plugins/experimental/wasm/lib/src/wasm.cc:494–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

492}
493
494bool WasmHandleBase::canary(const std::shared_ptr<PluginBase> &plugin,
495 const WasmHandleCloneFactory &clone_factory) {
496 if (this->wasm() == nullptr) {
497 return false;
498 }
499 auto it = plugin_canary_cache_.find(plugin->key());
500 if (it != plugin_canary_cache_.end()) {
501 return it->second;
502 }
503 auto configuration_canary_handle = clone_factory(shared_from_this());
504 if (!configuration_canary_handle) {
505 this->wasm()->fail(FailState::UnableToCloneVm, "Failed to clone Base Wasm");
506 return false;
507 }
508 if (!configuration_canary_handle->wasm()->initialize()) {
509 configuration_canary_handle->wasm()->fail(FailState::UnableToInitializeCode,
510 "Failed to initialize Wasm code");
511 return false;
512 }
513 auto *root_context = configuration_canary_handle->wasm()->start(plugin);
514 if (root_context == nullptr) {
515 configuration_canary_handle->wasm()->fail(FailState::StartFailed, "Failed to start base Wasm");
516 return false;
517 }
518 if (!configuration_canary_handle->wasm()->configure(root_context, plugin)) {
519 configuration_canary_handle->wasm()->fail(FailState::ConfigureFailed,
520 "Failed to configure base Wasm plugin");
521 plugin_canary_cache_[plugin->key()] = false;
522 return false;
523 }
524 configuration_canary_handle->kill();
525 plugin_canary_cache_[plugin->key()] = true;
526 return true;
527}
528
529std::shared_ptr<WasmHandleBase> createWasm(const std::string &vm_key, const std::string &code,
530 const std::shared_ptr<PluginBase> &plugin,

Callers 1

createWasmFunction · 0.80

Calls 9

killMethod · 0.80
wasmMethod · 0.45
findMethod · 0.45
keyMethod · 0.45
endMethod · 0.45
failMethod · 0.45
initializeMethod · 0.45
startMethod · 0.45
configureMethod · 0.45

Tested by

no test coverage detected