{"id":13413038,"url":"https://github.com/ITcathyh/conexec","last_synced_at":"2025-03-14T19:31:04.903Z","repository":{"id":57503646,"uuid":"229894916","full_name":"ITcathyh/conexec","owner":"ITcathyh","description":"A concurrent toolkit to help execute funcs concurrently in an efficient and safe way. It supports specifying the overall timeout to avoid blocking.","archived":false,"fork":false,"pushed_at":"2020-06-28T03:09:55.000Z","size":43,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:51:51.548Z","etag":null,"topics":["go","golang","goroutine"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ITcathyh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-24T07:35:11.000Z","updated_at":"2024-04-18T22:08:09.000Z","dependencies_parsed_at":"2022-08-28T02:00:39.873Z","dependency_job_id":null,"html_url":"https://github.com/ITcathyh/conexec","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITcathyh%2Fconexec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITcathyh%2Fconexec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITcathyh%2Fconexec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ITcathyh%2Fconexec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ITcathyh","download_url":"https://codeload.github.com/ITcathyh/conexec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243635217,"owners_count":20322899,"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":["go","golang","goroutine"],"created_at":"2024-07-30T20:01:32.665Z","updated_at":"2025-03-14T19:31:04.580Z","avatar_url":"https://github.com/ITcathyh.png","language":"Go","readme":"## Introduction\n[![Build Status](https://travis-ci.org/ITcathyh/conexec.svg?branch=master)](https://travis-ci.org/ITcathyh/conexec)\n[![codecov](https://codecov.io/gh/ITcathyh/conexec/branch/master/graph/badge.svg)](https://codecov.io/gh/ITcathyh/conexec)\n[![Go Report Card](https://goreportcard.com/badge/github.com/ITcathyh/conexec)](https://goreportcard.com/report/github.com/ITcathyh/conexec)\n[![GoDoc](https://godoc.org/github.com/ITcathyh/conexec?status.svg)](https://godoc.org/github.com/ITcathyh/conexec)\n\nconexec is a concurrent toolkit to help execute functions concurrently in an efficient and safe way. It supports specifying the overall timeout to avoid blocking.\n\n## How to use\nGenerally it can be set as a singleton to save memory. There are some example to use it.\n### Normal Actuator\nActuator is a base struct to execute functions concurrently.\n```\n\topt := \u0026Options{TimeOut:DurationPtr(time.Millisecond*50)}\n\tc := NewActuator(opt)\n\t\n\terr := c.Exec(\n\t\tfunc() error {\n\t\t\tfmt.Println(1)\n\t\t\ttime.Sleep(time.Second * 2)\n\t\t\treturn nil\n\t\t},\n\t\tfunc() error {\n\t\t\tfmt.Println(2)\n\t\t\treturn nil\n\t\t},\n\t\tfunc() error {\n\t\t\ttime.Sleep(time.Second * 1)\n\t\t\tfmt.Println(3)\n\t\t\treturn nil\n\t\t},\n\t)\n\t\n\tif err != nil {\n\t\t// ...do sth\n\t}\n```\n### Pooled Actuator\nPooled actuator uses the goroutine pool to execute functions. In some times it is a more efficient way.\n```\n\topt := \u0026Options{TimeOut:DurationPtr(time.Millisecond*50)}\n\tc := NewPooledActuator(5, opt)\n\t\n\terr := c.Exec(...)\n\t\n\tif err != nil {\n\t\t// ...do sth\n\t}\n```\nUse custom goroutine pool\n```\n\tc := NewPooledActuator(5).WithPool(pool)\n```\n### Simply exec using goroutine\n```\n\tdone := Exec(...)\n\n\tif !done {\n\t\t// ... do sth \n\t}\n```\n","funding_links":[],"categories":["Goroutines","Goroutines `goroutines的管理和使用`","Relational Databases"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","SQL 查询语句构建库"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FITcathyh%2Fconexec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FITcathyh%2Fconexec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FITcathyh%2Fconexec/lists"}