-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streaming-Serverless in Rx way with CLI support (#70)
* feat(rx): introduce RxStream [#60] * add(serverless): add serverless runtime [#58] * feat(cli): add `yomo dev` command [#61] * doc: update README file for v0.4 Co-authored-by: jjwygjj <[email protected]> Co-authored-by: Hong Xiaojian <[email protected]>
- Loading branch information
1 parent
1901594
commit 071c13b
Showing
27 changed files
with
1,377 additions
and
1,164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ | |
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
vendor/ | ||
yomo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,97 @@ | ||
<p align="center"> | ||
<img width="200px" height="200px" src="https://docs.yomo.run/favicon.ico" /> | ||
</p> | ||
|
||
# YoMo ![Go](https://github.com/yomorun/yomo/workflows/Go/badge.svg) | ||
|
||
YoMo is an open-source Streaming Serverless Framework for building Low-latency Edge Computing applications. Built atop QUIC Transport Protocol and Functional Reactive Programming interface, it makes real-time data processing reliable, secure, and easy. | ||
|
||
More info at [https://yomo.run](https://yomo.run/?utm_source=github&utm_campaign=ossc) <a href="https://vercel.com/?utm_source=cella&utm_campaign=oss" target="_blank"><img src="https://raw.githubusercontent.com/abumalick/powered-by-vercel/master/powered-by-vercel.svg" height="25px" /></a> | ||
|
||
[中文内容在Gitee](https://gitee.com/yomorun/yomo) | ||
|
||
## Getting Started | ||
|
||
### 1. Install the current release | ||
🇨🇳 [简体中文](https://docs.yomo.run/zh) | ||
|
||
Create a directory named `yomotest` and `cd` into it. | ||
## 🚀 Getting Started | ||
|
||
mkdir yomotest | ||
cd yomotest | ||
### 1. Install CLI | ||
|
||
Make the current directory the root of a module by using `go mod init`. | ||
|
||
go mod init yomotest | ||
|
||
Download and install. | ||
```bash | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/yomorun/install/HEAD/install.sh)" | ||
``` | ||
|
||
go get -u github.com/yomorun/yomo | ||
### 2. Create your serverless code | ||
|
||
### 2. Create file `echo.go` | ||
```bash | ||
mkdir yomo-demo && cd $_ && touch app.go | ||
``` | ||
|
||
To check that YoMo is installed correctly on your device, create a file named `echo.go` and copy the following code to your file: | ||
Write your `app.go` code: | ||
|
||
```go | ||
```go | ||
package main | ||
|
||
import ( | ||
"github.com/yomorun/yomo/pkg/yomo" | ||
) | ||
func main() { | ||
// run echo plugin and monitor port 4241; data will be sent by yomo egde | ||
// yomo.Run(&EchoPlugin{}, "0.0.0.0:4241") | ||
// a method for development and testing; when connected to the Internet, it will | ||
// automatically connect to the development server of yomo.run | ||
// after successfully connected to the server, the plugin will receive the value | ||
// of the key specified by the Observed() method every 2 seconds | ||
// yomo.RunDev(&EchoPlugin{}, "localhost:4241") | ||
yomo.RunDevWith(&EchoPlugin{}, "localhost:4241", yomo.OutputEchoData) | ||
} | ||
// EchoPlugin - a yomo plugin that converts received data into strings and appends | ||
// additional information to the strings; the modified data will flow to the next plugin | ||
type EchoPlugin struct{} | ||
"context" | ||
"fmt" | ||
"time" | ||
|
||
// Handle - this method will be called when data flows in; the Observed() method is used | ||
// to tell yomo which key the plugin should monitor; the parameter value is what the plugin | ||
// needs to process | ||
func (p *EchoPlugin) Handle(value interface{}) (interface{}, error) { | ||
return value.(string) + "✅", nil | ||
} | ||
"github.com/yomorun/yomo/pkg/rx" | ||
) | ||
|
||
// Observed - returns a value of type string, which is the key monitored by echo plugin; | ||
// the corresponding value will be passed into the Handle() method as an object | ||
func (p EchoPlugin) Observed() string { | ||
return "0x11" //name | ||
var printer = func(_ context.Context, i interface{}) (interface{}, error) { | ||
value := i.(float32) | ||
fmt.Println("serverless get value:", value) | ||
return value, nil | ||
} | ||
|
||
// Name - sets the name of a given plugin p (mainly used for debugging) | ||
func (p *EchoPlugin) Name() string { | ||
return "EchoPlugin" | ||
} | ||
// Handler will handle data in Rx way | ||
func Handler(rxstream rx.RxStream) rx.RxStream { | ||
stream := rxstream. | ||
Y3Decoder("0x10", float32(0)). | ||
AuditTime(100 * time.Millisecond). | ||
Map(printer). | ||
StdOut() | ||
|
||
// Mold describe the struct of `Observed` value | ||
func (p EchoPlugin) Mold() interface{} { | ||
return "" | ||
return stream | ||
} | ||
``` | ||
|
||
### 3. Build and run | ||
|
||
1. Run `go run echo.go` from the terminal. If YoMo is installed successfully, you will see the following message: | ||
1. Run `yomo dev` from the terminal. you will see the following message: | ||
|
||
```bash | ||
% go run echo.go | ||
[EchoPlugin:6031]2020/07/06 22:14:20 plugin service start... [localhost:4241] | ||
name:yomo!✅ | ||
name:yomo!✅ | ||
name:yomo!✅ | ||
name:yomo!✅ | ||
name:yomo!✅ | ||
^Csignal: interrupt | ||
(20:08:50 ~/yomo/examples)──> yomo dev | ||
2020/12/18 20:09:12 Building the Serverless Function File... | ||
2020/12/18 20:09:14 ✅ Listening on 0.0.0.0:4242 | ||
``` | ||
Congratulations! You have written and tested your first YoMo app. | ||
|
||
Note: If you want to use a complex Mold, please refer to [yomo-echo-plugin](https://github.com/yomorun/yomo-echo-plugin). | ||
Congratulations! You have done your first YoMo application. | ||
|
||
## Illustration | ||
## 🎯 Focuses on computings out of data center | ||
|
||
![yomo-arch](https://yomo.run/yomo-arch.png) | ||
- Latency-sensitive applications. | ||
- Networking situation with packet loss or high latency. | ||
- Handling continuous high frequency generated data with stream-processing. | ||
- Building Complex systems with Streaming-Serverless architecture. | ||
|
||
### YoMo focuses on: | ||
## 🌟 Why YoMo | ||
|
||
- Industrial IoT: | ||
- On the IoT device side, real-time communication with a latency of less than 10ms is required. | ||
- On the smart device side, AI performing with a high hash rate is required. | ||
- YoMo consists of 2 parts: | ||
- `yomo-edge`: deployed on company intranet; responsible for receiving device data and executing each yomo-plugin in turn according to the configuration | ||
- `yomo-plugin`: can be deployed on public cloud, private cloud, and `yomo-edge-server` | ||
|
||
### Why YoMo | ||
|
||
- Based on QUIC (Quick UDP Internet Connection) protocol for data transmission, which uses the User Datagram Protocol (UDP) as its basis instead of the Transmission Control Protocol (TCP); significantly improves the stability and throughput of data transmission. | ||
- Based on QUIC (Quick UDP Internet Connection) protocol for data transmission, which uses the User Datagram Protocol (UDP) as its basis instead of the Transmission Control Protocol (TCP); significantly improves the stability and throughput of data transmission. Especially for cellular networks like 5G. | ||
- A self-developed `yomo-codec` optimizes decoding performance. For more information, visit [its own repository](https://github.com/yomorun/yomo-codec) on GitHub. | ||
- Based on stream computing, which improves speed and accuracy when dealing with data handling and analysis; simplifies the complexity of stream-oriented programming. | ||
- Secure-by-default from transport protocol. | ||
|
||
## Contributing | ||
## 🦸 Contributing | ||
|
||
First off, thank you for considering making contributions. It's people like you that make YoMo better. There are many ways in which you can participate in the project, for example: | ||
|
||
- File a [bug report](https://github.com/yomorun/yomo/issues/new?assignees=&labels=bug&template=bug_report.md&title=%5BBUG%5D). Be sure to include information like what version of YoMo you are using, what your operating system is, and steps to recreate the bug. | ||
|
||
- Suggest a new feature. | ||
|
||
- Read our [contributing guidelines](https://github.com/yomorun/yomo/blob/master/CONTRIBUTING.md) to learn about what types of contributions we are looking for. | ||
|
||
- We have also adopted a [code of conduct](https://github.com/yomorun/yomo/blob/master/CODE_OF_CONDUCT.md) that we expect project participants to adhere to. | ||
|
||
## Feedback | ||
## 🤹🏻♀️ Feedback | ||
|
||
Email us at [[email protected]](mailto:[email protected]). Any feedback would be greatly appreciated! | ||
Any questions or good ideas, please feel free to come to our [Discussion](https://github.com/yomorun/yomo/discussions). Any feedback would be greatly appreciated! | ||
|
||
## License | ||
|
||
|
Oops, something went wrong.