Skip to content

Commit cbb4467

Browse files
Changed the interface name from Interface to AcquireReleaseCloser
1 parent 944f117 commit cbb4467

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

chapter7/patterns/pool/main/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func main() {
7979
}
8080

8181
// performQueries tests the resource pool of connections.
82-
func performQueries(query int, p pool.Interface) {
82+
func performQueries(query int, p pool.AcquireReleaseCloser) {
8383
// Acquire a connection from the pool.
8484
conn, err := p.Acquire()
8585
if err != nil {

chapter7/patterns/pool/pool.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import (
1212
"sync"
1313
)
1414

15-
// Pool manages a set of resources that can be acquired, released and closed.
16-
// We name it Interface because when the package is imported it will be used
17-
// as pool.Interface, which is better semantics.
18-
type Interface interface {
15+
// AcquireReleaseCloser is behavior that need to be implemented
16+
// to use the pool package.
17+
type AcquireReleaseCloser interface {
1918
Acquire() (Resource, error)
2019
Release(Resource)
2120
Close()
@@ -43,7 +42,7 @@ var ErrInvalidCapacity = errors.New("Capacity needs to be greater than zero.")
4342

4443
// New creates a pool from a set of factory functions. A pool provides capacity
4544
// number of resources that can be shared safely by multiple goroutines.
46-
func New(fn func() (Resource, error), capacity uint) (Interface, error) {
45+
func New(fn func() (Resource, error), capacity uint) (AcquireReleaseCloser, error) {
4746
if capacity == 0 {
4847
return nil, ErrInvalidCapacity
4948
}

0 commit comments

Comments
 (0)