DEV Community

Leveraging the Layer-cake design in Go

Adele Reed on May 17, 2019

It's no secret that I love go's multi-threading support. It's a one-liner for a new thread: go func(){}() And a three liner (minimum) to tal...
Collapse
 
bgadrian profile image
Adrian B.G.

A few notes

Goroutines are not threads, you can use the term lightweight threads but that also could confuse the devs that does not know what they actually mean.

Os.Exit is not actually fine, the other layers may remain in memory processing and doing their stuff on different system threads. You need to send the shutdown signal to all your layers and goroutines. Easiest way is by cancelling a Context.

Collapse
 
virepri profile image
Adele Reed • Edited

I appreciate the feedback, man.

I understand goroutines aren't threads on their own, and that they're more akin to scheduled tasks.

And I actually didn't know that there were lingering side-effects of os.Exit (the docs don't exactly go into that), thanks for pointing that out.

Collapse
 
theodesp profile image
Theofanis Despoudis

I didn't know anything about the Cake pattern until recently when I read this article

However so far I'm not impressed.