{"id":44536009,"url":"https://github.com/sujit-baniya/flow","last_synced_at":"2026-02-13T18:48:15.720Z","repository":{"id":48304147,"uuid":"441470790","full_name":"sujit-baniya/flow","owner":"sujit-baniya","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-19T02:51:19.000Z","size":77,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-19T17:50:48.127Z","etag":null,"topics":["dag","flow","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sujit-baniya.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":"2021-12-24T13:18:36.000Z","updated_at":"2023-11-19T00:00:19.000Z","dependencies_parsed_at":"2022-07-24T23:32:10.073Z","dependency_job_id":null,"html_url":"https://github.com/sujit-baniya/flow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sujit-baniya/flow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujit-baniya%2Fflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujit-baniya%2Fflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujit-baniya%2Fflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujit-baniya%2Fflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sujit-baniya","download_url":"https://codeload.github.com/sujit-baniya/flow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sujit-baniya%2Fflow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29414284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dag","flow","go","golang"],"created_at":"2026-02-13T18:48:14.585Z","updated_at":"2026-02-13T18:48:15.688Z","avatar_url":"https://github.com/sujit-baniya.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\nThis package provides simple graph to execute functions in a group.\n\n## Features\n- Define nodes of different types: Vertex, Branch and Loop\n- Define branch for conditional nodes\n\n\n## Installation\n\u003e go get github.com/sujit-baniya/flow\n\n## Usage\n\n### Basic Flow\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"github.com/sujit-baniya/flow\"\n)\n\nfunc Message(ctx context.Context, d flow.Data) (flow.Data, error) {\n\td.Payload = flow.Payload(fmt.Sprintf(\"message %s\", d.Payload))\n\treturn d, nil\n}\n\nfunc Send(ctx context.Context, d flow.Data) (flow.Data, error) {\n\td.Payload = flow.Payload(fmt.Sprintf(\"This is send %s\", d.Payload))\n\treturn d, nil\n}\n\nfunc basicFlow() {\n\tflow1 := flow.New()\n\tflow1.AddNode(\"message\", Message)\n\tflow1.AddNode(\"send\", Send)\n\tflow1.Edge(\"message\", \"send\")\n\tresponse, e := flow1.Build().Process(context.Background(), flow.Data{\n\t\tPayload: flow.Payload(\"Payload\"),\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(response.ToString())\n}\n\nfunc basicRawFlow() {\n\trawFlow := []byte(`{\n\t\t\"edges\": [\n\t\t\t[\"message\", \"send\"]\n\t\t]\n\t}`)\n\tflow1 := flow.New(rawFlow)\n\tflow1.AddNode(\"message\", Message)\n\tflow1.AddNode(\"send\", Send)\n\tresponse, e := flow1.Process(context.Background(), flow.Data{\n\t\tPayload: flow.Payload(\"Payload\"),\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(response.ToString())\n}\n\nfunc main() {\n\tbasicFlow()\n\tbasicRawFlow()\n}\n\n```\n\n### Branch Flow\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"encoding/json\"\n\t\"github.com/sujit-baniya/flow\"\n)\n\nfunc GetRegistration(ctx context.Context, d flow.Data) (flow.Data, error) {\n\treturn d, nil\n}\n\n// VerifyUser Conditional Vertex\nfunc VerifyUser(ctx context.Context, d flow.Data) (flow.Data, error) {\n\tvar reg Registration\n\td.ConvertTo(\u0026reg)\n\tif _, ok := registeredEmail[reg.Email]; !ok {\n\t\td.Status = \"pass\"\n\t} else {\n\t\td.Status = \"fail\"\n\t}\n\treturn d, nil\n}\n\nfunc CreateUser(ctx context.Context, d flow.Data) (flow.Data, error) {\n\td.Payload = flow.Payload(fmt.Sprintf(\"create user %s\", d.Payload))\n\treturn d, nil\n}\n\nfunc CancelRegistration(ctx context.Context, d flow.Data) (flow.Data, error) {\n\td.Payload = flow.Payload(fmt.Sprintf(\"cancel user %s\", d.Payload))\n\treturn d, nil\n}\n\ntype Registration struct {\n\tEmail    string\n\tPassword string\n}\n\nvar registeredEmail = map[string]bool{\"test@gmail.com\": true}\n\nfunc basicRegistrationFlow() {\n\tflow1 := flow.New()\n\tflow1.AddNode(\"get-registration\", GetRegistration)\n\tflow1.AddNode(\"create-user\", CreateUser)\n\tflow1.AddNode(\"cancel-registration\", CancelRegistration)\n\tflow1.AddNode(\"verify-user\", VerifyUser)\n\tflow1.ConditionalNode(\"verify-user\", map[string]string{\n\t\t\"pass\": \"create-user\",\n\t\t\"fail\": \"cancel-registration\",\n\t})\n\tflow1.Edge(\"get-registration\", \"verify-user\")\n\n\tregistration1 := Registration{\n\t\tEmail:    \"test@gmail.com\",\n\t\tPassword: \"admin\",\n\t}\n\treg1, _ := json.Marshal(registration1)\n\n\tregistration2 := Registration{\n\t\tEmail:    \"test1@gmail.com\",\n\t\tPassword: \"admin\",\n\t}\n\treg2, _ := json.Marshal(registration2)\n\tresponse, e := flow1.Process(context.Background(), flow.Data{\n\t\tPayload: reg1,\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(response.ToString())\n\tresponse, e = flow1.Process(context.Background(), flow.Data{\n\t\tPayload: reg2,\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(response.ToString())\n}\n\nfunc basicRegistrationRawFlow() {\n\trawFlow := []byte(`{\n\t\t\"edges\": [\n\t\t\t[\"get-registration\", \"verify-user\"]\n\t\t],\n\t\t\"branches\":[\n\t\t\t{\n\t\t\t\t\"key\": \"verify-user\",\n\t\t\t\t\"conditional_nodes\": {\n\t\t\t\t\t\"pass\": \"create-user\",\n\t\t\t\t\t\"fail\": \"cancel-registration\"\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}`)\n\tflow1 := flow.New(rawFlow)\n\tflow1.AddNode(\"get-registration\", GetRegistration)\n\tflow1.AddNode(\"create-user\", CreateUser)\n\tflow1.AddNode(\"cancel-registration\", CancelRegistration)\n\tflow1.AddNode(\"verify-user\", VerifyUser)\n\tregistration1 := Registration{\n\t\tEmail:    \"test@gmail.com\",\n\t\tPassword: \"admin\",\n\t}\n\treg1, _ := json.Marshal(registration1)\n\n\tregistration2 := Registration{\n\t\tEmail:    \"test1@gmail.com\",\n\t\tPassword: \"admin\",\n\t}\n\treg2, _ := json.Marshal(registration2)\n\tresponse, e := flow1.Process(context.Background(), flow.Data{\n\t\tPayload: reg1,\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(response.ToString())\n\tresponse, e = flow1.Process(context.Background(), flow.Data{\n\t\tPayload: reg2,\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(response.ToString())\n}\n\nfunc main() {\n\tbasicRegistrationFlow()\n\tbasicRegistrationRawFlow()\n}\n\n```\n\n### Loop Flow\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"encoding/json\"\n\t\"github.com/sujit-baniya/flow\"\n\t\"strings\"\n)\n\nfunc GetSentence(ctx context.Context, d flow.Data) (flow.Data, error) {\n\twords := strings.Split(d.ToString(), ` `)\n\tbt, _ := json.Marshal(words)\n\td.Payload = bt\n\treturn d, nil\n}\n\nfunc ForEachWord(ctx context.Context, d flow.Data) (flow.Data, error) {\n\treturn d, nil\n}\n\nfunc WordUpperCase(ctx context.Context, d flow.Data) (flow.Data, error) {\n\tvar word string\n\t_ = json.Unmarshal(d.Payload, \u0026word)\n\tbt, _ := json.Marshal(strings.Title(strings.ToLower(word)))\n\td.Payload = bt\n\treturn d, nil\n}\n\nfunc AppendString(ctx context.Context, d flow.Data) (flow.Data, error) {\n\tvar word string\n\t_ = json.Unmarshal(d.Payload, \u0026word)\n\tbt, _ := json.Marshal(\"Upper Case: \" + word)\n\td.Payload = bt\n\treturn d, nil\n}\n\nfunc main() {\n\tflow1 := flow.New()\n\tflow1.AddNode(\"get-sentence\", GetSentence)\n\tflow1.AddNode(\"for-each-word\", ForEachWord)\n\tflow1.AddNode(\"upper-case\", WordUpperCase)\n\tflow1.AddNode(\"append-string\", AppendString)\n\tflow1.Loop(\"for-each-word\", \"upper-case\")\n\tflow1.Edge(\"get-sentence\", \"for-each-word\")\n\tflow1.Edge(\"upper-case\", \"append-string\")\n\tresp, e := flow1.Process(context.Background(), flow.Data{\n\t\tPayload: flow.Payload(\"this is a sentence\"),\n\t})\n\tif e != nil {\n\t\tpanic(e)\n\t}\n\tfmt.Println(resp.ToString())\n}\n\n```\n## ToDo List\n- Implement async flow and nodes\n- Implement distributed nodes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsujit-baniya%2Fflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsujit-baniya%2Fflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsujit-baniya%2Fflow/lists"}