-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yashash H L <[email protected]> Co-authored-by: Vigith Maurice <[email protected]>
- Loading branch information
Showing
24 changed files
with
1,042 additions
and
120 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 |
---|---|---|
@@ -1 +1 @@ | ||
edition = "2021" | ||
edition = "2021" |
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "flatmap-stream" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
tonic = "0.12.0" | ||
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } | ||
numaflow = { path = "../../numaflow" } |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM rust:1.82-bullseye AS build | ||
|
||
RUN apt-get update | ||
RUN apt-get install protobuf-compiler -y | ||
|
||
WORKDIR /numaflow-rs | ||
COPY ./ ./ | ||
WORKDIR /numaflow-rs/examples/flatmap-stream | ||
|
||
# build for release | ||
RUN cargo build --release | ||
|
||
# our final base | ||
FROM debian:bullseye AS flatmap-stream | ||
|
||
# copy the build artifact from the build stage | ||
COPY --from=build /numaflow-rs/target/release/flatmap-stream . | ||
|
||
# set the startup command to run your binary | ||
CMD ["./flatmap-stream"] |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
TAG ?= stable | ||
PUSH ?= false | ||
IMAGE_REGISTRY = quay.io/numaio/numaflow-rs/flatmap-stream:${TAG} | ||
DOCKER_FILE_PATH = examples/flatmap-stream/Dockerfile | ||
|
||
.PHONY: update | ||
update: | ||
cargo check | ||
cargo update | ||
|
||
.PHONY: image | ||
image: update | ||
cd ../../ && docker build \ | ||
-f ${DOCKER_FILE_PATH} \ | ||
-t ${IMAGE_REGISTRY} . | ||
@if [ "$(PUSH)" = "true" ]; then docker push ${IMAGE_REGISTRY}; fi | ||
|
||
.PHONY: clean | ||
clean: | ||
-rm -rf target |
29 changes: 29 additions & 0 deletions
29
examples/flatmap-stream/manifests/simple-flatmap-stream.yaml
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: numaflow.numaproj.io/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: simple-flatmap-stream | ||
spec: | ||
vertices: | ||
- name: in | ||
source: | ||
# A self data generating source | ||
generator: | ||
rpu: 300 | ||
duration: 1s | ||
keyCount: 5 | ||
value: 5 | ||
- name: cat | ||
scale: | ||
min: 1 | ||
udf: | ||
container: | ||
image: quay.io/numaio/numaflow-rs/flatmap-stream:stable | ||
- name: out | ||
sink: | ||
# A simple log printing sink | ||
log: { } | ||
edges: | ||
- from: in | ||
to: cat | ||
- from: cat | ||
to: out |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use numaflow::mapstream; | ||
use numaflow::mapstream::Message; | ||
use tokio::sync::mpsc::Sender; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { | ||
mapstream::Server::new(Cat).start().await | ||
} | ||
|
||
struct Cat; | ||
|
||
#[tonic::async_trait] | ||
impl mapstream::MapStreamer for Cat { | ||
async fn map_stream(&self, input: mapstream::MapStreamRequest, tx: Sender<Message>) { | ||
let payload_str = String::from_utf8(input.value).unwrap_or_default(); | ||
let splits: Vec<&str> = payload_str.split(',').collect(); | ||
|
||
for split in splits { | ||
let message = Message::new(split.as_bytes().to_vec()) | ||
.with_keys(input.keys.clone()) | ||
.with_tags(vec![]); | ||
if tx.send(message).await.is_err() { | ||
break; | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.