trait StateMachine[+R <: Response] extends AnyRef
A StateMachine
is responsible for managing the connection state and expose a Request => Future[Response]
regardless
of the number of actual request / response cycles required with a backend server.
That is, for any particular client request / response cycle, multiple request / response cycles are usually required
with the postgresql backend. This requires coordinating state with the backend which is what is encapsulated in
StateMachine
implementations.
StateMachine
s have a public type parameter to represent the response type that it will eventually produce.
They also have an internal type parameter to represent its internal state representation.
StateMachine
only encapsulates the state transitions, not the state itself, which must be maintained externally
(i.e.: in some kind of runner). That is, implementations provide a starting state and a way to transition to another
state. The "current state" must be maintained in whatever is encapsulating the connection
(specifically, in com.twitter.finagle.postgresql.ClientDispatcher for the finagle client.)
StateMachine
s are responsible for eventually producing the response to the client's request as well as eventually
reaching a completion state which leaves the connection ready for a new client request. Note that responding to the
client with the response does not necessarily occur at the same time the state machine completing. That is, the
client response may be produced while the state machine still exchanges messages with the backend on the connection.
- R
The type of client response eventually produced by the state machine implementation.
- Alphabetic
- By Inheritance
- StateMachine
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract type State
Abstract Value Members
- abstract def receive(state: State, msg: BackendMessage): TransitionResult[State, R]
Given the current state and a message from the backend server, this method will produce the appropriate transition to execute.
Given the current state and a message from the backend server, this method will produce the appropriate transition to execute.
Specifically, this may be additional messages to send to the backend, a response to send to the client, etc.
- state
the current state of the connection previously returned by a call to
start
orreceive
.- msg
the message received from the backend server
- returns
the transition to execute to realize the new state
- abstract def start: TransitionResult[State, R]
The initial transition to execute upon starting this particular machine.
The initial transition to execute upon starting this particular machine. Normally, this will contain
Send
actions to send messages to the Postgres backend.- returns
the initial transition to execute upon starting the machine.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()