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

Dummy service which serves Noop tunnel #506

Merged
merged 8 commits into from
Oct 31, 2018

Conversation

Waldz
Copy link
Member

@Waldz Waldz commented Oct 26, 2018

Updates #382

@Waldz Waldz mentioned this pull request Oct 26, 2018
10 tasks
sessionConfigProvider = func() (session.ServiceConfiguration, error) {
return nil, nil
}
log.Info(logPrefix, "Openvpn service started successfully")
Copy link
Contributor

Choose a reason for hiding this comment

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

Openvpn ? Or noop ? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

}

// Wait blocks until service is stopped
func (manager *Manager) Wait() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

This breaks contract. Service is started ( starts return nil - no error), then wait should block until stop is called. I can be simply implemented with channels or wait groups.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

}

// Stop stops service
func (manager *Manager) Stop() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Related to "Wait" comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

func (service *serviceFake) Start(identity.Identity) (dto_discovery.ServiceProposal, session.ConfigProvider, error) {
proposal := dto_discovery.ServiceProposal{}

if service.onStartReturnError != nil {
Copy link
Member

Choose a reason for hiding this comment

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

It can be just return proposal, nil, service.onStartReturnError

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

Choose a reason for hiding this comment

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

this one was not fixed.

// PaymentMethodNoop defines payment method wo payment at all
const PaymentMethodNoop = "NOOP"

// PaymentNoop structure
Copy link
Member

Choose a reason for hiding this comment

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

Should it a private structure? In this case, we can avoid such meaningless comments.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added meaningful docs

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 The "MysteriumNetwork/node" Authors.
* Copyright (C) 2018 The "MysteriumNetwork/node" Authors.
Copy link
Member

Choose a reason for hiding this comment

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

If we are changing it without changing the file, let's do it for every file at once.

Copy link
Contributor

Choose a reason for hiding this comment

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

in a separate pr, preferably

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted, it was a mistake

return nil, ErrUnsupportedServiceType
}

return createConnection(options)
Copy link
Contributor

Choose a reason for hiding this comment

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

createConnection returns service? Maybe createService?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

err error,
) {
proposal = dto_discovery.ServiceProposal{
ServiceType: "noop",
Copy link
Contributor

@zolia zolia Oct 26, 2018

Choose a reason for hiding this comment

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

We could have var serviceType = "noop" constant, which can be reused.

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 The "MysteriumNetwork/node" Authors.
* Copyright (C) 2018 The "MysteriumNetwork/node" Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

in a separate pr, preferably

func (registry *Registry) Create(options Options) (Service, error) {
createConnection, exists := registry.factories[options.Type]
if !exists {
return nil, ErrUnsupportedServiceType
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be nice to return an error containing the type that was specified, not just an error

Copy link
Member Author

Choose a reason for hiding this comment

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

Not my scope. Package "core/connection" and "core/service" already has bunch of errors standardised thru constants.
Feel free to improve it if You see how ;)

@@ -21,6 +21,7 @@ package service
type Options struct {
Identity string
Passphrase string
Type string
Copy link
Contributor

Choose a reason for hiding this comment

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

we could also use an enum here instead of a string, since we're probably gonna have a limited number of service types.

Copy link
Member Author

Choose a reason for hiding this comment

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

Dont agree here. It's hook-able transports so central Core does not know predefined list

Copy link
Member Author

Choose a reason for hiding this comment

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

Plus this structure is from user input, so it's free text - so that it could be validated later

func (service *serviceFake) Start(identity.Identity) (dto_discovery.ServiceProposal, session.ConfigProvider, error) {
proposal := dto_discovery.ServiceProposal{}

if service.onStartReturnError != nil {
Copy link
Member

Choose a reason for hiding this comment

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

this one was not fixed.

tadovas
tadovas previously approved these changes Oct 31, 2018
Copy link
Contributor

@tadovas tadovas left a comment

Choose a reason for hiding this comment

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

Let's do this. More functionality depend on this

zolia
zolia previously approved these changes Oct 31, 2018
Copy link
Contributor

@zolia zolia left a comment

Choose a reason for hiding this comment

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

lgtm

@Waldz Waldz dismissed stale reviews from zolia and tadovas via cbc3e71 October 31, 2018 07:27
Copy link
Contributor

@tadovas tadovas left a comment

Choose a reason for hiding this comment

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

reLGTMed

@tadovas tadovas merged commit 7e976a8 into mysteriumnetwork:master Oct 31, 2018
@Waldz Waldz deleted the feature/noop-service branch October 31, 2018 08:38
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.

5 participants