Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin67 committed Oct 9, 2024
1 parent a00987c commit 73708cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
15 changes: 5 additions & 10 deletions inngest/examples/axum/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ fn dummy_fn(client: &Inngest) -> ServableFn<Data, Error> {
let invoke_id = fallible_step_run(client).slug();

client.create_function(
FunctionOpts::new("dummy-func")
.name("Dummy func"),
FunctionOpts::new("dummy-func").name("Dummy func"),
Trigger::event("test/event"),
move |_input: Input<Data>, step: StepTool| {
let function_id = invoke_id.clone();
Expand Down Expand Up @@ -124,8 +123,7 @@ fn dummy_fn(client: &Inngest) -> ServableFn<Data, Error> {

fn hello_fn(client: &Inngest) -> ServableFn<Data, Error> {
client.create_function(
FunctionOpts::new("hello-func")
.name("Hello func"),
FunctionOpts::new("hello-func").name("Hello func"),
Trigger::event("test/hello"),
|input: Input<Data>, step: StepTool| async move {
println!("In hello function");
Expand Down Expand Up @@ -159,17 +157,15 @@ async fn call_some_step_function(_input: Input<Data>, step: StepTool) -> Result<

fn step_run(client: &Inngest) -> ServableFn<Data, Error> {
client.create_function(
FunctionOpts::new("step-run")
.name("Step run"),
FunctionOpts::new("step-run").name("Step run"),
Trigger::event("test/step-run"),
call_some_step_function,
)
}

fn incorrectly_propagates_error(client: &Inngest) -> ServableFn<Data, Error> {
client.create_function(
FunctionOpts::new("step-run")
.name("Step run"),
FunctionOpts::new("step-run").name("Step run"),
Trigger::event("test/step-run-incorrect"),
|_input: Input<Data>, step: StepTool| async move {
let some_captured_variable = "captured".to_string();
Expand All @@ -195,8 +191,7 @@ fn incorrectly_propagates_error(client: &Inngest) -> ServableFn<Data, Error> {

fn fallible_step_run(client: &Inngest) -> ServableFn<Data, Error> {
client.create_function(
FunctionOpts::new("fallible-step-run")
.name("Fallible Step run"),
FunctionOpts::new("fallible-step-run").name("Fallible Step run"),
Trigger::event("test/step-run-fallible"),
|input: Input<Data>, step: StepTool| async move {
let step_res = into_dev_result!(
Expand Down
14 changes: 9 additions & 5 deletions inngest/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use serde_json::Value;
use slug::slugify;
use url::Url;
use std::future::Future;
use url::Url;

use crate::{
config::Config,
event::{Event, InngestEvent},
function::{FunctionOpts, Input, ServableFn, Trigger},
handler::Kind,
result::DevError,
step_tool::Step as StepTool
step_tool::Step as StepTool,
};

const API_ORIGIN_DEV: &str = "http://127.0.0.1:8288";
Expand Down Expand Up @@ -84,11 +84,15 @@ impl Inngest {
self
}

pub fn create_function<T: 'static, E, F: Future<Output = Result<Value, E>> + Send + Sync + 'static>(
pub fn create_function<
T: 'static,
E,
F: Future<Output = Result<Value, E>> + Send + Sync + 'static,
>(
&self,
opts: FunctionOpts,
trigger: Trigger,
func: impl Fn(Input<T>, StepTool) -> F + Send + Sync + 'static
func: impl Fn(Input<T>, StepTool) -> F + Send + Sync + 'static,
) -> ServableFn<T, E> {
use futures::future::FutureExt;

Expand All @@ -97,7 +101,7 @@ impl Inngest {
app_id,
opts,
trigger,
func: Box::new(move |input, step| func(input, step).boxed())
func: Box::new(move |input, step| func(input, step).boxed()),
}
}

Expand Down
7 changes: 1 addition & 6 deletions inngest/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,7 @@ impl<T, E> Handler<T, E> {
let functions: Vec<Function> = self
.funcs
.iter()
.map(|(_, f)| {
f.function(
&self.app_serve_origin(headers),
&self.app_serve_path()
)
})
.map(|(_, f)| f.function(&self.app_serve_origin(headers), &self.app_serve_path()))
.collect();

let req = Request {
Expand Down

0 comments on commit 73708cf

Please sign in to comment.