-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement(lua transform): Add
version
configuration option (#2056)
* enhancement(lua transform): Add "version" configuration option Signed-off-by: Alexander Rodin <[email protected]> * Don't expose internal typetag names `lua_v1` and `lua_v1` to users Signed-off-by: Alexander Rodin <[email protected]> * Add `version` configuration option to the documentation Signed-off-by: Alexander Rodin <[email protected]> * Use independent implementations of `rlua::UserData` for `Event` Signed-off-by: Alexander Rodin <[email protected]> * Fix benchmarks Signed-off-by: Alexander Rodin <[email protected]> * Benchmark both version 1 and version 2 Signed-off-by: Alexander Rodin <[email protected]> * Don't show version 2 in the docs Signed-off-by: Alexander Rodin <[email protected]> * Add behavior tests for `version` configuration option Signed-off-by: Alexander Rodin <[email protected]> * Update CODEOWNERS to match the new directory structure Signed-off-by: Alexander Rodin <[email protected]>
- Loading branch information
Showing
9 changed files
with
755 additions
and
38 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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,78 @@ | ||
pub mod v1; | ||
pub mod v2; | ||
|
||
use crate::{ | ||
topology::config::{DataType, TransformConfig, TransformContext, TransformDescription}, | ||
transforms::Transform, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
enum V1 { | ||
#[serde(rename = "1")] | ||
V1, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct LuaConfigV1 { | ||
version: Option<V1>, | ||
#[serde(flatten)] | ||
config: v1::LuaConfig, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
enum V2 { | ||
#[serde(rename = "2")] | ||
V2, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct LuaConfigV2 { | ||
version: V2, | ||
#[serde(flatten)] | ||
config: v2::LuaConfig, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
#[serde(untagged)] | ||
pub enum LuaConfig { | ||
V1(LuaConfigV1), | ||
V2(LuaConfigV2), | ||
} | ||
|
||
inventory::submit! { | ||
TransformDescription::new_without_default::<LuaConfig>("lua") | ||
} | ||
|
||
#[typetag::serde(name = "lua")] | ||
impl TransformConfig for LuaConfig { | ||
fn build(&self, cx: TransformContext) -> crate::Result<Box<dyn Transform>> { | ||
match self { | ||
LuaConfig::V1(v1) => v1.config.build(cx), | ||
LuaConfig::V2(v2) => v2.config.build(cx), | ||
} | ||
} | ||
|
||
fn input_type(&self) -> DataType { | ||
match self { | ||
LuaConfig::V1(v1) => v1.config.input_type(), | ||
LuaConfig::V2(v2) => v2.config.input_type(), | ||
} | ||
} | ||
|
||
fn output_type(&self) -> DataType { | ||
match self { | ||
LuaConfig::V1(v1) => v1.config.output_type(), | ||
LuaConfig::V2(v2) => v2.config.output_type(), | ||
} | ||
} | ||
|
||
fn transform_type(&self) -> &'static str { | ||
match self { | ||
LuaConfig::V1(v1) => v1.config.transform_type(), | ||
LuaConfig::V2(v2) => v2.config.transform_type(), | ||
} | ||
} | ||
} |
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
Oops, something went wrong.