File: README.md
English | ไธญๆ
๐ Introduction
Library ants implements a goroutine pool with fixed capacity, managing and recycling a massive number of goroutines, allowing developers to limit the number of goroutines in your concurrent programs.
๐ Features:
- Managing and recycling a massive number of goroutines automatically
- Purging overdue goroutines periodically
- Abundant APIs: submitting tasks, getting the number of running goroutines, tuning the capacity of the pool dynamically, releasing the pool, rebooting the pool, etc.
- Handle panic gracefully to prevent programs from crash
- Efficientย inย memoryย usage and it may even achieveย higher performanceย than unlimited goroutines in Go
- Nonblocking mechanism
- Preallocated memory (ring buffer, optional)
๐ก How `ants` works
Flow Diagram
Activity Diagrams
๐งฐ How to install
For `ants` v1
go get -u github.com/panjf2000/antsFor `ants` v2 (with GO111MODULE=on)
go get -u github.com/panjf2000/ants/v2๐ How to use
Check out the examples for basic usage.
Functional options for pool
ants.Optionscontains all optional configurations of the ants pool, which allows you to customize the goroutine pool by invoking option functions to set up each configuration in NewPool/NewPoolWithFunc/NewPoolWithFuncGeneric method.
Check out ants.Options and ants.Option for more details.
Customize pool capacity
ants supports customizing the capacity of the pool. You can call the NewPool method to instantiate a Pool with a given capacity, as follows:
p, _ := ants.NewPool(10000)Submit tasks
Tasks can be submitted by calling ants.Submit
ants.Submit(func(){})Tune pool capacity at runtime
You can tune the capacity of ants pool at runtime with ants.Tune:
pool.Tune(1000) // Tune its capacity to 1000
pool.Tune(100000) // Tune its capacity to 100000Don't worry about the contention problems in this case, the method here is thread-safe (or should be called goroutine-safe).
Pre-malloc goroutine queue in pool
ants allows you to pre-allocate the memory of the goroutine queue in the pool, which may get a performance enhancement under some special certain circumstances such as the scenario that requires a pool with ultra-large capacity, meanwhile, each task in goroutine lasts for a long time, in this case, pre-mallocing will reduce a lot of memory allocation in goroutine queue.
// ants will pre-malloc the whole capacity of pool when calling ants.NewPool.
p, _ := ants.NewPool(100000, ants.WithPreAlloc(true))Release pool
pool.Release()or
pool.ReleaseTimeout(time.Second * 3)Reboot pool
// A pool that has been released can be still used after calling the Reboot().
pool.Reboot()โ๏ธ About sequence
All tasks submitted to ants pool will not be guaranteed to be addressed in order, because those tasks scatter among a series of concurrent workers, thus those tasks would be executed concurrently.
๐ Contributors
Please read our Contributing Guidelines before opening a PR and thank you to all the developers who already made contributions to ants!
๐ License
The source code in ants is available under the MIT License.
๐ Relevant Articles
- Goroutine ๅนถๅ่ฐๅบฆๆจกๅๆทฑๅบฆ่งฃๆไนๆๆธไธไธช้ซๆง่ฝ goroutine ๆฑ
- Visually Understanding Worker Pool
- The Case For A Go Worker Pool
- Go Concurrency - GoRoutines, Worker Pools and Throttling Made Simple
๐ฅ Use cases
business corporations & open-source organizations
Trusted by the following corporations/organizations.
If you're also using ants in production, please help us enrich this list by opening a pull request.
open-source software
The open-source projects below do concurrent programming with the help of ants.
- gnet: A high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.
- milvus: An open-source vector database for scalable similarity search and AI applications.
- nps: A lightweight, high-performance, powerful intranet penetration proxy server, with a powerful web management terminal.
- TDengine: TDengine is an open source, high-performance, cloud native time-series database optimized for Internet of Things (IoT), Connected Cars, and Industrial IoT.
- siyuan: SiYuan is a local-first personal knowledge management system that supports complete offline use, as well as end-to-end encrypted synchronization.
- BillionMail: A future open-source Mail server, Email marketing platform designed to help businesses and individuals manage their email campaigns with ease.
- WeKnora: An LLM-powered framework designed for deep document understanding and semantic retrieval, especially for handling complex, heterogeneous documents.
- coze-loop: A developer-oriented, platform-level solution focused on the development and operation of AI agents.
- osmedeus: A Workflow Engine for Offensive Security.
- jitsu: An open-source Segment alternative. Fully-scriptable data ingestion engine for modern data teams. Set-up a real-time data pipeline in minutes, not days.
- triangula: Generate high-quality triangulated and polygonal art from images.
- teler: Real-time HTTP Intrusion Detection.
- bsc: A Binance Smart Chain client based on the go-ethereum fork.
- jaeles: The Swiss Army knife for automated Web Application Testing.
- devlake: The open-source dev data platform & dashboard for your DevOps tools.
- matrixone: MatrixOne is a future-oriented hyper-converged cloud and edge native DBMS that supports transactional, analytical, and streaming workloads with a simplified and distributed database engine, across multiple data centers, clouds, edges and other heterogeneous infrastructures.
- bk-bcs: BlueKing Container Service (BCS, same below) is a container management and orchestration platform for the micro-services under the BlueKing ecosystem.
- trueblocks-core: TrueBlocks improves access to blockchain data for any EVM-compatible chain (particularly Ethereum mainnet) while remaining entirely local.
- openGemini: openGemini is an open-source,cloud-native time-series database(TSDB) that can be widely used in IoT, Internet of Vehicles(IoV), O&M monitoring, and industrial Internet scenarios.
- AdGuardDNS: AdGuard DNS is an alternative solution for tracker blocking, privacy protection, and parental control.
- WatchAD2.0: WatchAD2.0 ๆฏ 360 ไฟกๆฏๅฎๅ จไธญๅฟๅผๅ็ไธๆฌพ้ๅฏนๅๅฎๅ จ็ๆฅๅฟๅๆไธ็ๆง็ณป็ป๏ผๅฎๅฏไปฅๆถ้ๆๆๅๆงไธ็ไบไปถๆฅๅฟใ็ฝ็ปๆต้๏ผ้่ฟ็นๅพๅน้ ใๅ่ฎฎๅๆใๅๅฒ่กไธบใๆๆๆไฝๅ่็ฝ่ดฆๆท็ญๆนๅผๆฅๆฃๆตๅ็งๅทฒ็ฅไธๆช็ฅๅจ่๏ผๅ่ฝ่ฆ็ไบๅคง้จๅ็ฎๅ็ๅธธ่งๅ ็ฝๅๆธ้ๆๆณใ
- vanus: Vanus is a Serverless, event streaming system with processing capabilities. It easily connects SaaS, Cloud Services, and Databases to help users build next-gen Event-driven Applications.
- trpc-go: A pluggable, high-performance RPC framework written in Golang.
- motan-go: Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services. motan-go is the golang implementation of Motan.
All use cases:
If you have ants integrated into projects, feel free to open a pull request refreshing this list of use cases.
๐ JetBrains OS licenses
ants has been being developed with GoLand under the free JetBrains Open Source license(s) granted by JetBrains s.r.o., hence I would like to express my thanks here.
โ๏ธ Buy me a coffee
Please be sure to leave your name, GitHub account, or other social media accounts when you donate by the following means so that I can add it to the list of donors as a token of my appreciation.
๐ Sponsorship
File: CODE_OF_CONDUCT.md
Contributor Covenant Code of Conduct
Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
Our Standards
Examples of behavior that contributes to creating a positive environment
include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
advances - Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission - Other conduct which could reasonably be considered inappropriate in a
professional setting
Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
File: CONTRIBUTING.md
Contributing
With issues:
- Use the search tool before opening a new issue.
- Please provide source code and commit sha if you found a bug.
- Review existing issues and provide feedback or react to them.
With pull requests:
- Open your pull request against
dev. - Open one pull request for only one feature/proposal, if you have several those, please put them into different PRs, whereas you are allowed to open one pull request with several bug-fixs.
- Your pull request should have no more than two commits, if not, you should squash them.
- It should pass all tests in the available continuous integrations systems such as TravisCI.
- You should add/modify tests to cover your proposed code changes.
- If your pull request contains a new feature, please document it on the README.
File: README_ZH.md
่ฑๆ | ไธญๆ
๐ ็ฎไป
ants ๆฏไธไธช้ซๆง่ฝ็ goroutine ๆฑ ๏ผๅฎ็ฐไบๅฏนๅคง่งๆจก goroutine ็่ฐๅบฆ็ฎก็ใgoroutine ๅค็จ๏ผๅ
่ฎธไฝฟ็จ่
ๅจๅผๅๅนถๅ็จๅบ็ๆถๅ้ๅถ goroutine ๆฐ้๏ผๅค็จ่ตๆบ๏ผ่พพๅฐๆด้ซๆๆง่กไปปๅก็ๆๆใ
๐ ๅ่ฝ๏ผ
- ่ชๅจ่ฐๅบฆๆตท้็ goroutines๏ผๅค็จ goroutines
- ๅฎๆๆธ ็่ฟๆ็ goroutines๏ผ่ฟไธๆญฅ่็่ตๆบ
- ๆไพไบๅคง้ๅฎ็จ็ๆฅๅฃ๏ผไปปๅกๆไบคใ่ทๅ่ฟ่กไธญ็ goroutine ๆฐ้ใๅจๆ่ฐๆด Pool ๅคงๅฐใ้ๆพ Poolใ้ๅฏ Pool ็ญ
- ไผ้ ๅค็ panic๏ผ้ฒๆญข็จๅบๅดฉๆบ
- ่ตๆบๅค็จ๏ผๆๅคง่็ๅ ๅญไฝฟ็จ้๏ผๅจๅคง่งๆจกๆน้ๅนถๅไปปๅกๅบๆฏไธ็่ณๅฏ่ฝๆฏ Go ่ฏญ่จ็ๆ ้ๅถ goroutine ๅนถๅๅ ทๆๆด้ซ็ๆง่ฝ
- ้้ปๅกๆบๅถ
- ้ขๅ้ ๅ ๅญ (็ฏๅฝข้ๅ๏ผๅฏ้)
๐ก `ants` ๆฏๅฆไฝ่ฟ่ก็
ๆต็จๅพ
ๅจๆๅพ
๐งฐ ๅฎ่ฃ
ไฝฟ็จ `ants` v1 ็ๆฌ:
go get -u github.com/panjf2000/antsไฝฟ็จ `ants` v2 ็ๆฌ (ๅผๅฏ GO111MODULE=on):
go get -u github.com/panjf2000/ants/v2๐ ไฝฟ็จ
ๅบๆฌ็ไฝฟ็จ่ฏทๆฅ็็คบไพ.
Pool ้ ็ฝฎ
้่ฟๅจ่ฐ็จ NewPool/NewPoolWithFunc/NewPoolWithFuncGeneric ไนๆถไฝฟ็จๅ็ง optional function๏ผๅฏไปฅ่ฎพ็ฝฎ ants.Options ไธญๅไธช้
็ฝฎ้กน็ๅผ๏ผ็ถๅ็จๅฎๆฅๅฎๅถๅ goroutine poolใ
ๆดๅค็ป่่ฏทๆฅ็ ants.Options ๅ ants.Option
่ชๅฎไน pool ๅฎน้
ants ๆฏๆๅฎไพๅไฝฟ็จ่
่ชๅทฑ็ไธไธช Pool๏ผๆๅฎๅ
ทไฝ็ pool ๅฎน้๏ผ้่ฟ่ฐ็จ NewPool ๆนๆณๅฏไปฅๅฎไพๅไธไธชๆฐ็ๅธฆๆๆๅฎๅฎน้็ Pool๏ผๅฆไธ๏ผ
p, _ := ants.NewPool(10000)ไปปๅกๆไบค
ๆไบคไปปๅก้่ฟ่ฐ็จ ants.Submit ๆนๆณ๏ผ
ants.Submit(func(){})ๅจๆ่ฐๆด goroutine ๆฑ ๅฎน้
้่ฆๅจๆ่ฐๆด pool ๅฎน้ๅฏไปฅ้่ฟ่ฐ็จ ants.Tune๏ผ
pool.Tune(1000) // Tune its capacity to 1000
pool.Tune(100000) // Tune its capacity to 100000่ฏฅๆนๆณๆฏ็บฟ็จๅฎๅ จ็ใ
้ขๅ ๅ้ goroutine ้ๅๅ ๅญ
ants ๆฏๆ้ขๅ
ไธบ pool ๅ้
ๅฎน้็ๅ
ๅญ๏ผ ่ฟไธชๅ่ฝๅฏไปฅๅจๆไบ็นๅฎ็ๅบๆฏไธๆ้ซ goroutine ๆฑ ็ๆง่ฝใๆฏๅฆ๏ผ ๆไธไธชๅบๆฏ้่ฆไธไธช่ถ
ๅคงๅฎน้็ๆฑ ๏ผ่ไธๆฏไธช goroutine ้้ข็ไปปๅก้ฝๆฏ่ๆถไปปๅก๏ผ่ฟ็งๆ
ๅตไธ๏ผ้ขๅ
ๅ้
goroutine ้ๅๅ
ๅญๅฐไผๅๅฐไธๅฟ
่ฆ็ๅ
ๅญ้ๆฐๅ้
ใ
// ๆๅๅ้
็ pool ๅฎน้็ๅ
ๅญ็ฉบ้ด
p, _ := ants.NewPool(100000, ants.WithPreAlloc(true))้ๆพ Pool
pool.Release()ๆ่
pool.ReleaseTimeout(time.Second * 3)้ๅฏ Pool
// ๅช่ฆ่ฐ็จ Reboot() ๆนๆณ๏ผๅฐฑๅฏไปฅ้ๆฐๆฟๆดปไธไธชไนๅๅทฒ็ป่ขซ้ๆฏๆ็ๆฑ ๏ผๅนถไธๆๅ
ฅไฝฟ็จใ
pool.Reboot()โ๏ธ ๅ ณไบไปปๅกๆง่ก้กบๅบ
ants ๅนถไธไฟ่ฏๆไบค็ไปปๅก่ขซๆง่ก็้กบๅบ๏ผๆง่ก็้กบๅบไนไธๆฏๅๆไบค็้กบๅบไฟๆไธ่ด๏ผๅ ไธบๅจ ants ๆฏๅนถๅๅฐๅค็ๆๆๆไบค็ไปปๅก๏ผๆไบค็ไปปๅกไผ่ขซๅๆดพๅฐๆญฃๅจๅนถๅ่ฟ่ก็ workers ไธๅป๏ผๅ ๆญค้ฃไบไปปๅกๅฐไผ่ขซๅนถๅไธๆ ๅบๅฐ่ขซๆง่กใ
๐ ่ดก็ฎ่
่ฏทๅจๆ PR ไนๅไป็ป้
่ฏป Contributing Guidelines๏ผๆ่ฐข้ฃไบไธบ ants ่ดก็ฎ่ฟไปฃ็ ็ๅผๅ่
๏ผ
๐ ่ฏไนฆ
ants ็ๆบ็ ๅ
่ฎธ็จๆทๅจ้ตๅพช MIT ๅผๆบ่ฏไนฆ ่งๅ็ๅๆไธไฝฟ็จใ
๐ ็ธๅ ณๆ็ซ
- Goroutine ๅนถๅ่ฐๅบฆๆจกๅๆทฑๅบฆ่งฃๆไนๆๆธไธไธช้ซๆง่ฝ goroutine ๆฑ
- Visually Understanding Worker Pool
- The Case For A Go Worker Pool
- Go Concurrency - GoRoutines, Worker Pools and Throttling Made Simple
๐ฅ ็จๆทๆกไพ
ๅไธๅ ฌๅธๅๅผๆบ็ป็ป
ไปฅไธๅ
ฌๅธ/็ป็ปๅจ็ไบง็ฏๅขไธไฝฟ็จไบ antsใ
ๅฆๆไฝ ไนๆญฃๅจ็ไบง็ฏๅขไธไฝฟ็จ ants๏ผๆฌข่ฟๆ PR ๆฅไธฐๅฏ่ฟไปฝๅ่กจใ
ๅผๆบ่ฝฏไปถ
่ฟไบๅผๆบ้กน็ฎๅๅฉ ants ่ฟ่กๅนถๅ็ผ็จใ
- gnet: gnet ๆฏไธไธช้ซๆง่ฝใ่ฝป้็บงใ้้ปๅก็ไบไปถ้ฉฑๅจ Go ็ฝ็ปๆกๆถใ
- milvus: ไธไธช้ซๅบฆ็ตๆดปใๅฏ้ ไธ้ๅบฆๆๅฟซ็ไบๅ็ๅผๆบๅ้ๆฐๆฎๅบใ
- nps: ไธๆฌพ่ฝป้็บงใ้ซๆง่ฝใๅ่ฝๅผบๅคง็ๅ ็ฝ็ฉฟ้ไปฃ็ๆๅกๅจใ
- TDengine: TDengine ๆฏไธๆฌพๅผๆบใ้ซๆง่ฝใไบๅ็็ๆถๅบๆฐๆฎๅบ (Time-Series Database, TSDB)ใTDengine ่ฝ่ขซๅนฟๆณ่ฟ็จไบ็ฉ่็ฝใๅทฅไธไบ่็ฝใ่ฝฆ่็ฝใIT ่ฟ็ปดใ้่็ญ้ขๅใ
- siyuan: ๆๆบ็ฌ่ฎฐๆฏไธๆฌพๆฌๅฐไผๅ ็ไธชไบบ็ฅ่ฏ็ฎก็็ณป็ป๏ผๆฏๆๅฎๅ จ็ฆป็บฟไฝฟ็จ๏ผๅๆถไนๆฏๆ็ซฏๅฐ็ซฏๅ ๅฏๅๆญฅใ
- BillionMail: BillionMail ๆฏไธไธชๆชๆฅ็ๅผๆบ้ฎไปถๆๅกๅจๅ็ตๅญ้ฎไปถ่ฅ้ๅนณๅฐ๏ผๆจๅจๅธฎๅฉไผไธๅไธชไบบ่ฝปๆพ็ฎก็ไปไปฌ็็ตๅญ้ฎไปถ่ฅ้ๆดปๅจใ
- WeKnora: ไธๆฌพๅบไบๅคง่ฏญ่จๆจกๅ๏ผLLM๏ผ็ๆๆกฃ็่งฃไธ่ฏญไนๆฃ็ดขๆกๆถ๏ผไธไธบ็ปๆๅคๆใๅ ๅฎนๅผๆ็ๆๆกฃๅบๆฏ่ๆ้ ใ
- coze-loop: Coze Loop ๆฏไธไธช้ขๅๅผๅ่ ๏ผไธๆณจไบ AI Agent ๅผๅไธ่ฟ็ปด็ๅนณๅฐ็บง่งฃๅณๆนๆกใ
- osmedeus: A Workflow Engine for Offensive Security.
- jitsu: An open-source Segment alternative. Fully-scriptable data ingestion engine for modern data teams. Set-up a real-time data pipeline in minutes, not days.
- triangula: Generate high-quality triangulated and polygonal art from images.
- teler: Real-time HTTP Intrusion Detection.
- bsc: A Binance Smart Chain client based on the go-ethereum fork.
- jaeles: The Swiss Army knife for automated Web Application Testing.
- devlake: The open-source dev data platform & dashboard for your DevOps tools.
- matrixone: MatrixOne ๆฏไธๆฌพ้ขๅๆชๆฅ็่ถ ่ๅๅผๆไบๅ็ๆฐๆฎๅบ๏ผ้่ฟ่ถ ่ๅๆฐๆฎๅผๆๆฏๆไบๅก/ๅๆ/ๆตๅค็็ญๆททๅๅทฅไฝ่ด่ฝฝ๏ผ้่ฟๅผๆไบๅ็ๆถๆๆฏๆ่ทจๆบๆฟๅๅ/ๅคๅฐๅๅ/ไบ่พนๅๅใ็ฎๅๅผๅ่ฟ็ปด๏ผๆถ็ฎๆฐๆฎ็ข็๏ผๆ็ ดๆฐๆฎ็็ณป็ปใไฝ็ฝฎๅๅๆฐ่พน็ใ
- bk-bcs: ่้ฒธๅฎนๅจ็ฎก็ๅนณๅฐ๏ผBlueking Container Service๏ผๅฎไฝไบๆ้ ไบๅ็ๆๆฏๅไธๅกๅฎ้ ๅบ็จๅบๆฏไน้ด็ๆกฅๆข๏ผ่็ฆไบๅคๆๅบ็จๅบๆฏ็ๅฎนๅจๅ้จ็ฝฒๆๆฏๆนๆก็็ ๅใๆดๅๅไบงๅๅ๏ผ่ดๅไบไธบๆธธๆ็ญๅคๆๅบ็จๆไพไธ็ซๅผใไฝ้จๆง็ๅฎนๅจ็ผๆๅๆๅกๆฒป็ๆๅกใ
- trueblocks-core: TrueBlocks improves access to blockchain data for any EVM-compatible chain (particularly Ethereum mainnet) while remaining entirely local.
- openGemini: openGemini ๆฏๅไธบไบๅผๆบ็ไธๆฌพไบๅ็ๅๅธๅผๆถๅบๆฐๆฎๅบ๏ผๅฏๅนฟๆณๅบ็จไบ็ฉ่็ฝใ่ฝฆ่็ฝใ่ฟ็ปด็ๆงใๅทฅไธไบ่็ฝ็ญไธๅกๅบๆฏ๏ผๅ ทๅคๅ่ถ็่ฏปๅๆง่ฝๅ้ซๆ็ๆฐๆฎๅๆ่ฝๅ๏ผ้็จ็ฑปSQLๆฅ่ฏข่ฏญ่จ๏ผๆ ็ฌฌไธๆน่ฝฏไปถไพ่ตใๅฎ่ฃ ็ฎๅใ้จ็ฝฒ็ตๆดปใ่ฟ็ปดไพฟๆทใ
- AdGuardDNS: AdGuard DNS is an alternative solution for tracker blocking, privacy protection, and parental control.
- WatchAD2.0: WatchAD2.0 ๆฏ 360 ไฟกๆฏๅฎๅ จไธญๅฟๅผๅ็ไธๆฌพ้ๅฏนๅๅฎๅ จ็ๆฅๅฟๅๆไธ็ๆง็ณป็ป๏ผๅฎๅฏไปฅๆถ้ๆๆๅๆงไธ็ไบไปถๆฅๅฟใ็ฝ็ปๆต้๏ผ้่ฟ็นๅพๅน้ ใๅ่ฎฎๅๆใๅๅฒ่กไธบใๆๆๆไฝๅ่็ฝ่ดฆๆท็ญๆนๅผๆฅๆฃๆตๅ็งๅทฒ็ฅไธๆช็ฅๅจ่๏ผๅ่ฝ่ฆ็ไบๅคง้จๅ็ฎๅ็ๅธธ่งๅ ็ฝๅๆธ้ๆๆณใ
- vanus: Vanus is a Serverless, event streaming system with processing capabilities. It easily connects SaaS, Cloud Services, and Databases to help users build next-gen Event-driven Applications.
- trpc-go: ไธไธช Go ๅฎ็ฐ็ๅฏๆๆ็้ซๆง่ฝ RPC ๆกๆถใ
- motan-go: Motan ๆฏไธๅฅ้ซๆง่ฝใๆไบไฝฟ็จ็ๅๅธๅผ่ฟ็จๆๅก่ฐ็จ (RPC) ๆกๆถใmotan-go ๆฏ motan ็ Go ่ฏญ่จๅฎ็ฐใ
ๆๆๆกไพ:
ๅฆๆไฝ ็้กน็ฎไนๅจไฝฟ็จ ants๏ผๆฌข่ฟ็ปๆๆ Pull Request ๆฅๆดๆฐ่ฟไปฝ็จๆทๆกไพๅ่กจใ
๐ JetBrains ๅผๆบ่ฏไนฆๆฏๆ
ants ้กน็ฎไธ็ดไปฅๆฅ้ฝๆฏๅจ JetBrains ๅ
ฌๅธๆไธ็ GoLand ้ๆๅผๅ็ฏๅขไธญ่ฟ่กๅผๅ๏ผๅบไบ free JetBrains Open Source license(s) ๆญฃ็ๅ
่ดนๆๆ๏ผๅจๆญค่กจ่พพๆ็่ฐขๆใ
โ๏ธ ๆ่ต
ๅฝๆจ้่ฟไปฅไธๆนๅผ่ฟ่กๆ่ต ๆถ๏ผ่ฏทๅกๅฟ ็ไธๅงๅใGitHub ่ดฆๅทๆๅ ถไป็คพไบคๅชไฝ่ดฆๅท๏ผไปฅไพฟๆๅฐๅ ถๆทปๅ ๅฐๆ่ต ่ ๅๅไธญ๏ผไปฅ่กจ่ฐขๆใ
๐ ่ตๅฉๅ
File: .github/FUNDING.yml
These are supported funding model platforms
github: [panjf2000]
patreon: panjf2000
open_collective: panjf2000
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
File: .github/pull_request_template.md
1. Are you opening this pull request for bug-fixs, optimizations or new feature?
2. Please describe how these code changes achieve your intention.
3. Please link to the relevant issues (if any).
4. Which documentation changes (if any) need to be made/updated because of this PR?
4. Checklist
- I have squashed all insignificant commits.
- I have commented my code for explaining package types, values, functions, and non-obvious lines.
- I have written unit tests and verified that all tests passes (if needed).
- I have documented feature info on the README (only when this PR is adding a new feature).
- (optional) I am willing to help maintain this change if there are issues with it later.
File: .github/release-drafter.yml
name-template: Ants v$RESOLVED_VERSION
tag-template: v$RESOLVED_VERSION
categories:
- title: ๐งจ Breaking changes
labels:
- breaking changes
- title: ๐ Features
labels:
- proposal
- new feature
- title: ๐ฉ Enhancements
labels:
- enhancement
- optimization
- title: ๐ Bugfixes
labels:
- bug
- title: ๐ Documentation
labels:
- doc
- docs
- title: ๐ Misc
labels:
- chores
change-template: '- $TITLE (#$NUMBER)'
change-title-escapes: '<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- major
minor:
labels:
- minor
- new feature
- proposal
patch:
labels:
- patch
- bug
- dependencies
default: patch
autolabeler:
label: bug
title:- /fix/i
- /bug/i
- /resolve/i
label: docs
files:- '*.md'
title: - /doc/i
- /README/i
- '*.md'
label: enhancement
title:- /opt:/i
- /refactor/i
- /optimize/i
- /improve/i
- /update/i
- /remove/i
- /delete/i
label: optimization
title:- /opt:/i
- /refactor/i
- /optimize/i
- /improve/i
- /update/i
- /remove/i
- /delete/i
label: new feature
title:- /feat:/i
- /feature/i
- /implement/i
- /add/i
- /minor/i
label: dependencies
title:- /dependencies/i
- /upgrade/i
- /bump up/i
label: chores
title:- /chore/i
- /misc/i
- /cleanup/i
- /clean up/i
label: major
title:- /major:/i
label: minor
title:- /minor:/i
label: patch
title:- /patch:/i
template: |
Changelogs
$CHANGES
Full Changelog: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
Thanks to all these contributors: $CONTRIBUTORS for making this release possible.
- /patch:/i
File: .github/ISSUE_TEMPLATE/bug-report.yaml
name: Bug Report
title: "[Bug]: "
labels: ["bug"]
assignees:
- panjf2000
body: - type: markdown
id: tips
attributes:
value: |
## Before you go any further
- Please read How To Ask Questions The Smart Way ( Chinese translation: ใๆ้ฎ็ๆบๆ งใ) before you file an issue formally.
- Keep in mind that there is always welcome to ask questions on Discord. - type: checkboxes
id: checklist
attributes:
label: Actions I've taken before I'm here
options:
- label: I've thoroughly read the documentations on this issue but still have no clue.
required: true
- label: I've searched the current list of Github issues but didn't find any duplicate issues that have been solved.
required: true
- label: I've searched the internet with this issue, but haven't found anything helpful.
required: true
validations:
required: true - type: textarea
id: bug-report
attributes:
label: What happened?
placeholder: Please describe what happened and how it happened, the more details you provide, the faster the bug gets fixed.
validations:
required: true - type: dropdown
id: major-version
attributes:
label: Major version of ants
options:
- v2
- v1
validations:
required: true - type: input
id: specific-version
attributes:
label: Specific version of ants
placeholder: "For example: v2.6.0"
validations:
required: true - type: dropdown
id: os
attributes:
label: Operating system
multiple: true
options:
- Linux
- macOS
- Windows
- BSD
validations:
required: true - type: input
id: os-version
attributes:
label: OS version
placeholder: "Rununame -srmcommand to get the info, for example: Darwin 21.5.0 arm64, Linux 5.4.0-137-generic x86_64"
validations:
required: true - type: input
id: go-version
attributes:
label: Go version
placeholder: "Rungo versioncommand to get the info, for example: go1.20.5 linux/amd64"
validations:
required: true - type: textarea
id: logs
attributes:
label: Relevant log output
render: shell
validations:
required: true - type: textarea
id: code
attributes:
label: Reproducer
render: go - type: textarea
id: how-to-reproduce
attributes:
label: How to Reproduce
placeholder: Tell us step by step how we can replicate this bug and what we should see in the end.
value: |
Steps to reproduce the behavior:
1. Go to '....'
2. Click on '....'
3. Do '....'
4. See '....'
validations:
required: true - type: dropdown
id: bug-in-latest-code
attributes:
label: Does this issue reproduce with the latest release?
options:
- It can reproduce with the latest release
- It gets fixed in the latest release
- I haven't verified it with the latest release
validations:
required: true
File: .github/ISSUE_TEMPLATE/feature-request.yaml
name: Feature Request
title: "[Feature]: "
labels: ["proposal", "enhancement"]
assignees:
- panjf2000
body: - type: markdown
id: tips
attributes:
value: |
## Before you go any further
- Please read How To Ask Questions The Smart Way ( Chinese translation: ใๆ้ฎ็ๆบๆ งใ) before you file an issue formally.
- Keep in mind that there is always welcome to ask questions on Discord. - type: textarea
id: feature-request
attributes:
label: Description of new feature
placeholder: Describe this new feature with critical details.
validations:
required: true - type: textarea
id: feature-scenario
attributes:
label: Scenarios for new feature
placeholder: Please try to convince us that this new feature makes sense, also it will improve ants.
validations:
required: true - type: dropdown
id: breaking-changes
attributes:
label: Breaking changes or not?
options:
- "Yes"
- "No"
validations:
required: true - type: textarea
id: code
attributes:
label: Code snippets (optional)
render: go - type: textarea
id: feature-alternative
attributes:
label: Alternatives for new feature
placeholder: A concise but clear description of any alternative solutions or features you had in mind.
value: None. - type: textarea
id: additional-context
attributes:
label: Additional context (optional)
placeholder: What else should we know before we start discussing this new feature?
value: None.
File: .github/ISSUE_TEMPLATE/question.yaml
name: Question
title: "[Question]: "
labels: ["question", "help wanted"]
body:
- type: markdown
id: tips
attributes:
value: |
## Before you go any further
- Please read How To Ask Questions The Smart Way ( Chinese translation: ใๆ้ฎ็ๆบๆ งใ) before you file an issue formally.
- Keep in mind that there is always welcome to ask questions on Discord. - type: textarea
id: question
attributes:
label: Questions with details
placeholder: Describe your question with critical details here.
validations:
required: true - type: textarea
id: code
attributes:
label: Code snippets (optional)
render: go
File: .github/workflows/codeql.yml
name: "Code scanning"
on:
push:
branches:
- master
- dev
paths-ignore:
- '.md'
- '.yml'
- '.yaml'
- '!.github/workflows/codeql.yml'
pull_request:
branches:
- master
- dev
paths-ignore:
- '.md'
- '.yml'
- '.yaml'
- '!.github/workflows/codeql.yml'
schedule:
# โโโโโโโโโโโโโโ minute (0 - 59)
# โ โโโโโโโโโโโโโโ hour (0 - 23)
# โ โ โโโโโโโโโโโโโโ day of the month (1 - 31)
# โ โ โ โโโโโโโโโโโโโโ month (1 - 12 or JAN-DEC)
# โ โ โ โ โโโโโโโโโโโโโโ day of the week (0 - 6 or SUN-SAT)
# โ โ โ โ โ
# โ โ โ โ โ
# โ โ โ โ โ
# * * * * *
- cron: '30 4 * * 6'
jobs:
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest
permissions:
# required for all workflows
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v3
# โน๏ธ Command-line programs to run using the OS shell.
# ๐ See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# โ๏ธ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3File: .github/workflows/pull-request.yml
name: Check pull request target
on:
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- master
jobs:
check-branches:
runs-on: ubuntu-latest
steps:
- name: Check target branch
run: |
if [ ${{ github.head_ref }} != "dev" ]; then
echo "Only pull requests from dev branch are only allowed to be merged into master branch."
exit 1
fi
File: .github/workflows/release-drafter.yml
name: Release Drafter
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
pull_request_target event is required for autolabeler to support PRs from forks
pull_request_target:
types: [opened, reopened, synchronize]
permissions:
contents: read
jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https://}" >> $GITHUB_ENV
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v6
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}File: .github/workflows/stale-bot.yml
name: Monitor inactive issues and PRs
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
stale-issues:
runs-on: ubuntu-latest
permissions:
actions: write
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
operations-per-run: 50
days-before-issue-stale: 30
days-before-issue-close: 7
stale-issue-label: 'stale'
stale-issue-message: |
This issue is marked as stale because it has been open for 30 days with no activity.
You should take one of the following actions:
- Manually close this issue if it is no longer relevant
- Comment if you have more information to share
This issue will be automatically closed in 7 days if no further activity occurs.
close-issue-message: |
This issue was closed because it has been inactive for 7 days since being marked as stale.
If you believe this is a false alarm, please leave a comment for it or open a new issue, you can also reopen this issue directly if you have permission.
days-before-pr-stale: 21
days-before-pr-close: 7
stale-pr-label: 'stale'
stale-pr-message: |
This PR is marked as stale because it has been open for 21 days with no activity.
You should take one of the following actions:
- Manually close this PR if it is no longer relevant
- Push new commits or comment if you have more information to share
This PR will be automatically closed in 7 days if no further activity occurs.
close-pr-message: |
This PR was closed because it has been inactive for 7 days since being marked as stale.
If you believe this is a false alarm, feel free to reopen this PR or create a new one.
repo-token: ${{ secrets.GITHUB_TOKEN }}File: .github/workflows/test.yml
name: Run tests
on:
push:
branches:
- master
- dev
paths-ignore:
- '.md'
- '.yml'
- '.yaml'
- 'examples/*'
- '!.github/workflows/test.yml'
pull_request:
branches:
- master
- dev
paths-ignore:
- '.md'
- '.yml'
- '.yaml'
- 'examples/*'
- '!.github/workflows/test.yml'
env:
GO111MODULE: on
GOPROXY: "https://proxy.golang.org"
jobs:
lint:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
name: Run golangci-lint
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '^1.20'
cache: false
- name: Setup and run golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.13.2
args: --timeout=5m -v -E=gocritic -E=misspell -E=revive -E=godot
- name: Check Go formatting
run: golangci-lint fmt --diff -E=gofumpt test:
needs: lint
strategy:
fail-fast: false
matrix:
go: [1.19, 1.26]
os: [ubuntu-latest, macos-latest, windows-latest]
name: Go ${{ matrix.go }} @ ${{ matrix.os }}
runs-on: ${{ matrix.os}}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Print Go environment
id: go-env
run: |
printf "Using go at: $(which go)\n"
printf "Go version: $(go version)\n"
printf "\n\nGo environment:\n\n"
go env
printf "\n\nSystem environment:\n\n"
env
# Calculate the short SHA1 hash of the git commit
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Run unit tests and integrated tests
run: go test -v -race -coverprofile="codecov.report" -covermode=atomic
- name: Upload code coverage report to Codecov
uses: codecov/codecov-action@v5
with:
files: ./codecov.report
flags: unittests
name: codecov-ants
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}