Skip to content
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

Common interfacing for Valor modules #51

Open
pandres95 opened this issue May 10, 2023 · 0 comments
Open

Common interfacing for Valor modules #51

pandres95 opened this issue May 10, 2023 · 0 comments

Comments

@pandres95
Copy link
Member

pandres95 commented May 10, 2023

Valor: A Multi-Target, Transport-Agnostic Runtime for Modular Code Execution

Valor is a Rust runtime designed to run arbitrary code organized in a modular way, independent of the transport layer. It can be compiled for multiple targets, including server-side applications, WebAssembly (WASM/WASI), and embedded systems.

Design

Module Registry

Valor maintains a static, thread-safe registry of modules. Each module contains a collection of methods, along with arbitrary metadata in the form of extensions. This design allows for organized and manageable execution of code in different environments.

Attribute Macros

Valor provides three attribute macros: valor::module, valor::method, and valor::extensions. These macros are used to define modules and their associated methods and extensions.

  • valor::module: Defines a module. The module contains a collection of methods and metadata.
  • valor::method: Marks functions as methods of the containing module.
  • valor::extensions: Provides arbitrary metadata for methods or modules.

Module and Method Structures

Modules and methods in Valor are represented by the Module and Method structs, respectively. Both structs contain a name and a set of extensions. The Method struct also contains a function that can be called to execute the method.

Example Usage

Here's an example of how to define a module and its methods using Valor:

#[valor::module(a_module)]
pub mod a_module {
    use valor::structures::{Request, Response};

    #[valor::method(a_method)]
    #[valor::extensions(http_verb = "GET", http_path = "/")]
    pub fn a_method (request: Request) -> Response {
        // Implement the function
    }
}

In this test, we create a Module, add it to the registry, and then verify that it was correctly added.

Future Work

The design of Valor allows for further expansion and adaptation to different use cases. Future plans include additional attribute macros for more granular control over methods, an expanded registry that can manage modules across multiple servers and applications, and potential integrations with different transport layers. Stay tuned for updates!

@pandres95 pandres95 converted this from a draft issue May 10, 2023
@pandres95 pandres95 linked a pull request Jun 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant