Simple mimic of async/await for those come from C# world, now you can Cancel(), Wait() on a go routine.
Перейти к файлу
dependabot[bot] 0cfea47d87
Bump the github-actions group across 1 directory with 5 updates (#125)
Bumps the github-actions group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `4.2.1` | `4.2.2` |
| [github/codeql-action](https://github.com/github/codeql-action) | `3.26.13` | `3.27.4` |
| [actions/dependency-review-action](https://github.com/actions/dependency-review-action) | `4.3.4` | `4.4.0` |
| [actions/setup-go](https://github.com/actions/setup-go) | `5.0.2` | `5.1.0` |
| [codecov/codecov-action](https://github.com/codecov/codecov-action) | `4.6.0` | `5.0.2` |



Updates `actions/checkout` from 4.2.1 to 4.2.2
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](eef61447b9...11bd71901b)

Updates `github/codeql-action` from 3.26.13 to 3.27.4
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](f779452ac5...ea9e4e3799)

Updates `actions/dependency-review-action` from 4.3.4 to 4.4.0
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](5a2ce3f5b9...4081bf99e2)

Updates `actions/setup-go` from 5.0.2 to 5.1.0
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](0a12ed9d6a...41dfa10bad)

Updates `codecov/codecov-action` from 4.6.0 to 5.0.2
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](b9fd7d16f6...5c47607acb)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-actions
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-actions
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-18 13:22:56 -08:00
.github Bump the github-actions group across 1 directory with 5 updates (#125) 2024-11-18 13:22:56 -08:00
.gitignore add gitignore (#29) 2023-04-05 13:36:56 -07:00
.pre-commit-config.yaml [StepSecurity] Apply security best practices (#34) 2024-01-23 10:14:53 -08:00
CODE_OF_CONDUCT.md
LICENSE
README.md remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
SECURITY.md
after_both.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
after_both_test.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
continue_with.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
continue_with_test.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
error_test.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
go.mod Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#61) 2024-05-03 00:03:09 -07:00
go.sum Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 (#61) 2024-05-03 00:03:09 -07:00
task.go docstrings update (#105) 2024-08-19 13:38:25 -07:00
task_test.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
types.go use generics for asyncTasks, no type assertion required (#14) 2022-05-31 13:49:21 -07:00
wait_all.go waitall fix write on closed channel (#26) 2023-04-05 11:50:17 -07:00
wait_all_test.go remove restriction on return pointer value of TypeParameter (#33) 2023-11-13 14:08:57 -08:00
wait_any.go fix comment 2023-06-27 16:53:01 -07:00
wait_any_test.go address comment 2023-06-27 16:39:04 -07:00

README.md

AsyncTask

Build Go Report Card GoDoc Codecov

Simple mimik of async/await for those come from C# world, so you don't need to dealing with waitGroup/channel in golang.

also the result is strongTyped with go generics, no type assertion is needed.

few chaining method provided:

  • ContinueWith: send task1's output to task2 as input, return reference to task2.
  • AfterBoth : send output of taskA, taskB to taskC as input, return reference to taskC.
  • WaitAll: all of the task have to finish to end the wait (with an option to fail early if any task failed)
  • WaitAny: any of the task finish would end the wait
    // start task
    task := asynctask.Start(ctx, countingTask)
    
    // do something else
    somethingelse()
    
    // get the result
    rawResult, err := task.Wait()
    // or
    task.Cancel()

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.