Skip to content

how to use simple_one_for_one under supervisor tree #137

Answered by halturin
zile2000 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello, thanks for the question. There was the same question a while ago #92 (comment)

I would recommend to use this kind of supervisor in this way

   control_process (based on gen.Server)
       |
       ---- spawn sup_process (based on gen.Supervisor with "one for one" strategy)
                     |
                     ------ worker_process (based on gen.Server)

so the code will be like:

// definition
var (
	numWorkers = 5
)

type control struct {
   gen.Server
}
type controlState struct {
   sup *supWorkers
   supProcess gen.Process
   workers    []etf.Pid
   counter    uint64
}

type supWorkers struct {
   gen.Supervisor
}

type worker struct {
  gen.Server
}

/// callbacks for the…

Replies: 5 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by halturin
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@halturin
Comment options

@rupurt
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #136 on December 15, 2022 11:29.