Skip to content

Commit

Permalink
chore: centralize proto files for sdks (#1402)
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Wang <[email protected]>
  • Loading branch information
whynowy authored Dec 1, 2023
1 parent d7a1d78 commit 35ad8d9
Show file tree
Hide file tree
Showing 7 changed files with 530 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pkg/apis/proto/map/v1/map.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2022 The Numaproj Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

option go_package = "github.com/numaproj/numaflow-go/pkg/apis/proto/map/v1";
option java_package = "io.numaproj.numaflow.map.v1";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

package map.v1;

service Map {
// MapFn applies a function to each map request element.
rpc MapFn(MapRequest) returns (MapResponse);

// IsReady is the heartbeat endpoint for gRPC.
rpc IsReady(google.protobuf.Empty) returns (ReadyResponse);
}

/**
* MapRequest represents a request element.
*/
message MapRequest {
repeated string keys = 1;
bytes value = 2;
google.protobuf.Timestamp event_time = 3;
google.protobuf.Timestamp watermark = 4;
}

/**
* MapResponse represents a response element.
*/
message MapResponse {
message Result {
repeated string keys = 1;
bytes value = 2;
repeated string tags = 3;
}
repeated Result results = 1;
}

/**
* ReadyResponse is the health check result.
*/
message ReadyResponse {
bool ready = 1;
}
62 changes: 62 additions & 0 deletions pkg/apis/proto/mapstream/v1/mapstream.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright 2022 The Numaproj Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

option go_package = "github.com/numaproj/numaflow-go/pkg/apis/proto/mapstream/v1";
option java_package = "io.numaproj.numaflow.mapstream.v1";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

package mapstream.v1;

service MapStream {
// MapStreamFn applies a function to each request element and returns a stream.
rpc MapStreamFn(MapStreamRequest) returns (stream MapStreamResponse);

// IsReady is the heartbeat endpoint for gRPC.
rpc IsReady(google.protobuf.Empty) returns (ReadyResponse);
}

/**
* MapStreamRequest represents a request element.
*/
message MapStreamRequest {
repeated string keys = 1;
bytes value = 2;
google.protobuf.Timestamp event_time = 3;
google.protobuf.Timestamp watermark = 4;
}

/**
* MapStreamResponse represents a response element.
*/
message MapStreamResponse {
message Result {
repeated string keys = 1;
bytes value = 2;
repeated string tags = 3;
}
Result result = 1;
}

/**
* ReadyResponse is the health check result.
*/
message ReadyResponse {
bool ready = 1;
}
63 changes: 63 additions & 0 deletions pkg/apis/proto/reduce/v1/reduce.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Copyright 2022 The Numaproj Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

option go_package = "github.com/numaproj/numaflow-go/pkg/apis/proto/reduce/v1";
option java_package = "io.numaproj.numaflow.reduce.v1";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";


package reduce.v1;

service Reduce {
// ReduceFn applies a reduce function to a request stream.
rpc ReduceFn(stream ReduceRequest) returns (stream ReduceResponse);

// IsReady is the heartbeat endpoint for gRPC.
rpc IsReady(google.protobuf.Empty) returns (ReadyResponse);
}

/**
* ReduceRequest represents a request element.
*/
message ReduceRequest {
repeated string keys = 1;
bytes value = 2;
google.protobuf.Timestamp event_time = 3;
google.protobuf.Timestamp watermark = 4;
}

/**
* ReduceResponse represents a response element.
*/
message ReduceResponse {
message Result {
repeated string keys = 1;
bytes value = 2;
repeated string tags = 3;
}
repeated Result results = 1;
}

/**
* ReadyResponse is the health check result.
*/
message ReadyResponse {
bool ready = 1;
}
59 changes: 59 additions & 0 deletions pkg/apis/proto/sideinput/v1/sideinput.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2022 The Numaproj Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

option go_package = "github.com/numaproj/numaflow-go/pkg/apis/proto/sideinput/v1";
option java_package = "io.numaproj.numaflow.sideinput.v1";

import "google/protobuf/empty.proto";

package sideinput.v1;

// SideInput is the gRPC service for user-defined Side Inputs.
// It is used to propagate changes in the values of the provided Side Inputs
// which allows access to slow updated data or configuration without needing to retrieve
// it during each message processing.
// Through this service we should should be able to:-
// 1) Invoke retrieval request for a single Side Input parameter, which in turn should
// check for updates and return its latest value.
// 2) Provide a health check endpoint to indicate whether the service is ready to be used.
service SideInput {
// RetrieveSideInput is the endpoint to retrieve the latest value of a given Side Input.
rpc RetrieveSideInput(google.protobuf.Empty) returns (SideInputResponse);

// IsReady is the health check endpoint to indicate whether the service is ready to be used.
rpc IsReady(google.protobuf.Empty) returns (ReadyResponse);
}

/**
* SideInputResponse represents a response to a given side input retrieval request.
*/
message SideInputResponse {
// value represents the latest value of the side input payload
bytes value = 1;
// noBroadcast indicates whether the side input value should be broadcasted to all
// True if value should not be broadcasted
// False if value should be broadcasted
bool no_broadcast = 2;
}

/**
* ReadyResponse is the health check result.
*/
message ReadyResponse {
bool ready = 1;
}
66 changes: 66 additions & 0 deletions pkg/apis/proto/sink/v1/sink.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2022 The Numaproj Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

option go_package = "github.com/numaproj/numaflow-go/pkg/apis/proto/sink/v1";
option java_package = "io.numaproj.numaflow.sink.v1";

import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

package sink.v1;

service Sink {
// SinkFn writes the request to a user defined sink.
rpc SinkFn(stream SinkRequest) returns (SinkResponse);

// IsReady is the heartbeat endpoint for gRPC.
rpc IsReady(google.protobuf.Empty) returns (ReadyResponse);
}

/**
* SinkRequest represents a request element.
*/
message SinkRequest {
repeated string keys = 1;
bytes value = 2;
google.protobuf.Timestamp event_time = 3;
google.protobuf.Timestamp watermark = 4;
string id = 5;
}

/**
* ReadyResponse is the health check result.
*/
message ReadyResponse {
bool ready = 1;
}

/**
* SinkResponse is the individual response of each message written to the sink.
*/
message SinkResponse {
message Result {
// id is the ID of the message, can be used to uniquely identify the message.
string id = 1;
// success denotes the status of persisting to disk. if set to false, it means writing to sink for the message failed.
bool success = 2;
// err_msg is the error message, set it if success is set to false.
string err_msg = 3;
}
repeated Result results = 1;
}
Loading

0 comments on commit 35ad8d9

Please sign in to comment.