Skip to content

Commit 8640326

Browse files
committed
调整部分代码
1 parent 0699d69 commit 8640326

File tree

14 files changed

+51
-83
lines changed

14 files changed

+51
-83
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

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)

_examples/pool.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

@@ -56,7 +56,7 @@ func main() {
5656
// The acquire function is for acquiring a new resource, and you can do some setups for your resource.
5757
// The release function is for releasing the given resource, and you can destroy everything of your resource.
5858
// Also, you can specify some options to change the default settings.
59-
pool := rego.New[*http.Client](acquireClient, releaseClient, rego.WithLimit(4))
59+
pool := rego.New(4, acquireClient, releaseClient)
6060
defer pool.Close()
6161

6262
var wg sync.WaitGroup

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/FishGoddess/rego
22

3-
go 1.21
3+
go 1.23

0 commit comments

Comments
 (0)