-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt Kafka ingress tests to event shape changes (#203)
- Loading branch information
1 parent
7d03797
commit 895b16e
Showing
9 changed files
with
142 additions
and
21 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
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,16 @@ | ||
syntax = "proto3"; | ||
|
||
option java_package = "dev.restate.e2e.services.eventhandler"; | ||
option java_outer_classname = "EventHandlerProto"; | ||
|
||
import "google/protobuf/empty.proto"; | ||
import "dev/restate/ext.proto"; | ||
import "dev/restate/events.proto"; | ||
|
||
package eventhandler; | ||
|
||
service EventHandler { | ||
option (dev.restate.ext.service_type) = KEYED; | ||
|
||
rpc Handle (dev.restate.Event) returns (google.protobuf.Empty); | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...ava-services/src/main/java/dev/restate/e2e/services/eventhandler/EventHandlerService.java
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,25 @@ | ||
package dev.restate.e2e.services.eventhandler; | ||
|
||
import com.google.protobuf.Empty; | ||
import dev.restate.e2e.services.counter.CounterGrpc; | ||
import dev.restate.e2e.services.counter.CounterProto; | ||
import dev.restate.generated.Event; | ||
import dev.restate.sdk.blocking.RestateBlockingService; | ||
import io.grpc.stub.StreamObserver; | ||
|
||
public class EventHandlerService extends EventHandlerGrpc.EventHandlerImplBase | ||
implements RestateBlockingService { | ||
|
||
@Override | ||
public void handle(Event event, StreamObserver<Empty> responseObserver) { | ||
restateContext() | ||
.oneWayCall( | ||
CounterGrpc.getAddMethod(), | ||
CounterProto.CounterAddRequest.newBuilder() | ||
.setCounterName(event.getKey().toStringUtf8()) | ||
.setValue(Long.parseLong(event.getPayload().toStringUtf8())) | ||
.build()); | ||
responseObserver.onNext(Empty.getDefaultInstance()); | ||
responseObserver.onCompleted(); | ||
} | ||
} |
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,25 @@ | ||
import * as restate from "@restatedev/restate-sdk"; | ||
|
||
import { Empty } from "./generated/google/protobuf/empty"; | ||
import { EventHandler, protobufPackage } from "./generated/event_handler"; | ||
import { Event } from "./generated/dev/restate/events"; | ||
import { CounterClientImpl } from "./generated/counter"; | ||
|
||
export const EventHandlerFQN = protobufPackage + ".EventHandler"; | ||
|
||
export class EventHandlerService implements EventHandler { | ||
async handle(event: Event): Promise<Empty> { | ||
console.log("handleEvent: " + JSON.stringify(event)); | ||
const ctx = restate.useContext(this); | ||
|
||
const counterClient = new CounterClientImpl(ctx); | ||
await ctx.oneWayCall(() => | ||
counterClient.add({ | ||
counterName: event.key.toString(), | ||
value: parseInt(event.payload.toString()), | ||
}) | ||
); | ||
|
||
return Empty.create({}); | ||
} | ||
} |
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