-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor
js_generic
to use common DynamicJSEndpointRegistry
hiera…
…rchy, and expose as an extensible public header (#6710)
- Loading branch information
1 parent
526793b
commit 8306717
Showing
8 changed files
with
197 additions
and
925 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the Apache 2.0 License. | ||
#pragma once | ||
|
||
#include "ccf/js/registry.h" | ||
#include "ccf/service/tables/jsengine.h" | ||
#include "ccf/service/tables/modules.h" | ||
|
||
namespace ccf::js | ||
{ | ||
// This sample extends the generic BaseDynamicJSEndpointRegistry to read JS | ||
// endpoints (code, metadata, options) from governance tables. Specifically, | ||
// tables populated by actions in the default sample CCF constitution | ||
// (set_js_app). This can be sub-classed to modify the dispatch or execution | ||
// behaviour, or to provide further JS extension APIs via get_extensions(). | ||
// | ||
// An application running this registry with no further extensions is shipped | ||
// with the CCF releases as `js_generic`. | ||
class GovernanceDrivenJSRegistry | ||
: public ccf::js::BaseDynamicJSEndpointRegistry | ||
{ | ||
public: | ||
GovernanceDrivenJSRegistry(AbstractNodeContext& context) : | ||
// Note: We do not pass a kv_prefix here, instead we explicitly, manually | ||
// construct each map name to match previously used values | ||
ccf::js::BaseDynamicJSEndpointRegistry(context) | ||
{ | ||
modules_map = ccf::Tables::MODULES; | ||
metadata_map = ccf::endpoints::Tables::ENDPOINTS; | ||
interpreter_flush_map = ccf::Tables::INTERPRETER_FLUSH; | ||
modules_quickjs_version_map = ccf::Tables::MODULES_QUICKJS_VERSION; | ||
modules_quickjs_bytecode_map = ccf::Tables::MODULES_QUICKJS_BYTECODE; | ||
runtime_options_map = ccf::Tables::JSENGINE; | ||
} | ||
}; | ||
} // namespace ccf::js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the Apache 2.0 License. | ||
|
||
#include "ccf/app_interface.h" | ||
#include "js_generic_base.h" | ||
#include "ccf/js/samples/governance_driven_registry.h" | ||
|
||
namespace ccf | ||
{ | ||
std::unique_ptr<ccf::endpoints::EndpointRegistry> make_user_endpoints( | ||
ccf::AbstractNodeContext& context) | ||
{ | ||
return make_user_endpoints_impl(context); | ||
return std::make_unique<ccf::js::GovernanceDrivenJSRegistry>(context); | ||
} | ||
|
||
} // namespace ccf |
Oops, something went wrong.