Implementing Go Actor System

Actors are objects which encapsulate state and behavior, they communicate exclusively by exchanging messages which are placed into the recipient’s queue.
Read more about it here.

Read more about this project implementation in [this article]https://medium.com/better-programming/implementing-the-actor-model-in-golang-3579c2227b5e

Architecture

image info

To use actor model:
Import the repo in your project and use it as done in here

sample code

func TestIOSimulationSystem(t *testing.T) {
	ioSimSystem := CreateActorSystem("io_sim", &actor.Config{
		MinActor: 10,
		MaxActor: 100,
		AutoScale: actor.AutoScale{
			UpscaleQueueSize:   100,
			DownscaleQueueSize: 10,
		},
	})

	for i := 0; i < 1000; i += 1 {
		ioSimSystem.SubmitTask(CreateNumberPrinterTask(i))
		<-time.After(2 * time.Millisecond)
	}
	shutdown([]*ActorSystem{ioSimSystem})

}

GitHub

View Github