Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have the peergrouper publish the apiservers over the central hub. #6669
Conversation
howbazaar
added some commits
Dec 7, 2016
| @@ -101,11 +111,15 @@ type pgWorker struct { | ||
| publisher publisherInterface | ||
| providerSupportsSpaces bool | ||
| + | ||
| + // hub is the central hub of the apiserver, and is used to pusblish the |
| +// Hub defines the only method of the apiserver centralhub that | ||
| +// the peer grouper uses. | ||
| +type Hub interface { | ||
| + Publish(topic pubsub.Topic, data interface{}) (<-chan struct{}, error) |
natefinch
Dec 8, 2016
•
Contributor
If you made Publish take a simple string instead of a pubsub.Topic, you could avoid importing pubsub here (and everywhere else that defines a similar interface).
The only benefit to the Topic type is that it's already a TopicMatcher.... but all that does is prevent you from needing two subscribes - one for a single topic (the common case) and one with a matcher (less common).
If you instead wrote publish & subscribe like this:
Publish(topic string, data interface{}) (<-chan struct{}, error)
Subscribe(topic string, handler func(string, interface{})) (unsubscribe func())
SubscribeMatches(match func(string)bool, handler func(string, interface{})) (unsubscribe func())Then things that get dependency injected wouldn't need to import pubsub at all.
Also then you wouldn't need to import pubsub when you define a topic and its types, as in the file above (messages.go)
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
|
Build failed: Tests failed |
|
$$merge$$ |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
howbazaar commentedDec 7, 2016
Also refactors the peergrouper to use clock.Clock interface rather than time directly.