Skip to content

Commit

Permalink
Move row data decoding out of state machine (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
lovetodream committed Jul 6, 2024
1 parent 84068c7 commit c4da4c1
Show file tree
Hide file tree
Showing 17 changed files with 701 additions and 839 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ struct ConnectionStateMachine {
EventLoopPromise<OracleRowStream>,
StatementResult
)
case needMoreData

// Statement streaming
case forwardRows([DataRow])
Expand Down Expand Up @@ -753,29 +752,6 @@ struct ConnectionStateMachine {
}
}

mutating func chunkReceived(
_ buffer: ByteBuffer, capabilities: Capabilities
) -> ConnectionAction {
switch self.state {
case .statement(var statement):
return self.avoidingStateMachineCoW { machine in
let action = statement.chunkReceived(
buffer, capabilities: capabilities
)
machine.state = .statement(statement)
return machine.modify(with: action)
}

case .loggingOff, .closing:
// Might happen if an error is thrown in row decoding and the
// connection is closed immediately after.
return .wait

default:
preconditionFailure("Invalid state: \(self.state)")
}
}

mutating func ioVectorReceived(
_ vector: OracleBackendMessage.InOutVector
) -> ConnectionAction {
Expand Down Expand Up @@ -921,7 +897,6 @@ struct ConnectionStateMachine {
.sendFetch,
.sendFlushOutBinds,
.succeedStatement,
.needMoreData,
.forwardRows,
.forwardStreamComplete,
.forwardCancelComplete,
Expand Down Expand Up @@ -1172,8 +1147,6 @@ extension ConnectionStateMachine {
return .failStatement(promise, with: error, cleanupContext: nil)
case .succeedStatement(let promise, let columns):
return .succeedStatement(promise, columns)
case .needMoreData:
return .needMoreData
case .forwardRows(let rows):
return .forwardRows(rows)
case .forwardStreamComplete(let rows, let cursorID):
Expand Down
Loading

0 comments on commit c4da4c1

Please sign in to comment.