Skip to content

Commit d97f268

Browse files
authored
Internal: Rename Command Contexts (#147)
1 parent 3b3416a commit d97f268

File tree

10 files changed

+39
-39
lines changed

10 files changed

+39
-39
lines changed

Sources/PostgresNIO/New/Connection State Machine/ConnectionStateMachine.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ struct ConnectionStateMachine {
8585
// --- general actions
8686
case sendParseDescribeBindExecuteSync(query: String, binds: [PSQLEncodable])
8787
case sendBindExecuteSync(statementName: String, binds: [PSQLEncodable])
88-
case failQuery(ExecuteExtendedQueryContext, with: PSQLError, cleanupContext: CleanUpContext?)
89-
case succeedQuery(ExecuteExtendedQueryContext, columns: [PSQLBackendMessage.RowDescription.Column])
90-
case succeedQueryNoRowsComming(ExecuteExtendedQueryContext, commandTag: String)
88+
case failQuery(ExtendedQueryContext, with: PSQLError, cleanupContext: CleanUpContext?)
89+
case succeedQuery(ExtendedQueryContext, columns: [PSQLBackendMessage.RowDescription.Column])
90+
case succeedQueryNoRowsComming(ExtendedQueryContext, commandTag: String)
9191

9292
// --- streaming actions
9393
// actions if query has requested next row but we are waiting for backend
@@ -100,8 +100,8 @@ struct ConnectionStateMachine {
100100

101101
// Prepare statement actions
102102
case sendParseDescribeSync(name: String, query: String)
103-
case succeedPreparedStatementCreation(CreatePreparedStatementContext, with: PSQLBackendMessage.RowDescription?)
104-
case failPreparedStatementCreation(CreatePreparedStatementContext, with: PSQLError, cleanupContext: CleanUpContext?)
103+
case succeedPreparedStatementCreation(PrepareStatementContext, with: PSQLBackendMessage.RowDescription?)
104+
case failPreparedStatementCreation(PrepareStatementContext, with: PSQLError, cleanupContext: CleanUpContext?)
105105

106106
// Close actions
107107
case sendCloseSync(CloseTarget)

Sources/PostgresNIO/New/Connection State Machine/ExtendedQueryStateMachine.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
struct ExtendedQueryStateMachine {
33

44
enum State {
5-
case initialized(ExecuteExtendedQueryContext)
6-
case parseDescribeBindExecuteSyncSent(ExecuteExtendedQueryContext)
5+
case initialized(ExtendedQueryContext)
6+
case parseDescribeBindExecuteSyncSent(ExtendedQueryContext)
77

8-
case parseCompleteReceived(ExecuteExtendedQueryContext)
9-
case parameterDescriptionReceived(ExecuteExtendedQueryContext)
10-
case rowDescriptionReceived(ExecuteExtendedQueryContext, [PSQLBackendMessage.RowDescription.Column])
11-
case noDataMessageReceived(ExecuteExtendedQueryContext)
8+
case parseCompleteReceived(ExtendedQueryContext)
9+
case parameterDescriptionReceived(ExtendedQueryContext)
10+
case rowDescriptionReceived(ExtendedQueryContext, [PSQLBackendMessage.RowDescription.Column])
11+
case noDataMessageReceived(ExtendedQueryContext)
1212

1313
/// A state that is used if a noData message was received before. If a row description was received `bufferingRows` is
1414
/// used after receiving a `bindComplete` message
15-
case bindCompleteReceived(ExecuteExtendedQueryContext)
15+
case bindCompleteReceived(ExtendedQueryContext)
1616
case bufferingRows([PSQLBackendMessage.RowDescription.Column], CircularBuffer<[PSQLData]>, readOnEmpty: Bool)
1717
case waitingForNextRow([PSQLBackendMessage.RowDescription.Column], CircularBuffer<[PSQLData]>, EventLoopPromise<StateMachineStreamNextResult>)
1818

@@ -27,9 +27,9 @@ struct ExtendedQueryStateMachine {
2727
case sendBindExecuteSync(statementName: String, binds: [PSQLEncodable])
2828

2929
// --- general actions
30-
case failQuery(ExecuteExtendedQueryContext, with: PSQLError)
31-
case succeedQuery(ExecuteExtendedQueryContext, columns: [PSQLBackendMessage.RowDescription.Column])
32-
case succeedQueryNoRowsComming(ExecuteExtendedQueryContext, commandTag: String)
30+
case failQuery(ExtendedQueryContext, with: PSQLError)
31+
case succeedQuery(ExtendedQueryContext, columns: [PSQLBackendMessage.RowDescription.Column])
32+
case succeedQueryNoRowsComming(ExtendedQueryContext, commandTag: String)
3333

3434
// --- streaming actions
3535
// actions if query has requested next row but we are waiting for backend
@@ -46,7 +46,7 @@ struct ExtendedQueryStateMachine {
4646

4747
var state: State
4848

49-
init(queryContext: ExecuteExtendedQueryContext) {
49+
init(queryContext: ExtendedQueryContext) {
5050
self.state = .initialized(queryContext)
5151
}
5252

Sources/PostgresNIO/New/Connection State Machine/PrepareStatementStateMachine.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
struct PrepareStatementStateMachine {
33

44
enum State {
5-
case initialized(CreatePreparedStatementContext)
6-
case parseDescribeSent(CreatePreparedStatementContext)
5+
case initialized(PrepareStatementContext)
6+
case parseDescribeSent(PrepareStatementContext)
77

8-
case parseCompleteReceived(CreatePreparedStatementContext)
9-
case parameterDescriptionReceived(CreatePreparedStatementContext)
8+
case parseCompleteReceived(PrepareStatementContext)
9+
case parameterDescriptionReceived(PrepareStatementContext)
1010
case rowDescriptionReceived
1111
case noDataMessageReceived
1212

@@ -15,16 +15,16 @@ struct PrepareStatementStateMachine {
1515

1616
enum Action {
1717
case sendParseDescribeSync(name: String, query: String)
18-
case succeedPreparedStatementCreation(CreatePreparedStatementContext, with: PSQLBackendMessage.RowDescription?)
19-
case failPreparedStatementCreation(CreatePreparedStatementContext, with: PSQLError)
18+
case succeedPreparedStatementCreation(PrepareStatementContext, with: PSQLBackendMessage.RowDescription?)
19+
case failPreparedStatementCreation(PrepareStatementContext, with: PSQLError)
2020

2121
case read
2222
case wait
2323
}
2424

2525
var state: State
2626

27-
init(createContext: CreatePreparedStatementContext) {
27+
init(createContext: PrepareStatementContext) {
2828
self.state = .initialized(createContext)
2929
}
3030

Sources/PostgresNIO/New/PSQLChannelHandler.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ final class PSQLChannelHandler: ChannelDuplexHandler {
417417
}
418418

419419
private func succeedQueryWithRowStream(
420-
_ queryContext: ExecuteExtendedQueryContext,
420+
_ queryContext: ExtendedQueryContext,
421421
columns: [PSQLBackendMessage.RowDescription.Column],
422422
context: ChannelHandlerContext)
423423
{
@@ -448,7 +448,7 @@ final class PSQLChannelHandler: ChannelDuplexHandler {
448448
}
449449

450450
private func succeedQueryWithoutRowStream(
451-
_ queryContext: ExecuteExtendedQueryContext,
451+
_ queryContext: ExtendedQueryContext,
452452
commandTag: String,
453453
context: ChannelHandlerContext)
454454
{

Sources/PostgresNIO/New/PSQLConnection.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ final class PSQLConnection {
131131
return self.channel.eventLoop.makeFailedFuture(PSQLError.tooManyParameters)
132132
}
133133
let promise = self.channel.eventLoop.makePromise(of: PSQLRows.self)
134-
let context = ExecuteExtendedQueryContext(
134+
let context = ExtendedQueryContext(
135135
query: query,
136136
bind: bind,
137137
logger: logger,
@@ -151,7 +151,7 @@ final class PSQLConnection {
151151

152152
func prepareStatement(_ query: String, with name: String, logger: Logger) -> EventLoopFuture<PSQLPreparedStatement> {
153153
let promise = self.channel.eventLoop.makePromise(of: PSQLBackendMessage.RowDescription?.self)
154-
let context = CreatePreparedStatementContext(
154+
let context = PrepareStatementContext(
155155
name: name,
156156
query: query,
157157
logger: logger,
@@ -170,7 +170,7 @@ final class PSQLConnection {
170170
return self.channel.eventLoop.makeFailedFuture(PSQLError.tooManyParameters)
171171
}
172172
let promise = self.channel.eventLoop.makePromise(of: PSQLRows.self)
173-
let context = ExecuteExtendedQueryContext(
173+
let context = ExtendedQueryContext(
174174
preparedStatement: preparedStatement,
175175
bind: bind,
176176
logger: logger,

Sources/PostgresNIO/New/PSQLRows.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class PSQLRows {
2525
private let jsonDecoder: PSQLJSONDecoder
2626

2727
init(rowDescription: [PSQLBackendMessage.RowDescription.Column],
28-
queryContext: ExecuteExtendedQueryContext,
28+
queryContext: ExtendedQueryContext,
2929
eventLoop: EventLoop,
3030
cancel: @escaping () -> (),
3131
next: @escaping () -> EventLoopFuture<StateMachineStreamNextResult>)

Sources/PostgresNIO/New/PSQLTask.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
enum PSQLTask {
2-
case extendedQuery(ExecuteExtendedQueryContext)
3-
case preparedStatement(CreatePreparedStatementContext)
2+
case extendedQuery(ExtendedQueryContext)
3+
case preparedStatement(PrepareStatementContext)
44
case closeCommand(CloseCommandContext)
55

66
func failWithError(_ error: PSQLError) {
@@ -15,7 +15,7 @@ enum PSQLTask {
1515
}
1616
}
1717

18-
final class ExecuteExtendedQueryContext {
18+
final class ExtendedQueryContext {
1919
enum Query {
2020
case unnamed(String)
2121
case preparedStatement(name: String, rowDescription: PSQLBackendMessage.RowDescription?)
@@ -58,7 +58,7 @@ final class ExecuteExtendedQueryContext {
5858

5959
}
6060

61-
final class CreatePreparedStatementContext {
61+
final class PrepareStatementContext {
6262
let name: String
6363
let query: String
6464
let logger: Logger

Tests/PostgresNIOTests/New/Connection State Machine/ConnectionStateMachineTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ConnectionStateMachineTests: XCTestCase {
103103
let queryPromise = eventLoopGroup.next().makePromise(of: PSQLRows.self)
104104

105105
var state = ConnectionStateMachine()
106-
let extendedQueryContext = ExecuteExtendedQueryContext(
106+
let extendedQueryContext = ExtendedQueryContext(
107107
query: "Select version()",
108108
bind: [],
109109
logger: .psqlTest,

Tests/PostgresNIOTests/New/Connection State Machine/ExtendedQueryStateMachineTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ExtendedQueryStateMachineTests: XCTestCase {
1010
let promise = EmbeddedEventLoop().makePromise(of: PSQLRows.self)
1111
promise.fail(PSQLError.uncleanShutdown) // we don't care about the error at all.
1212
let query = "DELETE FROM table WHERE id=$0"
13-
let queryContext = ExecuteExtendedQueryContext(query: query, bind: [1], logger: logger, jsonDecoder: JSONDecoder(), promise: promise)
13+
let queryContext = ExtendedQueryContext(query: query, bind: [1], logger: logger, jsonDecoder: JSONDecoder(), promise: promise)
1414

1515
XCTAssertEqual(state.enqueue(task: .extendedQuery(queryContext)), .sendParseDescribeBindExecuteSync(query: query, binds: [1]))
1616
XCTAssertEqual(state.parseCompleteReceived(), .wait)
@@ -28,7 +28,7 @@ class ExtendedQueryStateMachineTests: XCTestCase {
2828
let queryPromise = EmbeddedEventLoop().makePromise(of: PSQLRows.self)
2929
queryPromise.fail(PSQLError.uncleanShutdown) // we don't care about the error at all.
3030
let query = "SELECT version()"
31-
let queryContext = ExecuteExtendedQueryContext(query: query, bind: [], logger: logger, jsonDecoder: JSONDecoder(), promise: queryPromise)
31+
let queryContext = ExtendedQueryContext(query: query, bind: [], logger: logger, jsonDecoder: JSONDecoder(), promise: queryPromise)
3232

3333
XCTAssertEqual(state.enqueue(task: .extendedQuery(queryContext)), .sendParseDescribeBindExecuteSync(query: query, binds: []))
3434
XCTAssertEqual(state.parseCompleteReceived(), .wait)
@@ -59,7 +59,7 @@ class ExtendedQueryStateMachineTests: XCTestCase {
5959
let promise = EmbeddedEventLoop().makePromise(of: PSQLRows.self)
6060
promise.fail(PSQLError.uncleanShutdown) // we don't care about the error at all.
6161
let query = "DELETE FROM table WHERE id=$0"
62-
let queryContext = ExecuteExtendedQueryContext(query: query, bind: [1], logger: logger, jsonDecoder: JSONDecoder(), promise: promise)
62+
let queryContext = ExtendedQueryContext(query: query, bind: [1], logger: logger, jsonDecoder: JSONDecoder(), promise: promise)
6363

6464
XCTAssertEqual(state.enqueue(task: .extendedQuery(queryContext)), .sendParseDescribeBindExecuteSync(query: query, binds: [1]))
6565
XCTAssertEqual(state.parseCompleteReceived(), .wait)

Tests/PostgresNIOTests/New/Connection State Machine/PrepareStatementStateMachineTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PrepareStatementStateMachineTests: XCTestCase {
1111

1212
let name = "haha"
1313
let query = #"SELECT id FROM users WHERE id = $1 "#
14-
let prepareStatementContext = CreatePreparedStatementContext(
14+
let prepareStatementContext = PrepareStatementContext(
1515
name: name, query: query, logger: .psqlTest, promise: promise)
1616

1717
XCTAssertEqual(state.enqueue(task: .preparedStatement(prepareStatementContext)),
@@ -36,7 +36,7 @@ class PrepareStatementStateMachineTests: XCTestCase {
3636

3737
let name = "haha"
3838
let query = #"DELETE FROM users WHERE id = $1 "#
39-
let prepareStatementContext = CreatePreparedStatementContext(
39+
let prepareStatementContext = PrepareStatementContext(
4040
name: name, query: query, logger: .psqlTest, promise: promise)
4141

4242
XCTAssertEqual(state.enqueue(task: .preparedStatement(prepareStatementContext)),

0 commit comments

Comments
 (0)