{"id":21625380,"url":"https://github.com/eigr/spawn-go-sdk","last_synced_at":"2025-05-07T03:11:05.174Z","repository":{"id":118785567,"uuid":"500511072","full_name":"eigr/spawn-go-sdk","owner":"eigr","description":"Spawn Go SDK","archived":false,"fork":false,"pushed_at":"2025-04-20T00:25:23.000Z","size":7012,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-20T00:26:17.271Z","etag":null,"topics":[],"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/eigr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-06-06T16:31:41.000Z","updated_at":"2025-04-20T00:25:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"12570766-b498-4043-ac5e-126cf0add8b2","html_url":"https://github.com/eigr/spawn-go-sdk","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fspawn-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fspawn-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fspawn-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fspawn-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eigr","download_url":"https://codeload.github.com/eigr/spawn-go-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252804219,"owners_count":21806771,"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":[],"created_at":"2024-11-25T01:09:02.015Z","updated_at":"2025-05-07T03:11:05.153Z","avatar_url":"https://github.com/eigr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Spawn Go SDK](https://github.com/eigr/spawn)\n\n**Seamless Actor Mesh Runtime for Go Developers**\n\n---\n\n## 🚀 **Why Choose Spawn?**\n\n- **Developer Friendly**: Simplify building distributed, stateful applications.\n- **Scalable**: Designed for cloud-native environments with polyglot support.\n- **Effortless Integration**: Build robust systems with minimal boilerplate.\n\n---\n\n## **🌟 Features**\n\n- Fully managed actor lifecycle.\n- State persistence and snapshots.\n- Polyglot SDKs for ultimate flexibility. In this case GO SDK \\0/.\n- Optimized for high performance and low latency.\n\n---\n\n## **📦 Installation**\n\nSet up your environment in seconds. Install the Spawn CLI:\n\n```bash\ncurl -sSL https://github.com/eigr/spawn/releases/download/v1.4.3/install.sh | sh\n```\n\n## 🔥 Getting Started\n\n### 1️⃣ Create a New Project\n\n```bash\nspawn new go hello_world\n```\n\n### 2️⃣ Define Your Protocol\n\nLeverage the power of Protobuf to define your actor's schema:\n\n```proto\nsyntax = \"proto3\";\n\npackage examples.actors;\n\noption go_package = \"examples/actors\";\n\nmessage UserState {\n  string name = 1;\n}\n\nmessage ChangeUserNamePayload {\n  string new_name = 1;\n}\n\nmessage ChangeUserNameResponse {\n  // this is a bad example, but it's just an example\n  enum ResponseStatus {\n    OK = 0;\n    ERROR = 1;\n  }\n  ResponseStatus response_status = 1;\n}\n\nservice UserActor {\n  rpc ChangeUserName(ChangeUserNamePayload) returns (ChangeUserNameResponse) {}\n}\n```\n\n### 3️⃣ Compile Your Protobuf\n\nFollow the example in our [Makefile](./Makefile).\n\n### 4️⃣ Implement Your Business Logic\n\nStart writing actors with ease:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"time\"\n\n\tdomain \"examples/actors\"\n\n\tspawn \"github.com/eigr/spawn-go-sdk/spawn/actors\"\n\tactorSystem \"github.com/eigr/spawn-go-sdk/spawn/system\"\n\t\"google.golang.org/protobuf/proto\"\n)\n\nfunc main() {\n\t// Defines the actor configuration\n\tactorConfig := spawn.ActorConfig{\n\t\tName:               \"UserActor\",         // Name of ator\n\t\tStateType:          \u0026domain.UserState{}, // State type\n\t\tKind:               spawn.Named,         // Actor Type (Named)\n\t\tStateful:           true,                // Stateful actor\n\t\tSnapshotTimeout:    60,                  // Snapshot timeout\n\t\tDeactivatedTimeout: 120,                 // Deactivation timeout\n\t}\n\n\t// Creates an actor directly\n\tuserActor := spawn.ActorOf(actorConfig)\n\n\t// Define a simple action for the actor\n\tuserActor.AddAction(\"ChangeUserName\", func(ctx *spawn.ActorContext, payload proto.Message) (spawn.Value, error) {\n\t\t// Convert payload to expected type\n\t\tlog.Printf(\"Received invoke on Action ChangeUserName. Payload: %v\", payload)\n\t\tinput, ok := payload.(*domain.ChangeUserNamePayload)\n\t\tif !ok {\n\t\t\treturn spawn.Value{}, fmt.Errorf(\"invalid payload type\")\n\t\t}\n\n\t\t// Updates the status and prepares the response\n\t\tnewState := \u0026domain.UserState{Name: input.NewName}\n\t\tresponse := \u0026domain.ChangeUserNameResponse{ResponseStatus: domain.ChangeUserNameResponse_OK}\n\n\t\t// Returns response to caller and persist new state\n\t\treturn spawn.Of(response).\n\t\t\tState(newState).\n\t\t\tMaterialize(), nil\n\t})\n\n\t// Initializes the Spawn system\n\tsystem := actorSystem.NewSystem(\"spawn-system\").\n\t\tUseProxyPort(9001).\n\t\tExposePort(8090).\n\t\tRegisterActor(userActor)\n\n\t// Start the system\n\tif err := system.Start(); err != nil {\n\t\tlog.Fatalf(\"Failed to start Actor System: %v\", err)\n\t}\n\n\tresp, _ := system.Invoke(\n\t\t\"spawn-system\",\n\t\t\"UserActor\",\n\t\t\"ChangeUserName\",\n\t\t\u0026domain.ChangeUserNamePayload{NewName: \"Joe\"},\n\t\tactorSystem.Options{})\n\n\tlog.Printf(\"Response: %v\", resp)\n\n\tsystem.Await()\n}\n```\n\n### 5️⃣ Build and generate application in dev mode\n\n```bash\ngo build -v -gcflags=\"all=-N -l\" -o ./bin/examples/app ./examples\n```\n\n### 6️⃣ Start Spawn CLI in dev mode\n\n```bash\nspawn dev run\n```\n\nExpected output similar to this:\n\n```bash\n🏃  Starting Spawn Proxy in dev mode...\n❕  Spawn Proxy uses the following mapped ports: [\n      Proxy HTTP: nil:9001,\n      Proxy gRPC: nil:9980\n    ]\n🚀  Spawn Proxy started successfully in dev mode. Container Id: 7961ed391e06b36c6d73290a6d6a0cbb60cf910fd4e4ff3fc5b7bd49ed677976\n```\n\n### 7️⃣ Start application in dev mode\n\n```bash\n./bin/examples/app\n```\n\nOutputs need to be similar with this:\n\n```bash\n2024/12/10 20:09:37 HTTP server started on port 8090\n2024/12/10 20:09:37 Actors successfully registered and system started\n```\n\n### 8️⃣ Validate Spawn CLI docker logs\n\nUse `Id` for previous `spawn dev run` command to see docker logs.\n\n```bash\ndocker logs -f 7961ed391e06b36c6d73290a6d6a0cbb60cf910fd4e4ff3fc5b7bd49ed677976\n```\n\nExpected output similar to (ommited some logs for brevity):\n\n```bash\n2024-12-10 21:21:32.028 [proxy@GF-595]:[pid=\u003c0.2770.0\u003e ]:[info]:[Proxy.Config] Loading configs\n2024-12-10 21:21:32.029 [proxy@GF-595]:[pid=\u003c0.2770.0\u003e ]:[info]:Loading config: [actor_system_name]:[my-system]\n2024-12-10 21:21:32.044 [proxy@GF-595]:[pid=\u003c0.2775.0\u003e ]:[info]:[SUPERVISOR] Sidecar.Supervisor is up\n2024-12-10 21:21:32.044 [proxy@GF-595]:[pid=\u003c0.2777.0\u003e ]:[info]:[SUPERVISOR] Sidecar.ProcessSupervisor is up\n2024-12-10 21:21:32.045 [proxy@GF-595]:[pid=\u003c0.2779.0\u003e ]:[info]:[SUPERVISOR] Sidecar.MetricsSupervisor is up\n2024-12-10 21:21:32.046 [proxy@GF-595]:[pid=\u003c0.2783.0\u003e ]:[info]:[SUPERVISOR] Spawn.Supervisor is up\n2024-12-10 21:21:32.048 [proxy@GF-595]:[pid=\u003c0.2791.0\u003e ]:[info]:[SUPERVISOR] Spawn.Cluster.StateHandoff.ManagerSupervisor is up\n2024-12-10 21:21:32.053 [proxy@GF-595]:[pid=\u003c0.2809.0\u003e ]:[info]:[mnesiac:proxy@GF-595] mnesiac starting, with []\n2024-12-10 21:21:32.078 [proxy@GF-595]:[pid=\u003c0.2809.0\u003e ]:[info]:Elixir.Statestores.Adapters.Native.SnapshotStore Initialized with result {:aborted, {:already_exists, Statestores.Adapters.Native.SnapshotStore}}\n2024-12-10 21:21:32.079 [proxy@GF-595]:[pid=\u003c0.2809.0\u003e ]:[info]:[mnesiac:proxy@GF-595] mnesiac started\n2024-12-10 21:21:32.083 [proxy@GF-595]:[pid=\u003c0.2855.0\u003e ]:[info]:[SUPERVISOR] Actors.Supervisors.ActorSupervisor is up\n2024-12-10 21:21:32.123 [proxy@GF-595]:[pid=\u003c0.2772.0\u003e ]:[info]:Running Proxy.Router with Bandit 1.5.2 at 0.0.0.0:9001 (http)\n2024-12-10 21:21:32.124 [proxy@GF-595]:[pid=\u003c0.2770.0\u003e ]:[info]:Proxy Application started successfully in 0.095587ms. Running with 8 schedulers.\n2024-12-10 21:21:56.518 [proxy@GF-595]:[pid=\u003c0.3419.0\u003e ]:[info]:POST /api/v1/system\n2024-12-10 21:21:56.523 [proxy@GF-595]:[pid=\u003c0.3419.0\u003e ]:[info]:Sent 200 in 4ms\n2024-12-10 21:21:56.526 [proxy@GF-595]:[pid=\u003c0.3433.0\u003e ]:[notice]:Activating Actor \"UserActor\" with Parent \"\" in Node :\"proxy@GF-595\". Persistence true.\n2024-12-10 21:21:56.528 [proxy@GF-595]:[pid=\u003c0.3424.0\u003e ]:[info]:Actor UserActor Activated on Node :\"proxy@GF-595\" in 3402ms\n```\n\n## 📚 Explore More\n\nCheck out our examples folder for additional use cases and inspiration.\n\n## 💡 Why Spawn Matters\n\nCTOs, Tech Leads, and Developers love Spawn for its simplicity, scalability, and flexibility. Build reliable, distributed systems faster than ever.\n\nUnleash the power of polyglot distributed systems with Spawn today!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feigr%2Fspawn-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feigr%2Fspawn-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feigr%2Fspawn-go-sdk/lists"}