suborbital / grav

Embedded decentralized message bus
Apache License 2.0
103 stars 8 forks source link

Multiple OnType message handlers #46

Open oskoi opened 3 years ago

oskoi commented 3 years ago

It would be nice to add more complex Pod type that can handle multiple message types. Pod would be like Actor

cohix commented 3 years ago

Absolutely! #37 is designed to help with that :)

oskoi commented 3 years ago

Oh, I see. But we also need guarantees that one pod group can handle one message at a time. Now all pods are independent and handle messages concurrently. We can add a message handling strategy to PodGroup (serial, concurrently, etc.) I want to use it like

func mkPodGroup() *PodGroup {
  var state State

  pods := g.PodGroup()
  pods.New().On(...) // state is used here
  pods.New().OnType(...) // state is used here

  return pods
}

It looks a bit hacky but it's a good start for stateful handling :) Grav can be good alternative to Vertx in Go world.