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

Fix inngest.send. Add Event Builder #57

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

djfarrelly
Copy link
Member

@djfarrelly djfarrelly commented Jul 23, 2024

Summary

Fix and improve how events are sent using the Inngest client's send method.

Changes:

  • New exceptions to be thrown to handle specific types of Inngest Event API and event sending errors
  • InngestEventBuilder to expose a builder pattern to creating events
  • Refactor Step.kt to merge and simplify data classes

Checklist

  • Update documentation
  • Added unit/integration tests

Related

Copy link

linear bot commented Jul 23, 2024

return this
}

fun data(data: Any): InngestEventBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name and data are mandatory so why not have an InngestEvent with name and data for the constructor, and then chain itself instead?

Example/Reference in Rust
https://github.com/inngest/inngest-rs/blob/main/inngest/src/event.rs#L21-L49

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also since the InngestEvent is a data class with optional fields, honestly don't really need a builder?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general idea is that we'd have a couple different ways to do things, what you recommend and a builder pattern. It was recommended to have different options for users like this. The builder pattern might be preferred for users that want to set id or v but not have to include null arguments in a constructor.

Copy link
Collaborator

@albertchae albertchae Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up here:

@albertchae albertchae force-pushed the dan/inn-3336-simplify-inngestsend-for-sending-events-without-require branch from c8b6a70 to 53d0981 Compare September 9, 2024 04:59
@albertchae albertchae changed the base branch from main to albert/test-server-readme-inn-3336 September 9, 2024 05:00
@inngest inngest deleted a comment from github-actions bot Sep 9, 2024
Base automatically changed from albert/test-server-readme-inn-3336 to main September 9, 2024 14:04
djfarrelly and others added 3 commits September 12, 2024 06:33
- moved Array -> List conversion out of scope of this PR, we can do that
  in a follow up
@albertchae albertchae force-pushed the dan/inn-3336-simplify-inngestsend-for-sending-events-without-require branch from 53d0981 to 5180111 Compare September 12, 2024 14:37
- make name and data required params of the constructor
- all the optional fields have setters
- add tests

- also modify user on InngestEvent to have a type of map matching data
per https://github.com/inngest/inngest/blob/3f0b9cb28d38fa6f37abe82ded4734eea2f7dbc9/docs/SDK_SPEC.md?plain=1#L162
@albertchae albertchae marked this pull request as ready for review September 13, 2024 01:31
/**
* An internal class used for parsing events sent to Inngest functions
*/
internal data class Event(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After propagating InngestEvent to enough places to get this PR to compile, this Event is no longer used. I don't know if the intent was to convert external InngestEvents to internal Events somewhere, but I wasn't sure where so I'm punting on that for this PR

* in the order of which they were included in the request
*/
data class SendEventsResponse(
val ids: Array<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR originally changed this from Array to List which I think is a good change, but to reduce scope for this PR I am punting on it to a follow up

return this
}

fun data(data: Any): InngestEventBuilder {
Copy link
Collaborator

@albertchae albertchae Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants