Skip to content

Commit f79e4df

Browse files
authored
Merge pull request #2 from FishGoddess/develop
v0.2.0
2 parents ec975bd + c80dc40 commit f79e4df

File tree

17 files changed

+119
-129
lines changed

17 files changed

+119
-129
lines changed

.gitattributes

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ jobs:
1212
- name: Setup
1313
uses: actions/setup-go@v4
1414
with:
15-
go-version: "1.21"
15+
go-version: "1.23"
1616
- run: go version
1717

1818
- name: Checkout
1919
uses: actions/checkout@v4
2020

2121
- name: Test
22-
run: make test
22+
run: make test

FUTURE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## ✈️ 未来版本的新特性 (Features in future versions)
22

3+
### v0.2.x
4+
5+
* [x] 优化代码
6+
* [ ] 增加生命周期检测,资源检查回调
7+
38
### v0.1.x
49

510
* [x] 实现基础的控制池功能

HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## 📜 历史版本的特性介绍 (Features in old versions)
22

3+
### v0.2.0
4+
5+
> 此版本发布于 2025-04-12
6+
7+
* 优化代码
8+
39
### v0.1.1
410

511
> 此版本发布于 2024-03-07

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2024 FishGoddess
3+
Copyright (c) 2025 FishGoddess
44

55
Permission is hereby granted, free of charge, to any person obtaining
66
a copy of this software and associated documentation files (the "Software"),

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.PHONY: fmt test
22

3+
all: fmt test
4+
35
fmt:
46
go fmt ./...
57

68
test:
79
go mod tidy
8-
go test -cover -count=1 -test.cpu=1 ./...
9-
10-
all: fmt test
10+
go test -v -cover ./...

README.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func releaseConn(conn net.Conn) error {
4545

4646
func main() {
4747
// Create a resource pool which type is net.Conn and limit is 64.
48-
pool := rego.New[net.Conn](acquireConn, releaseConn, rego.WithLimit(64))
48+
pool := rego.New(64, acquireConn, releaseConn)
4949
defer pool.Close()
5050

5151
// Take a resource from pool.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func releaseConn(conn net.Conn) error {
4545

4646
func main() {
4747
// Create a resource pool which type is net.Conn and limit is 64.
48-
pool := rego.New[net.Conn](acquireConn, releaseConn, rego.WithLimit(64))
48+
pool := rego.New(64, acquireConn, releaseConn)
4949
defer pool.Close()
5050

5151
// Take a resource from pool.

_examples/basic.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 FishGoddess. All rights reserved.
1+
// Copyright 2025 FishGoddess. All rights reserved.
22
// Use of this source code is governed by a MIT style
33
// license that can be found in the LICENSE file.
44

@@ -25,7 +25,7 @@ func releaseConn(conn net.Conn) error {
2525

2626
func main() {
2727
// Create a resource pool which type is net.Conn and limit is 64.
28-
pool := rego.New[net.Conn](acquireConn, releaseConn, rego.WithLimit(64))
28+
pool := rego.New(64, acquireConn, releaseConn)
2929
defer pool.Close()
3030

3131
// Take a resource from pool.

_examples/errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 FishGoddess. All rights reserved.
1+
// Copyright 2025 FishGoddess. All rights reserved.
22
// Use of this source code is governed by a MIT style
33
// license that can be found in the LICENSE file.
44

@@ -36,7 +36,7 @@ func newPoolClosedErr(ctx context.Context) error {
3636
func main() {
3737
// Create a pool with limit and fast-failed so it will return an error immediately instead of waiting.
3838
ctx := context.Background()
39-
pool := rego.New[int](acquire, release, rego.WithLimit(1), rego.WithFastFailed())
39+
pool := rego.New(1, acquire, release, rego.WithFastFailed())
4040

4141
// Take one resource from pool which is ok.
4242
resource, err := pool.Take(ctx)
@@ -56,7 +56,7 @@ func main() {
5656
fmt.Println(resource, err, err == rego.ErrPoolIsClosed)
5757

5858
// Create a pool with limit and fast-failed and new error funcs.
59-
pool = rego.New[int](acquire, release, rego.WithLimit(1), rego.WithFastFailed(), rego.WithPoolFullErr(newPoolFullErr), rego.WithPoolClosedErr(newPoolClosedErr))
59+
pool = rego.New(1, acquire, release, rego.WithFastFailed(), rego.WithPoolFullErr(newPoolFullErr), rego.WithPoolClosedErr(newPoolClosedErr))
6060

6161
// Take one resource from pool which is ok.
6262
resource, err = pool.Take(ctx)

0 commit comments

Comments
 (0)