Skip to content

Event driven connection manager - #567

Merged
vkuznecovas merged 6 commits into
masterfrom
event-driven-conn-manager
Nov 27, 2018
Merged

Event driven connection manager#567
vkuznecovas merged 6 commits into
masterfrom
event-driven-conn-manager

Conversation

@vkuznecovas

@vkuznecovas vkuznecovas commented Nov 23, 2018

Copy link
Copy Markdown
Contributor

Connection manager now emits events and stats keeper/sender/session storage subscribe to those.

This means that the connection manager gets rid of 3 dependencies, many of the interfaces get thinner.

As a side note - when moving the stats keeper away from openvpn I had to come up with a way for getting stats out from the connection to the manager, therefore a stats channel has been introduced. This ruined the mobile client entrypoint, but I'll fix that separately once this get's rejected -> fixed -> approved -> merged since it might need a change on go-openvpn.

Please do a thorough review on this one. Really appreciate the opinions/ideas/suggestions.

Take note that the "moved the session storage to client package" commit moves the session storage related stuff to the client package. It seemed like the best place to put it, since after the event driven connection manager change it does not seem to fit in the connection package anymore.

This is also based on the decouple-stats-keeper - so keep that in mind. Once this get's merged in, I'll do some work to rebase the decouple-stats-keeper on master, where I'm expecting quite a few conflicts.

Bonus: wrote session storage tests.

EDIT: changed base to master, will now update this branch with master.

@vkuznecovas
vkuznecovas changed the base branch from decouple-stats-keeper to master November 23, 2018 12:59
@vkuznecovas
vkuznecovas force-pushed the event-driven-conn-manager branch from 56644f1 to 8ea2410 Compare November 23, 2018 13:11
Comment thread services/wireguard/connection.go Outdated
Comment thread client/stats/dto/dto.go Outdated
*/

package stats
package dto

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to move it into a separate dto package it contains the only struct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the stats structure is widely used in the project, we end up in circular references. Since it's client(consumer) related it makes sense to keep it under the client package. So I moved it into its own package :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dto name is really bad here as its too generic and technical also it makes you always alias imports because of its name. Consider moving this stats elsewhere. For example /core/consumer/statistics.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to core/consumer/statistics.go

Comment thread client/stats/keeper.go Outdated
Comment thread client/stats/sender.go Outdated
Comment thread core/connection/manager.go Outdated
Comment thread client/stats/keeper.go Outdated
Comment thread client/stats/keeper.go Outdated
Comment thread client/stats/sender.go Outdated
Comment thread client/stats/sender.go Outdated
Comment thread core/connection/stubs_test.go
@vkuznecovas
vkuznecovas force-pushed the event-driven-conn-manager branch from 8ea2410 to 1e64372 Compare November 26, 2018 10:00

@tadovas tadovas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main concern - code organisation.
💯 points for finally cleaning up openvpn integration (possibly a chance to improve go-openvpn)

Comment thread client/session/session.go
Comment thread client/session/session.go
*/

package connection
package session

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange package name. Why "connection" was bad? Also core -> client rename. As I mentioned earlier, there is no client/server. Consumer/provider

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use appropriate terms defined by functionality. Connection usually means lower level transmission facility whereas session would imply user (session id) and / or authentication somewhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not forget that term usage heavily depends on context in which that term is used (bounded context). In our case connection means established connection between consumer and provider with all ongoing message channels, underlying transport and accounting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case connection (and manager) is high level definition directly controlled by consumer ( through api).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't bad - it just seemed appropriate to move all consumer related event subscribers to a package, in this case - consumer(former client package).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left it under consumer/session for now - if we need a better place for it, #572 is the place to do it.

Comment thread client/session/session_storage.go Outdated
Comment thread client/session/session_storage.go
Comment thread client/stats/dto/dto.go Outdated
*/

package stats
package dto

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dto name is really bad here as its too generic and technical also it makes you always alias imports because of its name. Consider moving this stats elsewhere. For example /core/consumer/statistics.go

Comment thread core/connection/event.go Outdated
Comment thread core/connection/manager.go
Comment thread core/connection/manager.go Outdated
Comment thread core/connection/stub_connection.go Outdated
}

func (cff *connectionFactoryFake) CreateConnection(connectionParams ConnectOptions, stateChannel StateChannel) (Connection, error) {
func (cff *connectionFactoryFake) CreateConnection(connectionParams ConnectOptions, stateChannel StateChannel, statisticsChannel StatisticsChannel) (Connection, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this part of tests? It should not be separate file, also as for stubing it looks too complex?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move this to the stubs file (each and every single one of those had a separate file in the core/connection), but I'd rather not rewrite tests along the pull request that changes a whole lot in the package it's testing. Since the tests were stable for a long time, minimal changes to them assures that one does not break anything with the PR. It might be a candidate for a future refactor though.

Comment thread mobile/mysterium/openvpn_connection_setup.go Outdated
@zolia zolia added this to the Keliukis (0.5) milestone Nov 26, 2018
Comment thread client/stats/sender.go Outdated
zolia
zolia previously requested changes Nov 26, 2018

@zolia zolia left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree with @tadovas remarks. Naming improvements needed.

@vkuznecovas
vkuznecovas force-pushed the event-driven-conn-manager branch from b9e94a7 to c6f7392 Compare November 26, 2018 14:31
@vkuznecovas
vkuznecovas dismissed stale reviews from zolia and tadovas November 26, 2018 14:46

new one please

@vkuznecovas
vkuznecovas requested review from tadovas and zolia November 26, 2018 14:47
Comment thread consumer/statistics/reporter_test.go Outdated
Comment thread core/connection/manager.go Outdated
Comment thread core/connection/manager_test.go Outdated
Comment thread core/connection/stubs_test.go Outdated
Comment thread tequilapi/endpoints/connection.go Outdated
Comment thread tequilapi/endpoints/connection_test.go Outdated
@vkuznecovas
vkuznecovas force-pushed the event-driven-conn-manager branch from c6f7392 to 529858b Compare November 27, 2018 07:04
@vkuznecovas
vkuznecovas force-pushed the event-driven-conn-manager branch from 529858b to ca59f8d Compare November 27, 2018 07:14

@tadovas tadovas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far so good. Just make sure TODOs are registered and we can move on

@soffokl soffokl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@vkuznecovas
vkuznecovas merged commit 1f2f530 into master Nov 27, 2018
@vkuznecovas
vkuznecovas deleted the event-driven-conn-manager branch November 27, 2018 08:26
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.

4 participants