From b51995a73c82368a8b9415d97ba9cf79a727df55 Mon Sep 17 00:00:00 2001 From: svenvc Date: Thu, 7 Mar 2024 11:43:15 +0100 Subject: [PATCH 1/2] P3Client>>#close changed to signal P3ConnectionClosed after the connection is actually fully closed (rename logDisconnecting to logDisconnected) --- P3/P3Client.class.st | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/P3/P3Client.class.st b/P3/P3Client.class.st index 312f044..a81bd06 100644 --- a/P3/P3Client.class.st +++ b/P3/P3Client.class.st @@ -142,14 +142,13 @@ P3Client >> clearTextPasswordMessage [ P3Client >> close [ "Cleanly close my connection with the server" - connection - ifNotNil: [ - [ - self logDisconnecting. - self writeMessage: #[] tag: $X. - connection close ] on: Error do: [ ]. - self clearSession. - connection := nil ] + connection ifNotNil: [ + [ + self writeMessage: #[] tag: $X. + connection close ] on: Error do: [ ]. + self clearSession. + connection := nil. + self logDisconnected ] ] { #category : #public } @@ -514,7 +513,7 @@ P3Client >> logConnected [ ] { #category : #'private - logging' } -P3Client >> logDisconnecting [ +P3Client >> logDisconnected [ (self newLogEvent: P3ConnectionClosedEvent) emit ] From 29d48c2ad0441a662413e1e647b0f85edcbedca4 Mon Sep 17 00:00:00 2001 From: svenvc Date: Thu, 7 Mar 2024 18:02:27 +0100 Subject: [PATCH 2/2] P3Client compactUrl, statePrintString added, printOn: updated --- P3/P3Client.class.st | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/P3/P3Client.class.st b/P3/P3Client.class.st index a81bd06..1d55f7e 100644 --- a/P3/P3Client.class.st +++ b/P3/P3Client.class.st @@ -151,6 +151,15 @@ P3Client >> close [ self logDisconnected ] ] +{ #category : #accessing } +P3Client >> compactUrl [ + ^ self url + scheme: #psql; + password: nil; + queryRemoveAll; + yourself +] + { #category : #public } P3Client >> connect [ "Connect me to a PostgreSQL database. @@ -719,11 +728,16 @@ P3Client >> preparedStatementNamed: name [ P3Client >> printOn: stream [ super printOn: stream. stream nextPut: $(. - stream print: self url. - self session ifNotNil: [ stream space; print: session ]. + self printStateOn: stream. stream nextPut: $) ] +{ #category : #printing } +P3Client >> printStateOn: stream [ + stream print: self compactUrl. + self session ifNotNil: [ stream space; print: session ] +] + { #category : #private } P3Client >> processBackendKeyData: payload [ session := payload uint32. @@ -1103,6 +1117,11 @@ P3Client >> startupOptions: optionsString [ settings at: #options put: optionsString ] +{ #category : #printing } +P3Client >> statePrintString [ + ^ String streamContents: [ :out | self printStateOn: out ] +] + { #category : #accessing } P3Client >> timeout [ "Return the timeout in seconds I (want to) use, the default being 10 seconds."