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

Adding support for Init Functions #65

Merged
merged 2 commits into from
Oct 1, 2023
Merged

Adding support for Init Functions #65

merged 2 commits into from
Oct 1, 2023

Conversation

madflojo
Copy link
Member

@madflojo madflojo commented Oct 1, 2023

Summary by CodeRabbit

  • New Feature: Added "init functions" to Tarmac, allowing users to define initialization functions that execute when the service starts. This feature enhances the flexibility and control over service startup behavior.
  • New Feature: Updated the Run method in Server struct to support initializing routes, executing init functions, and scheduling tasks. This change improves the server's functionality and versatility.
  • Test: Introduced a new test case for handling failing init functions, improving the robustness of our testing suite.
  • Chore: Added a new build target build-testdata to the Makefile, facilitating the building of additional test data.
  • Documentation: Updated documentation to include details about the new "init functions" feature, providing users with necessary guidance on its usage.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2023

Walkthrough

This pull request introduces the concept of "init functions" to Tarmac, allowing for service initialization routines. It also includes a new build target for test data, and adds a test case for failing init functions. A Go example using Tarmac WASM functions is provided as well.

Changes

File(s) Summary
Makefile Adds a new build target for additional test data.
docs/wasm-functions/multi-function-services.md Introduces "init functions" feature with examples.
pkg/app/app.go Modifies the Run method to support init functions and task scheduling.
pkg/app/app_test.go Adds a test case for a failing init function.
testdata/fail/... Includes a Makefile for a Go example using Tarmac WASM functions and a Go program that initializes the Tarmac SDK.

🐇💻

Code changes here, code changes there,

Init functions everywhere!

With tests and docs, we take care,

To ensure our code is fair.

So celebrate this pull request's might,

For it brings Tarmac's features to light! 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between fc714c7 and 2edd8f8.
Files ignored due to filter (5)
  • testdata/fail/docker-compose.yml
  • testdata/fail/go.mod
  • testdata/fail/go.sum
  • testdata/tarmac-fail.json
  • testdata/tarmac.json
Files selected for processing (6)
  • Makefile (1 hunks)
  • docs/wasm-functions/multi-function-services.md (1 hunks)
  • pkg/app/app.go (3 hunks)
  • pkg/app/app_test.go (1 hunks)
  • testdata/fail/Makefile (1 hunks)
  • testdata/fail/main.go (1 hunks)
Files skipped from review due to trivial changes (5)
  • Makefile
  • docs/wasm-functions/multi-function-services.md
  • pkg/app/app_test.go
  • testdata/fail/Makefile
  • testdata/fail/main.go
Additional comments (Suppressed): 1
pkg/app/app.go (1)
  • 454-462: The new code introduces the concept of "init functions" which are executed when the service starts. Ensure that these init functions are designed to be idempotent and can handle being called multiple times without causing issues, as they might be called again if the service restarts.

pkg/app/app.go Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 1, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (fc714c7) 82.40% compared to head (2edd8f8) 82.57%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
+ Coverage   82.40%   82.57%   +0.17%     
==========================================
  Files          12       12              
  Lines        1125     1136      +11     
==========================================
+ Hits          927      938      +11     
  Misses        152      152              
  Partials       46       46              
Files Coverage Δ
pkg/app/app.go 75.19% <100.00%> (+0.73%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@madflojo madflojo merged commit 673fb94 into main Oct 1, 2023
11 checks passed
@madflojo madflojo deleted the initfunc branch October 1, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant