Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(enginenetx): rename HTTPTransport to Network #1293

Merged
merged 4 commits into from
Sep 22, 2023

Conversation

bassosimone
Copy link
Contributor

@bassosimone bassosimone commented Sep 22, 2023

The HTTPTransport model only offers a CloseIdleConnections callback, which semantics is obviously that of closing idle connections (unsurprisingly).

However, the struct I am slowly building inside the enginenetx package soon will need to write back statistics to disk using a key-value store.

I don't think we should overload the CloseIdleConnections semantics to do this job, since the resulting code would be quite surprising.

Therefore, I have decided to rename HTTPTransport to Network and make it represent all the network abstractions required by the OONI engine.

In time, I will move extra functionality in there. For now, let us be happy that we can easily define a Close method (currently empty) for this type having the usual io.Closer semantics, i.e., that any resource opened by the type itself is released when calling this method.

This diff does the following:

  • it renames the files, the type, and the tests;

  • it introduces a Close method that closes the Network's underlying transport's idle connections;

  • it adapts users of this code to use the new semantics;

  • it introduces an model.KeyValueStore argument for the Network constructor which we're going to use soon to persist statistics;

  • updates CONTRIBUTING.md to say how we do internal testing when the main tests body is external.

Part of ooni/probe#2531

The HTTPTransport model only offers a CloseIdleConnections callback, which
semantics is obviously that of closing idle connections (unsurprisingly).

However, the struct I am slowly building inside the enginenetx package soon will
need to write back statistics to disk using a key-value store.

I don't think we should overload the CloseIdleConnections semantics to do this
job, since the resulting code would be quite surprising.

Therefore, I have decided to rename HTTPTransport to Network and make it
represent all the network abstractions required by the OONI engine.

In time, I will move extra functionality in there. For now, let us be happy
that we can easily define a Close method (currently empty) for this type
having the usual io.Closer semantics, i.e., that any resource opened by the
type itself is released when calling this method.

This diff does the following:

- it renames the files;

- the type;

- the tests;

- it introduces an empty Close method;

- it adapts users of this code to use the new semantics;

- it introduces an model.KeyValueStore argument for the Network constructor
which we're going to use soon to persist statistics.

Part of ooni/probe#2531
@bassosimone bassosimone merged commit e27eead into master Sep 22, 2023
6 checks passed
@bassosimone bassosimone deleted the issue/2531-small branch September 22, 2023 08:06
Murphy-OrangeMud pushed a commit to Murphy-OrangeMud/probe-cli that referenced this pull request Feb 13, 2024
The HTTPTransport model only offers a CloseIdleConnections callback,
which semantics is obviously that of closing idle connections
(unsurprisingly).

However, the struct I am slowly building inside the enginenetx package
soon will need to write back statistics to disk using a key-value store.

I don't think we should overload the CloseIdleConnections semantics to
do this job, since the resulting code would be quite surprising.

Therefore, I have decided to rename HTTPTransport to Network and make it
represent all the network abstractions required by the OONI engine.

In time, I will move extra functionality in there. For now, let us be
happy that we can easily define a Close method (currently empty) for
this type having the usual io.Closer semantics, i.e., that any resource
opened by the type itself is released when calling this method.

This diff does the following:

- it renames the files, the type, and the tests;

- it introduces a Close method that closes the Network's underlying
transport's idle connections;

- it adapts users of this code to use the new semantics;

- it introduces an model.KeyValueStore argument for the Network
constructor which we're going to use soon to persist statistics;

- updates `CONTRIBUTING.md` to say how we do internal testing when the
main tests body is external.

Part of ooni/probe#2531
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant