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
Conversation
c245174
to
bd1625f
Compare
Reviewers: please consider checking this branch out ( |
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. |
There was a problem hiding this 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!
|
||
package server | ||
|
||
// Cell implements a generic HTTP server. Provides the 'Server' API |
There was a problem hiding this comment.
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
// 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...?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
// 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. |
There was a problem hiding this comment.
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) | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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") | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
cilium$ go run ./daemon hive dot-graph | dot -Tx11 | ||
|
||
Guidelines |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Documentation/spelling_wordlist.txt
Outdated
@@ -680,6 +692,7 @@ mediabot | |||
memcache | |||
memcached | |||
memcd | |||
memoized |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
|
||
cilium$ go run ./daemon hive dot-graph | dot -Tx11 | ||
|
||
Guidelines |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...)
There was a problem hiding this 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.
539f3c4
to
2814a79
Compare
2814a79
to
b4e6d43
Compare
There was a problem hiding this 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!
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>
b4e6d43
to
12c6d51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Full CI is not required, and seems like most (if not all) of the comments are addressed. Merging. |
Add the initial hive documentation to the cilium docs