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

Refactoring of the project, give more coherence to the Registration struct #36

Closed
wants to merge 2 commits into from

Conversation

Soulou
Copy link
Member

@Soulou Soulou commented Jan 25, 2018

Fixes #35

@Soulou Soulou force-pushed the fix/35/refactoring branch from 5419807 to 1205609 Compare January 25, 2018 11:44
@@ -25,15 +19,15 @@ const (
// This service will launch two go routines. The first one will maintain the
// registration every 5 seconds and the second one will check if the service
// credentials don't change and notify otherwise
func Register(ctx context.Context, service string, host Host) *Registration {
func Register(serviceName string, host Host) (*Registration, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you keep the context here to forward it to the NewRegistration function?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is just no need of context in here, as I wanted to use the context to stop the registration, but it's not possible.

When a context is canceled, there is no way to way for the registration to remove itself cleanly from etcd synchronously, the entity which canceled the context will keep its execution, like shutting down the application.

Now the Registration can be Stop(), which is synchronous and do it in a clean manner, it's a better way to handle the lifecycle of the Registration. The context cancellation not being used anymore, there was no more requirement of the context.

cancel context.CancelFunc
shutdownErr error

credsWatcher chan Credentials
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a few comments to explain the purpose of these channels?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep

time.Sleep(time.Second)
}

for err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

after the previous loop, err equals nil. Will it ever enter this loop? Not sure.

User: "Moi",
Password: "Lui",
}
// Convey("After a service registration", t, func() {
Copy link
Member

Choose a reason for hiding this comment

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

Remove 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.

woupsy, thanks

@EtienneM
Copy link
Member

@Soulou you may just have forgotten to push your changes here?

@Soulou
Copy link
Member Author

Soulou commented Feb 13, 2018

I actually have not done them yet..

@Soulou
Copy link
Member Author

Soulou commented Jan 28, 2020

Closing, we won't work on etcd-discovery anymore, it will be replaced by something else

@Soulou Soulou closed this Jan 28, 2020
@EtienneM EtienneM deleted the fix/35/refactoring branch January 29, 2020 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve structure of the project which is no super always coherent
2 participants