This file contains hidden or 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
CREATE KEYSPACE user_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}; | |
CREATE TABLE user_keyspace.user_by_first_name ( | |
firstname text PRIMARY KEY, | |
email text, | |
id uuid, | |
lastname text | |
); | |
CREATE TABLE user_keyspace.user_by_id ( | |
id uuid PRIMARY KEY, | |
email text, |
This file contains hidden or 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
class NetworkCallExampleTest extends AsyncFlatSpec { | |
it should "verify the future returns with for and yield" in { | |
val networkCallExample = new NetworkCallExample | |
// More fluent version | |
for { | |
_ <- networkCallExample.lengthOfTheResponse("testurl") | |
status <- networkCallExample.statusOfSomeOtherResponse("some other url") | |
} yield { | |
assert(status == 200) | |
} |
This file contains hidden or 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
class NetworkCallExampleTest extends AsyncFlatSpec { | |
it should "verify the future returns with for and yield" in { | |
val networkCallExample = new NetworkCallExample | |
for{ | |
res <- networkCallExample.lengthOfTheResponse("testurl") | |
} yield { | |
assert(res == 10) | |
} | |
} | |
} |
This file contains hidden or 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
import org.scalatest.FlatSpec | |
import org.scalatest.concurrent.ScalaFutures | |
class NetworkCallExampleTest extends FlatSpec with ScalaFutures { | |
it should "verify the future returns when complete" in { | |
val networkCallExample = new NetworkCallExample | |
//This will fail with a time out error | |
whenReady(networkCallExample.lengthOfTheResponse("testurl")) { res => | |
assert(res == 10) | |
} |
This file contains hidden or 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
import scala.concurrent.{ExecutionContext, Future} | |
class NetworkCallExample { | |
implicit val ec: ExecutionContext = ExecutionContext.Implicits.global | |
private def getResponseFromServer(url: String): Future[Int] = { | |
Future { | |
Thread.sleep(5000) | |
10 |
This file contains hidden or 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
# Keyspace Name | |
keyspace: keyspace_to_load_test | |
# The CQL for creating a keyspace (optional if it already exists) | |
keyspace_definition: | | |
CREATE KEYSPACE keyspace_to_load_test with replication = {'class': 'SimpleStrategy', 'replication_factor' : '3'} | |
# Table name | |
table: table_to_load_test |
This file contains hidden or 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
// Define your publisher | |
ConnectableObservable<Integer> integerObservable = Observable.fromIterable(integerList) | |
.map(integer -> integer * 2) | |
.publish(); | |
// Define your subscribers | |
Disposable subscribe1 = integerObservable | |
.map(integer -> integer * 10) | |
.subscribe(integer -> System.out.println("From first subscriber: " + integer)); |
This file contains hidden or 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
List<Integer> integerList = IntStream.range(1, 11).boxed().collect(Collectors.toList()); | |
Observable<Integer> integerObservable = Observable.fromIterable(integerList) | |
.map(integer -> integer * 2); | |
Disposable subscribe1 = integerObservable | |
.map(integer -> integer * 10) | |
.subscribe(integer -> System.out.println("From first subscriber: "+integer)); | |
Disposable subscribe2 = integerObservable |
This file contains hidden or 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
<modules> | |
<module>maven-reactor-app</module> | |
<module>maven-reactor-util</module> | |
</modules> |
This file contains hidden or 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
<dependency> | |
<groupId>com.indywiz.springorama.reactor</groupId> | |
<artifactId>maven-reactor-util</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
</dependency> |