ways to

do things

(a review)

whoami

 

who is Peter

 

3 parts

 

  • Actor stuff
  • Running stuff
  • Orchestration stuff

Do What Things?

 

What to Do with the Things

 

  • start
  • run
  • cancel
  • finish
  • restart

How to Do the Things

 

  • concurrently
  • correctly
  • in a testeable way

examples #1

 

  • one thing

  • several things

  • several concurrent things

    • no control
    • client side control
    • server side control

examples #2

cancelation

  • orchestration via channels

  • close chan pattern

  • context.Done()

example #3

BSK's contextx overview

 

socialpoint-labs/bsk/contextx

example #4

errgroup

golang.org/sync/errgroup

provides synchronization, error propagation, and Context cancelation for groups of goroutines working on subtasks of a common task

Go calls the given function in a new goroutine.

The first call to return a non-nil error cancels the group; its error will be returned by Wait.

example #5

Peter's oklog/run

github.com/oklog/run

Actors are defined as a pair of functions: an execute function [...] and an interrupt function [...] Finally, invoke Run, which blocks until the first actor returns.
Package run is somewhat similar to package errgroup, except it doesn't require actor goroutines to understand context semantics.

erlang's

a primer on

erlang

golang

actors/gen_server -

call() / cast() -

handle_call() / handle_cast()

goroutines -

buffered/unbuffered channels

{

Supervisors

If supervisors are supposed to be processes which do nothing but make sure their children are restarted when they die, workers are processes in charge of doing actual work, and that may die while doing so. They are usually not trusted.

Supervision trees

Restart strategies

one for one

one for all

rest for one

@TODO

a lib with a mix of:

  • errgroup-like context support
  • multiple restart strategies like erlang/OTP
  • other lifecycle states: ready, stopping (@jhvaras)

Conclusions

  • Conhardcurrisency
  • Do concurrent tests for concurrent code
  • Watch Peter's talk
  • Learn from the masters (not me lol)

Thank you!

Q&A?