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

Cleanup the Inngest's client send interface #69

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

KiKoS0
Copy link
Collaborator

@KiKoS0 KiKoS0 commented Sep 1, 2024

Summary

Cleanup the Inngest's client send interface, making it clearer that it supports sending multiple events at once.

Changes:

  • Remove the sendEvent method.
  • Correctly type the send method and cleanup the implementation: Removed the unnecessary generic and Any typing.
  • Handle both cases of passing one or multiple events.

Checklist

  • Update documentation

Related

@KiKoS0 KiKoS0 requested a review from albertchae September 1, 2024 21:20
@KiKoS0 KiKoS0 self-assigned this Sep 1, 2024
@KiKoS0 KiKoS0 force-pushed the riadh/inn-2815-send-multiple-events branch from 6c31189 to fdddaea Compare September 1, 2024 21:22
fun send(events: Array<InngestEvent>): SendEventsResponse? {
val request = httpClient.build("$baseUrl/e/$eventKey", events)

return httpClient.send(request) lambda@{ response ->
// TODO: Handle error case
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can handle the error case in: #57

Copy link

linear bot commented Sep 1, 2024

Making it clearer that it supports sending multiple events at once.
@KiKoS0 KiKoS0 force-pushed the riadh/inn-2815-send-multiple-events branch from fdddaea to 0fc1ebf Compare September 1, 2024 21:26
Copy link
Collaborator

@albertchae albertchae left a comment

Choose a reason for hiding this comment

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

looks good, main question is on use of an array vs List

@@ -206,23 +206,22 @@ class Step(
}

/**
* Sends multiple events to Inngest
* Sends a single event to Inngest.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice catch on the docs here

* @param events The events to send.
*
*/
fun send(events: Array<InngestEvent>): SendEventsResponse? {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hm, I can't find a concrete reference for this but I think Kotlin Array is the equivalent of a java array, which means InngestEvent[] which I think tends to be less flexible than the List interface, since that has multiple implementations and [] arrays can easily be made into ArrayList

Some SO posts that seem to align with that I'm saying, but nothing definitive

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's address this in a follow up

* @param event The event to send.
*
*/
fun send(event: InngestEvent): SendEventsResponse? = send(arrayOf(event))
Copy link
Collaborator

Choose a reason for hiding this comment

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

do other SDKs use the plural response type even if a singular event is sent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

both do yeah.

@@ -21,37 +19,28 @@ class Inngest

internal val httpClient = HttpClient(RequestConfig(headers))

inline fun <reified T> send(payload: Any): T? =
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh nice, we can get rid of the reified type

@KiKoS0 KiKoS0 merged commit 6503363 into main Sep 3, 2024
9 checks passed
@KiKoS0 KiKoS0 deleted the riadh/inn-2815-send-multiple-events branch September 3, 2024 14:30
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.

2 participants