没有合适的资源?快使用搜索试试~ 我知道了~
首页Reactive Programming with Scala and Akka(Pdf格式)
资源详情
资源评论
资源推荐


Table of Contents
Reactive Programming with Scala and Akka
Credits
About the Authors
About the Reviewers
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introducing Reactive Programming
Introduction
The rise of the data age
Tenets of reactive programming
How do tenets blend together?
An example use case
Responsive
Resilient / fault tolerant
The respect failure deserves
Scalable
Storage scaling
Compute scaling
Message-driven
Practices complementing reactive programming
Functional programming
Asynchronous programming
Data streams
Micro-services
RESTful services
Features of a RESTful service
Representations
Messages
URIs
Statelessness
Caching
Some technical use cases of reactive applications
Internet of Things
Reactive electricity measure
Tumblr's architecture
Tumblr's internal firehose
Tools of the trade
The Scala programming language
Akka
SBT
A skeleton SBT project
ScalaTest – a unit testing framework
A word about IDEs
Summary
2. Functional Reactive Programming in Scala
Mutability versus immutability
Collections
List
Map
Set
List transformations
map
flatMap
filter
Sort
foldLeft
foldRight
Lazy val

Function composition
Functors, applicative functors, and monads
The Scalaz dependency
Functor
Applicative functor
Revisiting point and pure
Monad
Indexing files for searching
Function composition revisited
Ease of unit testing
Summary
3. Asynchronous Programming in Scala
Synchronous versus asynchronous programming
Synchronous programming
Asynchronous programming
Futures
Futures as concurrency abstraction
Futures in Scala
How Futures in Scala work
Writing your first Future in Scala
Understanding Futures in Scala
Enter Promise
Composing Futures
Why nested Futures are hard
Building an asynchronous client
Implementing the service
Implementing a client API for CoffeeShop
Query for ShopMenu
Placing an order with CoffeeShop
Canceling an order
Confirming an order
Paying for an order
Example – A simple data crawler using Futures
About the dataset
Structure of the dataset
Goal
A sample RSS XML file
Data crawler workflow
Implementation
RSSReader
Page crawler
Wiring up and moving forward
Summary
4. Akka for Reactive Programming
Concurrency and parallelism
Actor model
Threads and actors
An introduction to Akka
Actor mailbox
Actor systems
Messaging passing
Creating an actor system
Creating an ActorRef
Sending a PizzaRequest to the ActorRef
Actor messages
Mailbox
Dispatcher
Actor path
The actor life cycle
Deadletters
Event streams
Actor deathwatch
Actor supervision
Supervision strategies
OneForOneStrategy
The actor hierarchy
PastaException
The final state
AllForOneStrategy
The actor hierarchy
PastaException
The final state
Summary
5. Building Resilient Application with Akka
An introduction to actor routing
Routers and routees

Routers and routees
Routing logic
RoundRobin Strategy
SmallestMailbox Strategy
RandomRouting Strategy
ScatterGatherFirstCompleted Strategy
BroadCast Strategy
Pizza delivery workflow implementation with actor routing
PizzaShop actor workflow
Taking the order
Finding a chef to prepare the order
Finding the oven to bake the pizza
Concluding remarks
Work pulling patterns
Pizza workflow implementation with the work pulling pattern
Actor mailbox
Types of mailbox implementation
Unbounded mailbox
Bounded mailbox
Unbounded priority and bounded priority mailbox
Akka persistence
Event sourcing
Commands and events
Actors and state
Summary
6. Akka Cluster
Introduction to Akka cluster
Membership life cycle
Elasticsearch RSS links using Akka cluster
Adding nodes elastically
Removing a node (or nodes)
Elasticsearch indexing
Setting up Elasticsearch
Installing the Marvel plugin
Elasticsearch client
Implementation
Master worker protocol
Master
WorkState
Worker
WorkExecutor
Summary
7. Finite State Machines with Akka
Introducing FSM
Relation to actors
Become/unbecome in actors
Writing FSMs with actors
FSM implementation
Implementing FSM for a simple stock price average counter
The problem statement
The approach
Implementation of FSM
Init state → BurstAccept state
BurstAccept state → CalcBurstValues state
CalcBurstValues state → Init state
BurstData
BurstEnd
SessionEnd
All put together
Generated output
Extending further
Concluding remarks
The Agent service
Creating agents
Updating the value of an agent
Reading a value from an agent
Summary
8. Akka Unit Testing
Introducing ScalaTest
Setting up ScalaTest
Setting up the test environment
Our first ScalaTest code
Matchers
Types of matcher
Simple value matchers
String matchers

Boolean operator matchers
Reference matchers
Compound matchers
Property matchers
Marking tests
Asserting exceptions
Putting everything together to test the pizza example
A word about fixtures
Other variants of ScalaTest
WordSpec
FeatureSpec
FlatSpec
IDE support
Specs2
Setting Specs2 in SBT
Rewriting the PizzaOrder example in Specs2
Testing Actors with ScalaTest
Akka TestKit
Testing Actors
Testing FSM
Summary
9. Distributed Systems and Key-Value Stores
Distributed systems
Scalability
Latency
Availability
Partitioning of data
Replication
The consensus problem
The CAP theorem
Differences between CA and CP systems
FLP impossibility result
The importance of timing and order
Timing in distributed systems
Global clock
Local clock
No clock
Lamport's algorithm
Vector clock
Consistency guarantees
Eventually consistent system
DynamoDB
Conflict-Free Replicated Data Type (CRDT)
Sets
GSet (or growth-only set)
ORSet (observed-removed set)
Counters
GCounters (growth-only counters)
PNCounter (positive/negative counter)
Maps
ORMultiMap (observed removed map)
A distributed in-memory key value store
Summary
Index
剩余177页未读,继续阅读















安全验证
文档复制为VIP权益,开通VIP直接复制

评论8