{"id":13413032,"url":"https://github.com/ddelizia/channelify","last_synced_at":"2025-03-14T19:31:07.589Z","repository":{"id":54300059,"uuid":"301413443","full_name":"ddelizia/channelify","owner":"ddelizia","description":"Make functions return a channel for parallel processing via go routines.","archived":false,"fork":false,"pushed_at":"2021-02-25T17:33:41.000Z","size":21,"stargazers_count":31,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-31T20:51:52.393Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddelizia.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":"2020-10-05T13:12:48.000Z","updated_at":"2024-07-03T14:25:19.000Z","dependencies_parsed_at":"2022-08-13T11:20:50.115Z","dependency_job_id":null,"html_url":"https://github.com/ddelizia/channelify","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/ddelizia%2Fchannelify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelizia%2Fchannelify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelizia%2Fchannelify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddelizia%2Fchannelify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddelizia","download_url":"https://codeload.github.com/ddelizia/channelify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221498712,"owners_count":16833053,"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-07-30T20:01:32.558Z","updated_at":"2024-10-26T05:30:15.448Z","avatar_url":"https://github.com/ddelizia.png","language":"Go","funding_links":[],"categories":["Goroutines","Relational Databases","Goroutines `goroutines的管理和使用`"],"sub_categories":["检索及分析资料库","Search and Analytic Databases","SQL 查询语句构建库","Advanced Console UIs"],"readme":"# channelify\n\n[![GitHub stars](https://img.shields.io/github/stars/ddelizia/channelify.svg?style=social\u0026label=Star\u0026maxAge=2592000)](https://GitHub.com/ddelizia/channelify/stargazers/) \n[![GitHub forks](https://img.shields.io/github/forks/ddelizia/channelify.svg?style=social\u0026label=Fork\u0026maxAge=2592000)](https://GitHub.com/ddelizia/channelify/network/) \n\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/ddelizia/channelify)](https://pkg.go.dev/github.com/ddelizia/channelify)\n[![Test Actions Status](https://github.com/ddelizia/channelify/workflows/Test/badge.svg)](https://github.com/ddelizia/channelify/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ddelizia/channelify)](https://goreportcard.com/report/github.com/ddelizia/channelify)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n\n\nThis library helps you to transform any function into a function that returns a any type to a function that return such types within a channel. This is useful to run in parallel multiple functions and have control on the returned values.\n\nChannelify uses go routines to parallelize the execution of the functions. \n\nThe idea comes from Javascript Promisify utility that transforms a callback into a promise.\n\n## Installation\n\n```\ngo get github.com/ddelizia/channelify\n```\n\n\n## Usage example\n\nHere an example of transforming a simple function in channel so you can execute multiple functions in parallel:\n\n```go\nfn := func () string {\n    time.Sleep(time.Second * 3)\n    return \"hello\"\n}\n\nch1 := Channelify(fn)\nch2 := Channelify(fn)\nchV1 := ch1.(func () chan string)()\nchV2 := ch2.(func () chan string)()\n\nv1, v2 := \u003c- chV1, \u003c- chV2\n```\n\nIf your functions returns multiple values you can use as follow:\n\n```go\nfn1 := func (hello string) (string, error)  {\n    time.Sleep(time.Second * 2)\n    fmt.Println(hello)\n    return hello, nil\n}\n\nfn2 := func (hello string) (string, error)  {\n    time.Sleep(time.Second * 3)\n    fmt.Println(hello)\n    return hello, nil\n}\n\nch1 := Channelify(fn1)\nch2 := Channelify(fn2)\nchV1, chE1 := ch1.(func (string) (chan string, chan error))(\"hello1\")\nchV2, chE2 := ch2.(func (string) (chan string, chan error))(\"hello2\")\n\nv1, e1, v2, e2 := \u003c- chV1, \u003c- chE1, \u003c- chV2, \u003c- chE2\n\nfmt.Print(v1, e1, v2, e2)\n```\n\n# Contributing\n\n * Fork it\n * Create your feature branch (`git checkout -b my-new-feature`)\n * Commit your changes (`git commit -am 'Add some feature'`)\n * Push to the branch (`git push origin my-new-feature`)\n * Create new Pull Request\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddelizia%2Fchannelify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddelizia%2Fchannelify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddelizia%2Fchannelify/lists"}