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

feat: support route dataframe to dedicate sfn instance #704

Merged
merged 20 commits into from
Feb 2, 2024

Conversation

woorui
Copy link
Collaborator

@woorui woorui commented Jan 21, 2024

Adding WriteWithTarget api for Source, call it like:

source.WriteWithTarget(0x33, []byte("hello handler"), "target-id-1")

And sfn will receive the payload that be written by source like this:

sfn.SetWantedTarget("target-id-1")

sfn.SetHandler(func(ctx serverless.Context) {
  fmt.Println(ctx.Data())
  ctx.WriteWithTarget(0x34, []byte("hello next"), "target-id-2")
})

And the sfn that has called sfn.SetWantedTarget("target-id-2") will receive data from the above sfn.

The route rules is:

  1. find all sfn in tag.
  2. if the sfn do not called SetWantedTarget, send data to the sfn.
  3. if the sfn called SetWantedTarget, send the data only when dataFrame.Metadata.Target == sfn.WantedTarget.

TODO: cli/wasm support.

Copy link

vercel bot commented Jan 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
yomo ⬜️ Ignored (Inspect) Visit Preview Jan 26, 2024 5:28pm

Copy link

codecov bot commented Jan 21, 2024

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (c9ed644) 59.45% compared to head (8eeda72) 59.58%.

Files Patch % Lines
source.go 71.42% 4 Missing and 2 partials ⚠️
core/server.go 0.00% 2 Missing and 1 partial ⚠️
pkg/frame-codec/y3codec/handshake_frame.go 70.00% 2 Missing and 1 partial ⚠️
core/client.go 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #704      +/-   ##
==========================================
+ Coverage   59.45%   59.58%   +0.12%     
==========================================
  Files          37       37              
  Lines        2733     2781      +48     
==========================================
+ Hits         1625     1657      +32     
- Misses       1009     1019      +10     
- Partials       99      105       +6     

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

@woorui woorui requested review from venjiang, wujunzhuo and fanweixiao and removed request for venjiang January 24, 2024 08:21
@woorui woorui self-assigned this Jan 24, 2024
Copy link
Contributor

@venjiang venjiang left a comment

Choose a reason for hiding this comment

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

how to use SetWantedTarget(string)? any tests?

core/payload/payload.go Outdated Show resolved Hide resolved
@woorui woorui requested a review from venjiang January 24, 2024 10:18
@woorui
Copy link
Collaborator Author

woorui commented Jan 24, 2024

how to use SetWantedTarget(string)? any tests?

I add some tests about target in source_test.go and sfn_test.go files.

@fanweixiao fanweixiao changed the title feat: support route dataframe in target way feat: support route dataframe to dedicate sfn instance Jan 26, 2024
Copy link
Contributor

@venjiang venjiang left a comment

Choose a reason for hiding this comment

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

👍

@woorui woorui merged commit 752305d into master Feb 2, 2024
7 checks passed
@woorui woorui deleted the feat/write-payload branch February 2, 2024 10:40
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