42 lines
721 B
Go
42 lines
721 B
Go
package subjects
|
|
|
|
import (
|
|
"feudal/feudal"
|
|
"feudal/message"
|
|
)
|
|
|
|
type WorkerCollection map[string]feudal.WorkerRouter
|
|
|
|
func New() feudal.Subjects {
|
|
var c WorkerCollection = make(map[string]feudal.WorkerRouter)
|
|
return &c
|
|
}
|
|
|
|
func (c *WorkerCollection) Send(m message.Envelope) {
|
|
for _, w := range *c {
|
|
w.Send(m)
|
|
}
|
|
}
|
|
|
|
func (c *WorkerCollection) Add(name string, worker feudal.WorkerRouter) {
|
|
(*c)[name] = worker
|
|
}
|
|
|
|
func (c *WorkerCollection) Remove(name string) {
|
|
|
|
}
|
|
|
|
func (c *WorkerCollection) Disolve() {
|
|
for _, w := range *c {
|
|
w.Stop()
|
|
}
|
|
}
|
|
|
|
func (c *WorkerCollection) Address() string {
|
|
return ""
|
|
}
|
|
|
|
func (c *WorkerCollection) Get(name string) feudal.WorkerRouter {
|
|
return (*c)[name]
|
|
}
|