Skip to content
This repository was archived by the owner on Jul 15, 2018. It is now read-only.

WIP Changed Service interface #114

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

WIP Changed Service interface #114

wants to merge 2 commits into from

Conversation

jaekwon
Copy link
Contributor

@jaekwon jaekwon commented Dec 26, 2017

Service could be much simplified.
We shouldn't be masking race conditions by letting the caller call Start/Stop willy nilly. If one needs to rely on such patterns, it's probably because one has racy buggy software.

Now that we know better, lets refactor and test Tendermint to see how racy it is.

We don't use Restart as far as I know.


The caller must ensure that Start and Stop are not called concurrently.
Services can be started, then stopped, then optionally restarted.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, no it can't be restarted.


String() string

SetServiceCore(ServiceCore)
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the new usage of ServiceCore. However, shouldn't we also make ServiceCore implement the String() method if Service implicitly invokes OnStart() and OnStop() of the ServiceCore?

Copy link
Contributor

Choose a reason for hiding this comment

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

The String is just the name passed into NewBaseService

<-bs.Quit
// SetServiceCore impleents SetServiceCore
func (bs *BaseService) SetServiceCore(service ServiceCore) {
bs.impl = service
Copy link
Contributor

Choose a reason for hiding this comment

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

While I see an atomic protection for started and stopped, there is none for logger and impl which sure by contract will only be set once, but if we've got mutual exclusion for some fields, why not for all of them?
This makes sure that our service our bullet proof and not reliant on the user, who can potentially breach the contract.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should clarify which things should and shouldn't be called multiple times or concurrently in the comments, but it might be confusing to make things thread safe when they shouldnt be

@adrianbrink
Copy link
Contributor

@odeke-em I like the idea of protecting everything. What do you think about just removing SetLogger and SetServiceCore from the interface. Both need to be passed into the constructor and then it can only be started and stopped.

@ebuchman ebuchman changed the base branch from sdk2 to develop February 3, 2018 05:16
@jaekwon
Copy link
Contributor Author

jaekwon commented Feb 7, 2018

Just noting that we'll want to expose the quit chan somehow. Maybe Quit() <- struct{}

Copy link
Contributor

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

I like the simplification. PR still needs some work.


String() string

SetServiceCore(ServiceCore)
Copy link
Contributor

Choose a reason for hiding this comment

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

The String is just the name passed into NewBaseService

<-bs.Quit
// SetServiceCore impleents SetServiceCore
func (bs *BaseService) SetServiceCore(service ServiceCore) {
bs.impl = service
Copy link
Contributor

Choose a reason for hiding this comment

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

We should clarify which things should and shouldn't be called multiple times or concurrently in the comments, but it might be confusing to make things thread safe when they shouldnt be

@ebuchman
Copy link
Contributor

ebuchman commented Feb 9, 2018

@greg-szabo let's add this to next release (not 0.16) and discuss on monday

@ebuchman
Copy link
Contributor

damn we forgot to talk about this. maybe we do need to use an organization level kanban @greg-szabo @jolesbi

@jbibla
Copy link

jbibla commented Feb 13, 2018

@greg-szabo can you put it on the tendermint meeting agenda for next week? alternatively, someone can set up a call to discuss. #zoomzoom 🚗

@ebuchman
Copy link
Contributor

We should move the Service to Tendermint. It's the only consumer AFAIK.

Same with the timers!

@zramsay
Copy link
Contributor

zramsay commented Jul 3, 2018

this PR is now captured in tendermint/tendermint#1882 but let's leave it open for now so the branch doesn't get deleted, or close and delete if obsolete

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants