yomorun / yomo

🦖 Stateful Serverless Framework for Geo-distributed Edge AI Infra. with function calling support, write once, run on any model.
https://yomo.run
Apache License 2.0
1.66k stars 128 forks source link

feat: support route dataframe to dedicate sfn instance #704

Closed woorui closed 7 months ago

woorui commented 7 months ago

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.

vercel[bot] commented 7 months ago

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

1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **yomo** | ⬜️ Ignored ([Inspect](https://vercel.com/yomorun/yomo/ADuGhMJ2YzmsnuPGnawqYTYqZVj1)) | [Visit Preview](https://yomo-git-feat-write-payload-yomorun.vercel.app) | | Jan 26, 2024 5:28pm |
codecov[bot] commented 7 months ago

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 :warning:
core/server.go 0.00% 2 Missing and 1 partial :warning:
pkg/frame-codec/y3codec/handshake_frame.go 70.00% 2 Missing and 1 partial :warning:
core/client.go 33.33% 2 Missing :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

woorui commented 7 months ago

how to use SetWantedTarget(string)? any tests?

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