Skip to content

Commit

Permalink
Issue 304: Chat Application Example (#306)
Browse files Browse the repository at this point in the history
Created a Chat Application demo that exemplifies the user of Key-Value Tables, Streams, and Stream Cuts.

Signed-off-by: Andrei Paduroiu <andrei.paduroiu@emc.com>
  • Loading branch information
andreipaduroiu authored Aug 30, 2021
1 parent 8209799 commit 8de6623
Show file tree
Hide file tree
Showing 6 changed files with 990 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ more complex applications as sub-projects, which show use-cases exploiting one o
| `noop` | Example of how to add a simple callback executed upon a read event. | [Java](pravega-client-examples/src/main/java/io/pravega/example/noop)
| `statesynchronizer` | Application that allows users to work with `StateSynchronizer` API via CLI. | [Java](pravega-client-examples/src/main/java/io/pravega/example/statesynchronizer)
| `streamcuts` | Application examples demonstrating the use of `StreamCut`s via CLI. | [Java](pravega-client-examples/src/main/java/io/pravega/example/streamcuts)
| `tables` | Application examples demonstrating the use of `KeyValueTable`s via CLI. | [Java](pravega-client-examples/src/main/java/io/pravega/example/tables)

The related documentation and instructions are [here](pravega-client-examples).

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
### Pravega dependencies
pravegaVersion=0.10.0-2917.d58e537-SNAPSHOT
pravegaVersion=0.10.0-2943.6c26515-SNAPSHOT
pravegaKeycloakVersion=0.9.0

### Pravega-samples output library
Expand Down
18 changes: 18 additions & 0 deletions pravega-client-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,24 @@ To demonstrate the use of `StreamCut`s, we provide a CLI. To use it, please exec
$ bin/streamCutsCli [-scope myScope] [-name myStream] [-uri tcp://127.0.0.1:9090]
```

## `tables` (ChatApplication)
This application aims to demonstrate the use of `KeyValueTable`s, `Stream`s and`StreamCut`s
for implementing a "serverless" chat application (with Pravega being used as the sole "server" -
there is no specialized chat server). The sample application allows defining users, chat
channels and let users subscribe to those channels; it also enables uses to send messages to each
other. Users receive messages in near-realtime and, upon logging in, get all the messages that
they received while offline. Please refer to the
[ChatClientCli Javadoc](pravega-client-examples/src/main/java/io/pravega/example/tables/ChatClientCli)
for all supported commands within the application.

### Execution

The `ChatApplication` can be run by means of a CLI. To use it, please execute:

```
$ bin/chatClientCli
```

## `secure`
This example includes three applications `SecureReader`, `SecureWriter` and a `SecureBatchReader`
which instantiate the corresponding Pravega clients on the data path. These applications illustrate
Expand Down
24 changes: 24 additions & 0 deletions pravega-client-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ task startStreamCutsCli(type: JavaExec) {
}
}

task scriptChatClientCli(type: CreateStartScripts) {
outputDir = file('build/scripts')
mainClassName = 'io.pravega.example.tables.ChatClientCli'
applicationName = 'chatClientCli'
defaultJvmOpts = ["-Dlogback.configurationFile=file:conf/logback.xml"]
classpath = files(jar.archivePath) + sourceSets.main.runtimeClasspath
}

/**
* This will only work well from the console if all Gradle output is suppressed. That's because it requires user input
* and output using the Console.
*
* Example: ./gradlew startChatClientCli -q --console=plain
*/
task startChatClientCli(type: JavaExec) {
main = "io.pravega.example.tables.ChatClientCli"
standardInput = System.in
classpath = sourceSets.main.runtimeClasspath
if(System.getProperty("exec.args") != null) {
args System.getProperty("exec.args").split()
}
}

task scriptSecureWriter(type: CreateStartScripts) {
outputDir = file('build/scripts')
mainClassName = 'io.pravega.example.secure.SecureWriter'
Expand Down Expand Up @@ -195,6 +218,7 @@ distributions {
from project.scriptSharedConfigCli
from project.scriptNoopReader
from project.scriptStreamCutsCli
from project.scriptChatClientCli
from project.scriptSecureWriter
from project.scriptSecureReader
from project.scriptSecureBatchReader
Expand Down
Loading

0 comments on commit 8de6623

Please sign in to comment.