You are here |
konradreiche.com | ||
| | | |
jbrandhorst.com
|
|
| | | | Sometimes when you're writing a server, you've got a function that consumes a lot of memory while running, or some other resource, and you might be worrying that a sudden burst of requests could crash the server, since gRPC by default will just spawn another goroutine to handle any incoming requests, oblivious to the danger. In these situations, it can be useful to implement some custom request throttling. Here I'll show an easy way to accomplish this with the use of a Go channel. | |
| | | |
matttproud.com
|
|
| | | | Pop quiz, hot shot: what is the behavior of func f (as defined below) when it is called from a bare gRPC method or HTTP handler as go f(ctx) using the context.Context provided to the handler?1 1 2 3 4 5 6 7 8 9 10 11 func f(ctx context.Context) { // Flimsily make it improbable for this function to continue while the // handler is serving. time.Sleep(time.Second) select { case <-time. | |
| | | |
matttproud.com
|
|
| | | | I would like to propose a set of neologisms for the Go Programming Language based on emergent language use: context awareness: noun, the state of an API being cognizant of and respecting the semantics of the context API. Example: Function f has context awareness. context-aware or1 context aware: phrasal adjective, whether an API has context awareness. Examples: The API consumes a context-aware function value like function f. Function f is context aware. | |
| | | |
golangdocs.com
|
|
| | In many cases, multiple parameters are needed to be passed in a function. Sometimes we know how many and other times we don't. Golang variadic function |