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
struct NullType | |
{ | |
}; | |
template <typename... Ts> | |
struct TypeList; | |
template <typename Head, typename... Tail> | |
struct TypeList<Head, Tail...> | |
{ |
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
// *************** behavior_scatter_hierarchy.h *************** | |
template <class T, class U> | |
struct TypeList | |
{ | |
using Head = T; | |
using Tail = U; | |
}; | |
struct NullType |
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
➜ python python3 nxnrecurse.py | |
1 2 3 4 5 | |
2 4 6 8 10 | |
3 6 9 12 15 | |
4 8 12 16 20 | |
5 10 15 20 25 | |
➜ python vi nxnrecurse.py | |
➜ python cat nxnrecurse.py |
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
import asyncio | |
import concurrent.futures | |
import threading | |
import uuid | |
from timeit import default_timer as timer | |
class NoConnectionAvailableError(Exception): | |
def __init__(self, msg): |
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
for i in {1..5}; do | |
VAL1=$((i % 2)); | |
VAL2=$(( ($VAL1 + 1) % 2)); | |
curl -H "Content-Type: application/json" \ | |
-X POST \ | |
-d '{"userID":'"${VAL1}"',"message":"Hello user '"${VAL1}"' from user '"${VAL2}"'!"}' \ | |
http://localhost:8080/v1/conversation/123; | |
echo; | |
done |
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
case PostMessage(conversationID, sender, message) => | |
context.log.info( | |
s"Received a command: PostMessage(conversationID=${conversationID}, sender=${sender}, message=${message})" | |
) | |
context.log.info( | |
s"Publishing domain event: MessagePosted(conversationID=${conversationID}, sender=${sender}, message=${message})" | |
) | |
Effect.persist(MessagePosted(conversationID, sender, message)) |
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
def apply(conversationID: ConversationID): Behavior[SessionCommand] = | |
Behaviors.setup[SessionCommand] { context => | |
EventSourcedBehavior[SessionCommand, SessionEvent, ConversationInMemoryState]( | |
persistenceId = PersistenceId.ofUniqueId(conversationID.toString()), | |
emptyState = ConversationInMemoryState( | |
mutable.Map[ConversationID, List[(UserID, String)]]() | |
), | |
commandHandler = { (state, command) => commandHandler(state, command, context) }, | |
eventHandler = { (state, event) => eventHandler(state, event, context) } | |
) |
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
override def onMessage(msg: SessionCommand): Behavior[SessionCommand] = | |
msg match { | |
case PostMessage(conversationID, sender, message) => | |
context.log.info(s"${sender} posted to conversation ${conversationID}: ${message}") | |
persistentEventSourcedActor ! PostMessage(conversationID, sender, message) | |
idle() | |
case GetHistory(conversationID, requester, replyTo) => | |
context.log.info(s"Retrieving history of conversation ${conversationID} for ${requester}") | |
val maybeHistory: Future[ConversationHistory] = | |
persistentEventSourcedActor.ask(GetHistory(conversationID, requester, _)) |
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
case SessionTimeout(conversationID) => | |
sessions -= conversationID // remove session from the cache | |
context.log.info(s"Session timed out for conversation ${conversationID}") | |
this |
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
case SessionTimeout(conversationID) => | |
sessions -= conversationID // remove session from the cache | |
context.log.info(s"Session timed out for conversation ${conversationID}") | |
this |
NewerOlder