Skip to content

Commit

Permalink
feat: project generation with init
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanBorai committed Oct 2, 2022
1 parent d6987fd commit b6511c1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions smartmodule/cargo_template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ fluvio-smartmodule = { {{smartmodule-version}} }
serde = { version = "1", features = ["derive"] }
serde_json = "1"


[profile.release]
[profile.release-lto]
inherits = "release"
lto = true
2 changes: 0 additions & 2 deletions smartmodule/cargo_template/Smart.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ package_version = "0.1"
description = "{{project-description}}"
license = "Apache-2.0"



[cargo]
profile = "release"
1 change: 1 addition & 0 deletions smartmodule/cargo_template/cargo-generate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type = "string"
prompt = "Which type of SmartModule would you like?"
choices = ["filter", "map", "filter-map", "array-map", "aggregate"]
default = "filter"

[placeholders.smartmodule-init]
type = "bool"
prompt = "Want to use SmartModule init?"
Expand Down
11 changes: 11 additions & 0 deletions smartmodule/cargo_template/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% if smartmodule-init %}
use fluvio_smartmodule::dataplane::smartmodule::{SmartModuleExtraParams, SmartModuleInitError};
{% endif %}
{% if smartmodule-type == "filter" %}
use fluvio_smartmodule::{smartmodule, Result, Record};

Expand Down Expand Up @@ -79,3 +82,11 @@ pub fn aggregate(accumulator: RecordData, current: &Record{% if smartmodule-para
#[derive(fluvio_smartmodule::SmartOpt, Default)]
pub struct SmartModuleOpt;
{% endif %}
{% if smartmodule-init %}
#[smartmodule(init)]
fn init(params: SmartModuleOpt) -> Result<()> {
todo!("Provide initialization logic for your SmartModule")
/// Using Init with a Filter SmartModule
/// https://github.com/infinyon/fluvio/blob/master/smartmodule/examples/filter_init/src/lib.rs
}
{% endif %}

0 comments on commit b6511c1

Please sign in to comment.