Skip to content

Commit

Permalink
update developer guide
Browse files Browse the repository at this point in the history
  • Loading branch information
acn-ericlaw committed Feb 23, 2024
1 parent 4e38ece commit 12808b8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions guides/APPENDIX-III.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ res.onSuccess(response -> {

In a suspend function using KotlinLambdaFunction, the same logic may look like this:

```kotlin
```java
val fastRPC = FastRPC(headers)
val req = AsyncHttpRequest()
req.setMethod("GET")
Expand Down Expand Up @@ -173,7 +173,7 @@ For simplicity and readability, we recommend using "suspend function" to read th

It may look like this:

```kotlin
```java
val po = PostOffice(headers, instance)
val fastRPC = FastRPC(headers)

Expand Down
2 changes: 1 addition & 1 deletion guides/CHAPTER-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ For example, to make a RPC call to another function, you can use the `awaitReque

Please refer to the `FileUploadDemo` class in the "examples/lambda-example" project.

```kotlin
```java
val po = PostOffice(headers, instance)
val fastRPC = FastRPC(headers)

Expand Down
4 changes: 2 additions & 2 deletions guides/CHAPTER-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ If you prefer coding in Kotlin, you can implement a "suspend function" using the
The following code segment illustrates the creation of the "hello.world" function that makes a non-blocking RPC
call to "another.service".
```kotlin
```java
@PreLoad(route="hello.world", instances=10)
class FileUploadDemo: KotlinLambdaFunction<AsyncHttpRequest, Any> {
override suspend fun handleEvent(headers: Map<String, String>, input: AsyncHttpRequest,
Expand All @@ -223,7 +223,7 @@ class FileUploadDemo: KotlinLambdaFunction<AsyncHttpRequest, Any> {
The API method signature for non-blocking RPC and fork-n-join are as follows:
```kotlin
```java
@Throws(IOException::class)
suspend fun awaitRequest(request: EventEnvelope, timeout: Long): EventEnvelope
Expand Down
2 changes: 1 addition & 1 deletion guides/CHAPTER-7.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public Future<EventEnvelope> request(final EventEnvelope event, long timeout,

### Sequential non-blocking API (Kotlin suspend function)

```kotlin
```java
suspend fun awaitRequest(request: EventEnvelope?, timeout: Long,
headers: Map<String, String>,
eventEndpoint: String, rpc: Boolean): EventEnvelope
Expand Down
23 changes: 19 additions & 4 deletions guides/CHAPTER-9.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,26 @@ response.onSuccess(results -> {

### Make a sequential non-blocking RPC call

You can make a sequential non-blocking RPC call from one function to another. The FastRPC is similar to the PostOffice.
You can make a sequential non-blocking RPC call from one function to another.

The most convenient method to make a sequential non-blocking RPC call is to use the PostOffice's request API.

```java
// for a single RPC call
PostOffice po = new PostOffice(headers, instance);
EventEnvelope result = po.request(requestEvent, timeoutInMills).get();

// for a fork-n-join call
PostOffice po = new PostOffice(headers, instance);
List<EventEnvelope> result = po.request(requestEvents, timeoutInMills).get();
```

If you prefer the Kotlin programming language, you may use the FastRPC API.

It is the event manager for KotlinLambdaFunction. You can create an instance of the FastRPC using the "headers"
parameters in the input arguments of your function.

```kotlin
```java
val fastRPC = new FastRPC(headers)
val request = EventEnvelope().setTo("another.function")
.setHeader("some_key", "some_value").setBody(somePoJo)
Expand All @@ -409,7 +424,7 @@ without consuming a lot of CPU resources because it is "suspended" while waiting

You can make a sequential non-blocking fork-n-join call using the FastRPC API like this:

```kotlin
```java
val fastRPC = FastRPC(headers)
val template = EventEnvelope().setTo("hello.world").setHeader("someKey", "someValue")
val requests = ArrayList<EventEnvelope>()
Expand Down Expand Up @@ -546,7 +561,7 @@ a custom serializer.
```java
public void setCustomSerializer(String route, CustomSerializer mapper);
// e.g.
// platform.setCustomSerializer(new JacksonSerializer());
// platform.setCustomSerializer("my.function", new JacksonSerializer());
```

## Minimalist API design for event orchestration
Expand Down

0 comments on commit 12808b8

Please sign in to comment.