@@ -5,7 +5,6 @@ import akka.actor._
5
5
import akka .util .duration ._
6
6
import javax .servlet .{ServletRequest , ServletResponse , AsyncContext }
7
7
import Endpoints ._
8
- import Http ._
9
8
import Async ._
10
9
11
10
/**
@@ -15,18 +14,18 @@ class AsyncActor extends Actor with LoggingFSM[State, Data] {
15
14
16
15
implicit def res2HttpRes (res : ServletResponse ) = res.asInstanceOf [HttpServletResponse ]
17
16
implicit def req2HttpReq (req : ServletRequest ) = req.asInstanceOf [HttpServletRequest ]
18
- val endpointTimeout = context.system.http .endpointRetrievalTimeout
17
+ val endpointTimeout = HttpExtension ( context.system) .endpointRetrievalTimeout
19
18
20
19
startWith(Idle , Empty )
21
20
22
21
when(Idle ) {
23
22
case Event (async : AsyncContext , Empty ) =>
24
23
val url = async.getRequest.getPathInfo
25
- log.debug(" Started async for '{}'" , url)
26
- context.system.http .endpoints ! Find (url)
27
- goto(Started ) using Context (async, url)
24
+ log.debug(" AboutToProcess$ async for '{}'" , url)
25
+ HttpExtension ( context.system) .endpoints ! Find (url)
26
+ goto(AboutToProcess ) using Context (async, url)
28
27
}
29
- when(Started , endpointTimeout millis) {
28
+ when(AboutToProcess , endpointTimeout millis) {
30
29
case Event (Found (EndpointFunc (func)), ctx@ Context (_, url)) =>
31
30
log.debug(" Processing async for '{}'" , url)
32
31
safeProcess(func, ctx)
@@ -37,9 +36,9 @@ class AsyncActor extends Actor with LoggingFSM[State, Data] {
37
36
log.debug(" No endpoint received within {} millis for '{}'" , endpointTimeout, url)
38
37
safeProcess(NotFound , ctx)
39
38
}
40
- when(Completing ) {
39
+ when(AboutToComplete ) {
41
40
case Event (Complete (completing), ctx@ Context (async, url)) =>
42
- log.debug(" Completing async for '{}'" , url)
41
+ log.debug(" AboutToComplete$ async for '{}'" , url)
43
42
44
43
def doComplete (callback : Callback ) {
45
44
val success = try {
@@ -93,25 +92,24 @@ class AsyncActor extends Actor with LoggingFSM[State, Data] {
93
92
catch InternalErrorOnException (async.url)
94
93
95
94
// we want receive different messages before responding, for example 'Timeout'
96
- goto(Completing ) using async
95
+ goto(AboutToComplete ) using async
97
96
}
98
97
99
98
def safeProcess (actor : ActorRef , async : Context ): State = {
100
99
try actor ! async.context.getRequest
101
100
catch InternalErrorOnException (async.url)
102
101
103
102
// actor should respond with Complete(..) message
104
- goto(Completing ) using async
103
+ goto(AboutToComplete ) using async
105
104
}
106
105
}
107
106
108
107
109
108
object Async {
110
109
sealed trait State
111
110
case object Idle extends State
112
- case object Started extends State
113
- case object ProcessingRequest extends State
114
- case object Completing extends State
111
+ case object AboutToProcess extends State
112
+ case object AboutToComplete extends State
115
113
116
114
sealed trait Data
117
115
case class Context (context : AsyncContext , url : String ) extends Data
0 commit comments