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

Implement onFailure handler. #63

Merged
merged 7 commits into from
Sep 11, 2024
Merged

Commits on Sep 11, 2024

  1. Implement an interface for functions that need to handle failures.

    I took a more OOP approach for this feature which is slightly different
    than the other SDKs but we can discuss this further in the PR review.
    
    The `WithFailureHandler` interface has a single method `onFailure` that
    is called when the function fails. An example of how to use this:
    
    ```kotlin
    class MyFunction : InngestFunction(), WithFailureHandler {
        override fun execute(ctx: FunctionContext, step: Step): Any? {
            // Do something
        }
    
        override fun onFailure(ctx: FunctionContext, step: Step): Any? {
            // Handle failure
        }
    }
    ```
    KiKoS0 committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    f7338ad View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    080d8ac View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    861ef1f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cb8582d View commit details
    Browse the repository at this point in the history
  5. Run formatting

    KiKoS0 committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    de78a21 View commit details
    Browse the repository at this point in the history
  6. Switch to an overridable onFailure method in InngestFunction

    This removes the `WithFailureHandler` interface and instead provides an
    overridable `onFailure` method in `InngestFunction` that can be used to
    define a function to be called when the function fails.
    
    It's used in the same way but without the need to implement an interface
    
    ```kotlin
    
    class MyFunction : InngestFunction() {
        override fun execute(ctx: FunctionContext, step: Step): Any? {
            // Do something
        }
    
        override fun onFailure(ctx: FunctionContext, step: Step): Any? {
            // Handle failure
        }
    }
    
    ```
    KiKoS0 committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    46b2323 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    d8d9b23 View commit details
    Browse the repository at this point in the history