Description (?) • Non-functional requirements • Technology stack • General overview of the system architecture • REST API • How to define • How to test • Flow as an Actor • How to define • Future Composition • How to test • Store Actors • Brief overview • Bonus • Loan Pattern 2
Overview Server Flow Actor Flow Actors PUT GET GetEntity Flow Actor SetEntity REST API Actor Riak Store Actor Riak Store Actor Store Actors GetEntityById UpdateEntity Riak Riak Client Streaming 6
API Server Flow Actor Flow Actors PUT GET GetEntity Flow Actor SetEntity REST API Actor Riak Store Actor Riak Store Actor Store Actors GetEntityById UpdateEntity Riak Riak Client Streaming 7
Route: RequestContext => Unit • Directives: Building block to construct complex route structures. • It does transforming, filtering, extracting from, and completing the request context and passing the result to inner directives. 11
as an Actor Server Flow Actor Flow Actors PUT GET GetEntity Flow Actor SetEntity REST API Actor Riak Store Actor Riak Store Actor Store Actors GetEntityById UpdateEntity Riak Riak Client Streaming 21
Actor • Actors are responsible to handle the business logic of the system • Per request a new flow actor is created (thanks to actor because they are lightweight) • Flow actors are children of ApiActor (implementation of RestApi) • Currently, supervision strategy is default which means upon exception the actor is restarted (is it right???!) 25
Future is an object holding a value which may become available at some point. • Future Composition: Chaining multiple futures without without being blocked. 27
Flow Actor Flow Actors PUT GET GetEntity Flow Actor SetEntity REST API Actor Riak Store Actor Riak Store Actor Store Actors GetEntityById UpdateEntity Riak Riak Client Store Actors Streaming 33
actors are the children of flow actors. So, per request we will have a flow actor together with a store actor as its child. • Driver friendly data types are the communication media at this level. • We use Riak Client Library to communicate to riak using its HTTP interface. Since it uses actors to provide non-blocking client, its model is consistent with our model. (future composition etc.) • Everything in Riak is key-value. We use JSON format for our values => Same marshalling and unmarshalling mechanism exists at RestApi level needed here which is encapsulated by Riak client. • Decreasing impedance mismatch??! • Bucket settings are done in store actors. 34
• Loan Pattern: it would loan a resource to your function • Usage: Hiding Java boiler-plate code while working with resources • Ingredient: Typed higher order curried function. 36
can be modeled as actors in an actor system. With this facts, non-blocking calls are there! • Complexities of asynchronous programming are hidden using future composition. • Using internal DSLs increases the readability and maintainability (debatable!) of the code. • Using appropriate internal DSLs breaks the program into isolated building blocks. 39