Simone Basso
eed51978ca
refactor(httpx): hide the real APIClient ( #648 )
...
As mentioned in https://github.com/ooni/probe/issues/1951 , one of
the main issues I did see with httpx.APIClient is that in some cases
it's used in a very fragile way by probeservices.Client.
This happens in psiphon.go and tor.go, where we create a copy of
the APIClient and then modify it's Authorization field.
If we ever refactor probeservices.Client to take a pointer to
httpx.Client, we are now mutating the httpx.Client.
Of course, we don't want that to happen.
This diff attempts to address such a problem as follows:
1. we create a new APIClientTemplate type that holds the same
fields of an APIClient and allows to build an APIClient
2. we modify every user of APIClient to use APIClientTemplate
3. when we need an APIClient, we build it from the corresponding
template and, when we need to use a specific Authorization, we
use a build factory that sets APIClient.Authorization
4. we hide APIClient by renaming it apiClient and by defining
an interface called APIClient that allows to use it
So, now the codebase always uses the opaque APIClient interface to
issue API calls and always uses the APIClientTemplate to build an
opaque APIClient.
Boom! We have separated construction from usage and we are not
mutating in weird ways the APIClient anymore.
2022-01-05 14:15:42 +01:00
..
experiment
refactor(httpx): hide the real APIClient ( #648 )
2022-01-05 14:15:42 +01:00
geolocate
refactor(httpx): hide the real APIClient ( #648 )
2022-01-05 14:15:42 +01:00
httpheader
[forwardport] release 3.11: update all the dependencies ( #636 ) ( #637 )
2021-12-06 17:46:13 +01:00
httpx
refactor(httpx): hide the real APIClient ( #648 )
2022-01-05 14:15:42 +01:00
internal
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
legacy
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
mockable
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
netx
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
probeservices
refactor(httpx): hide the real APIClient ( #648 )
2022-01-05 14:15:42 +01:00
testdata
fix: add missing files causing tests to fail ( #202 )
2021-02-02 14:18:22 +01:00
.gitignore
feat: support embedding encrypted psiphon config ( #285 )
2021-04-02 17:36:06 +02:00
allexperiments.go
refactor: introduce and use InputOrStaticDefault ( #632 )
2021-12-03 15:30:56 +01:00
doc.go
feat(engine): allow runner to return many measurements ( #527 )
2021-09-30 00:54:52 +02:00
experiment.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
experiment_integration_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
experiment_internal_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
experiment_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
experimentbuilder.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
experimentbuilder_test.go
chore: merge probe-engine into probe-cli ( #201 )
2021-02-02 12:05:47 +01:00
inputloader.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
inputloader_network_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
inputloader_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
inputprocessor.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
inputprocessor_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
saver.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
saver_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
session.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
session_integration_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
session_internal_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
session_nopsiphon.go
[forwardport] fix(mk): do nothing if we already have psiphon config ( #605 ) ( #606 )
2021-11-19 12:40:10 +01:00
session_nopsiphon_test.go
[forwardport] fix(mk): do nothing if we already have psiphon config ( #605 ) ( #606 )
2021-11-19 12:40:10 +01:00
session_psiphon.go
[forwardport] fix(mk): do nothing if we already have psiphon config ( #605 ) ( #606 )
2021-11-19 12:40:10 +01:00
session_psiphon_test.go
[forwardport] fix(mk): do nothing if we already have psiphon config ( #605 ) ( #606 )
2021-11-19 12:40:10 +01:00
submitter.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00
submitter_test.go
refactor: interfaces and data types into the model package ( #642 )
2022-01-03 13:53:23 +01:00