跨流程传递截止日期和取消信号
The golang context documentation says :
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
I also read concrete examples of context, but I don't see any information on carring deadlines and cancellation signals
across processes.
How does signals work across processes?
Are they reliable like, if service1 sends a cancel signal but it dies, and signal is lost, what happens now?
Sorry to break your enthusiasm, but the context
package cannot be used as-is for inter-process communication and signaling.
The wording here may be a little imperfect, as in the "context" of the context
package documentation most people would think of "processes" as an OS process entity. But the word "process" has multiple meanings, and the more general "a set of activities that interact to achieve a result" meaning is used here (from Wikipedia: Process). To avoid ambiguity, "goroutines" or "a set of goroutines" would be more appropriate here, but within the same Go application.
Note that when the context
package was first published as a separate, experimental package (not as part of the standard library), this blog post explained its background and uses: Go Concurrency Patterns: Context. The context
haven't change since it was integrated into the standard library, and that blog post did not mention the word "process", not even once.