{"id":13504411,"url":"https://github.com/teivah/gosiris","last_synced_at":"2025-03-29T21:30:34.979Z","repository":{"id":57491847,"uuid":"108638523","full_name":"teivah/gosiris","owner":"teivah","description":"An actor framework for Go","archived":true,"fork":false,"pushed_at":"2018-12-25T16:23:10.000Z","size":128,"stargazers_count":252,"open_issues_count":12,"forks_count":22,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-11-01T01:33:35.424Z","etag":null,"topics":["actor-model","actors","actorsystem","amqp","distributed-computing","distributed-systems","etcd","kafka","zipkin"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teivah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-28T10:00:01.000Z","updated_at":"2024-05-06T14:38:54.000Z","dependencies_parsed_at":"2022-08-30T23:21:08.805Z","dependency_job_id":null,"html_url":"https://github.com/teivah/gosiris","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teivah%2Fgosiris","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teivah%2Fgosiris/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teivah%2Fgosiris/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teivah%2Fgosiris/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teivah","download_url":"https://codeload.github.com/teivah/gosiris/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246249134,"owners_count":20747164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actor-model","actors","actorsystem","amqp","distributed-computing","distributed-systems","etcd","kafka","zipkin"],"created_at":"2024-08-01T00:00:37.090Z","updated_at":"2025-03-29T21:30:34.693Z","avatar_url":"https://github.com/teivah.png","language":"Go","funding_links":[],"categories":["Frameworks"],"sub_categories":["Vectors"],"readme":"[![Go Report Card](https://goreportcard.com/badge/gojp/goreportcard)](https://goreportcard.com/report/gojp/goreportcard)\r\n\r\ngosiris is an [actor](https://en.wikipedia.org/wiki/Actor_model) framework for Golang.\r\n\r\n# Features\r\n\r\n* Manage a hierarchy of actors (each actor has its own: state, behavior, mailbox, child actors)\r\n* Deploy remote actors accessible though an AMQP broker or Kafka\r\n* Automated registration and runtime discoverability using etcd registry\r\n* Zipkin integration \r\n* Built-in patterns (become/unbecome, send, forward, repeat, child supervision)\r\n\r\n# Examples\r\n\r\n## Hello world\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"gosiris/gosiris\"\r\n)\r\n\r\nfunc main() {\r\n\t//Init a local actor system\r\n\tgosiris.InitActorSystem(gosiris.SystemOptions{\r\n\t\tActorSystemName: \"ActorSystem\",\r\n\t})\r\n\r\n\t//Create an actor\r\n\tparentActor := gosiris.Actor{}\r\n\t//Close an actor\r\n\tdefer parentActor.Close()\r\n\r\n\t//Create an actor\r\n\tchildActor := gosiris.Actor{}\r\n\t//Close an actor\r\n\tdefer childActor.Close()\r\n\t//Register a reaction to event types (\"message\" in this case)\r\n\tchildActor.React(\"message\", func(context gosiris.Context) {\r\n\t\tcontext.Self.LogInfo(context, \"Received %v\\n\", context.Data)\r\n\t})\r\n\r\n\t//Register an actor to the system\r\n\tgosiris.ActorSystem().RegisterActor(\"parentActor\", \u0026parentActor, nil)\r\n\t//Register an actor by spawning it\r\n\tgosiris.ActorSystem().SpawnActor(\u0026parentActor, \"childActor\", \u0026childActor, nil)\r\n\r\n\t//Retrieve actor references\r\n\tparentActorRef, _ := gosiris.ActorSystem().ActorOf(\"parentActor\")\r\n\tchildActorRef, _ := gosiris.ActorSystem().ActorOf(\"childActor\")\r\n\r\n\t//Send a message from one actor to another (from parentActor to childActor)\r\n\tchildActorRef.Tell(gosiris.EmptyContext, \"message\", \"Hi! How are you?\", parentActorRef)\r\n}\r\n```\r\n\r\n```\r\nINFO: [childActor] 1988/01/08 01:00:00 Received Hi! How are you?\r\n```\r\n\r\n## Distributed actor system example\r\n\r\nIn the following example, **in less than 30 effective lines of code**, we will see how to create a distributed actor system implementing a request/reply interaction. An actor will be triggered by AMQP messages while another one will be triggered by Kafka events. Each actor will register itself in an etcd instance and will discover the other actor at runtime. Last but not least, gosiris will also manage the Zipkin integration by automatically managing the spans and forwarding the logs.\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"gosiris/gosiris\"\r\n\t\"time\"\r\n)\r\n\r\nfunc main() {\r\n\t//Configure a distributed actor system with an etcd registry and a Zipkin integration\r\n\tgosiris.InitActorSystem(gosiris.SystemOptions{\r\n\t\tActorSystemName: \"ActorSystem\",\r\n\t\tRegistryUrl:     \"http://etcd:2379\",\r\n\t\tZipkinOptions: gosiris.ZipkinOptions{\r\n\t\t\tUrl:      \"http://zipkin:9411/api/v1/spans\",\r\n\t\t\tDebug:    true,\r\n\t\t\tHostPort: \"0.0.0.0\",\r\n\t\t\tSameSpan: true,\r\n\t\t},\r\n\t})\r\n\t//Defer the actor system closure\r\n\tdefer gosiris.CloseActorSystem()\r\n\r\n\t//Configure actor1\r\n\tactor1 := new(gosiris.Actor).React(\"reply\", func(context gosiris.Context) {\r\n\t\t//Because Zipkin is enabled, the log will be also sent to the Zipkin server\r\n\t\tcontext.Self.LogInfo(context, \"Received: %v\", context.Data)\r\n\r\n\t})\r\n\t//Defer actor1 closure\r\n\tdefer actor1.Close()\r\n\t//Register a remote actor accessible through AMQP\r\n\tgosiris.ActorSystem().RegisterActor(\"actor1\", actor1, new(gosiris.ActorOptions).SetRemote(true).SetRemoteType(gosiris.Amqp).SetUrl(\"amqp://guest:guest@amqp:5672/\").SetDestination(\"actor1\"))\r\n\r\n\t//Configure actor2\r\n\tactor2 := new(gosiris.Actor).React(\"context\", func(context gosiris.Context) {\r\n\t\t//Because Zipkin is enabled, the log will be also sent to the Zipkin server\r\n\t\tcontext.Self.LogInfo(context, \"Received: %v\", context.Data)\r\n\t\tcontext.Sender.Tell(context, \"reply\", \"hello back\", context.Self)\r\n\t})\r\n\t//Defer actor2 closure\r\n\tdefer actor2.Close()\r\n\t//Register a remote actor accessible through Kafka\r\n\tgosiris.ActorSystem().SpawnActor(actor1, \"actor2\", actor2, new(gosiris.ActorOptions).SetRemote(true).SetRemoteType(gosiris.Kafka).SetUrl(\"kafka:9092\").SetDestination(\"actor2\"))\r\n\r\n\t//Retrieve the actor references\r\n\tactor1Ref, _ := gosiris.ActorSystem().ActorOf(\"actor1\")\r\n\tactor2Ref, _ := gosiris.ActorSystem().ActorOf(\"actor2\")\r\n\r\n\t//Send a message to the kafkaRef\r\n\tactor2Ref.Tell(gosiris.EmptyContext, \"context\", \"hello\", actor1Ref)\r\n\r\n\ttime.Sleep(250 * time.Millisecond)\r\n}\r\n\r\n```\r\n\r\n```\r\nINFO: [actor2] 2017/11/11 00:38:24 Received: hello\r\nINFO: [actor1] 2017/11/11 00:38:24 Received: hello back\r\n```\r\n\r\n## More Examples\r\n\r\nSee the examples in [actor_test.go](gosiris/actor_test.go).\r\n\r\n# Environment\r\n\r\nFirst of all, to run the examples you must configure the following hostnames: _etcd_, _amqp_, _zipkin_, and _kafka_.\r\nThen to setup the full environment, you can simply run the [Docker Compose](docker/docker-compose.yml).\r\n\r\n# Troubleshooting\r\n\r\nYou may experience errors during the tests like the following:\r\n```\r\nr.EncodeArrayStart undefined (type codec.encDriver has no field or method EncodeArrayStart)\r\n```\r\n\r\nThis is a known issue with the etcd client used. The manual workaround (for the time being) is to delete manually the file _keys.generated.go_ generated in /vendor. \r\n\r\n# Contributing\r\n\r\n* Open an issue if you want a new feature or if you spotted a bug\r\n* Feel free to propose pull requests\r\n\r\nAny contribution is more than welcome! In the meantime, if we want to discuss gosiris you can contact me [@teivah](https://twitter.com/teivah).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteivah%2Fgosiris","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteivah%2Fgosiris","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteivah%2Fgosiris/lists"}