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

Documentation: Add documentation for hive #23746

Merged
merged 3 commits into from Feb 24, 2023

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Feb 14, 2023

Add the initial hive documentation to the cilium docs

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 14, 2023
@joamaki joamaki added the release-note/misc This PR makes changes that have no direct user impact. label Feb 14, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Feb 14, 2023
@joamaki joamaki marked this pull request as ready for review February 21, 2023 14:20
@joamaki joamaki requested review from a team as code owners February 21, 2023 14:20
@joamaki
Copy link
Contributor Author

joamaki commented Feb 21, 2023

Reviewers: please consider checking this branch out (gh pr checkout 23746) and reading the docs with make -C Documentation live-preview, and also playing with the example in pkg/hive/example. I'd be really interested in hearing how these docs work for you and what's potentially missing or confusing. Thanks!

@qmonnet
Copy link
Member

qmonnet commented Feb 21, 2023

Reviewers: please consider checking this branch out (gh pr checkout 23746) and reading the docs with make -C Documentation live-preview

Or just use the Netlify preview? Or is there any difference that you expect?

@joamaki
Copy link
Contributor Author

joamaki commented Feb 21, 2023

Reviewers: please consider checking this branch out (gh pr checkout 23746) and reading the docs with make -C Documentation live-preview

Or just use the Netlify preview? Or is there any difference that you expect?

Doh, had completely forgotten about that. No I don't expect any difference.

@joamaki
Copy link
Contributor Author

joamaki commented Feb 21, 2023

https://deploy-preview-23746--docs-cilium-io.netlify.app/contributing/development/hive.html

Copy link
Member

@bimmlerd bimmlerd left a comment

Choose a reason for hiding this comment

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

Couple of nits, but generally awesome!

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved

package server

// Cell implements a generic HTTP server. Provides the 'Server' API
Copy link
Member

Choose a reason for hiding this comment

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

At this point, saying just Cell implements ... it sounds like you're talking about Cells in general. Maybe

Suggested change
// Cell implements a generic HTTP server. Provides the 'Server' API
// This cell implements a generic HTTP server. Provides the 'Server' API

I briefly thought calling it ServerCell would be better, but it stutters (server.ServerCell). So maybe differentiate Identifiers from concepts using quoting, maybe `Cell` implements...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed it to The server cell implements... and kept it as server.Cell

"HTTP Server", // Module title (for documentation)

// Provide "provides" the application with a constructor for one or more
// objects. It is lazy and won't be called unless Invoke()'d (directly, or
Copy link
Member

Choose a reason for hiding this comment

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

On the fence about this one, but calling out the lazyness at this point already I think is a bit premature. I think the purpose of Provide is enough to take in at this stage, and the lazyness can come up in the more detailed intro to it.

In addition, I think here it could just be Provide the application with a constructor for the server, ie keep it concrete to the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think it's fine to drop mentioning that it's lazy. I'm anyway mentioning it later.

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
Comment on lines +96 to +106
// This cell isn't a Module, but rather just a plain Invoke. An Invoke
// is a cell that, unlike Provide, is always executed. Invoke functions
// can depend on values that constructors registered with Provide() can
// return. These constructors are then called and their results remembered.
Copy link
Member

Choose a reason for hiding this comment

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

mhh maybe this makes it tricky to remove the lazyness intro above. I still think we'd gain clarity but unsure how to then explain this invoke. The Invoke, in general, I think is the most difficult to grasp intuitively based on the name. 🤔

func registerHelloHandler(srv server.Server) {
srv.RegisterHandler("/hello", helloHandler)
}

Copy link
Member

Choose a reason for hiding this comment

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

how about another quick break, maybe

Now, to put it all together, let's combine our cells into hive in the main package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added couple breaks.

// to fill it from the command-line flags.
flags.Int("server-port", def.ServerPort, "Sets the HTTP server listen port")
}

Copy link
Member

Choose a reason for hiding this comment

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

mabe a quick sentence that this is now a separate package and file, something like

Let's now look at a consumer of this cell, the hello package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved

cilium$ go run ./daemon hive dot-graph | dot -Tx11

Guidelines
Copy link
Member

Choose a reason for hiding this comment

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

These deserve an introduction sentence. Maybe even call out specifically that these can and should be used as Code review comments like https://github.com/golang/go/wiki/CodeReviewComments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
Documentation/spelling_wordlist.txt Outdated Show resolved Hide resolved
@@ -680,6 +692,7 @@ mediabot
memcache
memcached
memcd
memoized
Copy link
Member

Choose a reason for hiding this comment

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

Typo on this one, please fix the docs and remove it from this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't see the typo, but rephrased it anyway.

Copy link
Member

@qmonnet qmonnet Feb 24, 2023

Choose a reason for hiding this comment

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

OK my bad, I didn't know the term (and thought you meant memorized, obviously)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Then it's best I changed it to something less obscure :D

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved

cilium$ go run ./daemon hive dot-graph | dot -Tx11

Guidelines
Copy link
Member

Choose a reason for hiding this comment

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

Do we have any kind of CI check to enforce these guidelines? To me, some of them look easy to miss, and developers won't always think of checking this list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a test (daemon/cmd/cells_test.go) checks that the hive can be instantiated which potentially catches side-effects in the constructors. For the rest they need to be specifically tested for (e.g. cell's integration test checks with goleak that Stop() cleans up). If I do come up with guidelines and a generic way of testing for it I'll definitely implement it. (Already have some ideas about being able to enforce dependency direction...)

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
@qmonnet qmonnet added the area/documentation Impacts the documentation, including textual changes, sphinx, or other doc generation code. label Feb 21, 2023
pkg/hive/example/mini/main.go Outdated Show resolved Hide resolved
pkg/hive/example/mini/main.go Outdated Show resolved Hide resolved
Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
Copy link
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

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

I still have to review all the example code yet, but docs looks good to me, minus other reviewers comments.
Just a nit left inline.

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
@joamaki joamaki force-pushed the pr/joamaki/hive-docs branch 2 times, most recently from 539f3c4 to 2814a79 Compare February 22, 2023 17:46
@joamaki joamaki requested a review from qmonnet February 22, 2023 17:47
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

Found one typo (this time I think it's a real one :) ).

The rest looks all good from my side, thanks for addressing the feedback. The intro reads much better!

Documentation/contributing/development/hive.rst Outdated Show resolved Hide resolved
The prior example was a bit too abstract, so rewrite it instead
to showcase hive with an HTTP server with pluggable handlers.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
Add a very minimal example of how something like uber/dig is implemented on
top of the "reflect" package for those curious about the internals.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
Add the initial hive documentation to the cilium docs.

Signed-off-by: Jussi Maki <jussi@isovalent.com>
Copy link
Member

@qmonnet qmonnet left a comment

Choose a reason for hiding this comment

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

Thanks!

@joamaki joamaki added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Feb 24, 2023
@sayboras
Copy link
Member

Full CI is not required, and seems like most (if not all) of the comments are addressed. Merging.

@sayboras sayboras merged commit 365e19e into cilium:master Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Impacts the documentation, including textual changes, sphinx, or other doc generation code. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants