Skip to content

Commit d79074e

Browse files
committed
Remove PMessage.
1 parent 1fbb109 commit d79074e

File tree

7 files changed

+7
-35
lines changed

7 files changed

+7
-35
lines changed

cluster.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ func (c *ClusterClient) PoolStats() *PoolStats {
7676
s := client.connPool.Stats()
7777
acc.Requests += s.Requests
7878
acc.Hits += s.Hits
79-
acc.Waits += s.Waits
8079
acc.Timeouts += s.Timeouts
8180
acc.TotalConns += s.TotalConns
8281
acc.FreeConns += s.FreeConns

internal/pool/pool.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ var timers = sync.Pool{
2828
}
2929

3030
// PoolStats contains pool state information and accumulated stats.
31-
// TODO: remove Waits
3231
type PoolStats struct {
3332
Requests uint32 // number of times a connection was requested by the pool
3433
Hits uint32 // number of times free connection was found in the pool
35-
Waits uint32 // number of times the pool had to wait for a connection
3634
Timeouts uint32 // number of times a wait timeout occurred
3735

3836
TotalConns uint32 // the number of total connections in the pool
@@ -261,7 +259,6 @@ func (p *ConnPool) Stats() *PoolStats {
261259
stats := PoolStats{}
262260
stats.Requests = atomic.LoadUint32(&p.stats.Requests)
263261
stats.Hits = atomic.LoadUint32(&p.stats.Hits)
264-
stats.Waits = atomic.LoadUint32(&p.stats.Waits)
265262
stats.Timeouts = atomic.LoadUint32(&p.stats.Timeouts)
266263
stats.TotalConns = uint32(p.Len())
267264
stats.FreeConns = uint32(p.FreeLen())

options.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func newConnPool(opt *Options) *pool.ConnPool {
117117
type PoolStats struct {
118118
Requests uint32 // number of times a connection was requested by the pool
119119
Hits uint32 // number of times free connection was found in the pool
120-
Waits uint32 // number of times the pool had to wait for a connection
121120
Timeouts uint32 // number of times a wait timeout occurred
122121

123122
TotalConns uint32 // the number of total connections in the pool

pool_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ var _ = Describe("pool", func() {
109109
stats := pool.Stats()
110110
Expect(stats.Requests).To(Equal(uint32(4)))
111111
Expect(stats.Hits).To(Equal(uint32(2)))
112-
Expect(stats.Waits).To(Equal(uint32(0)))
113112
Expect(stats.Timeouts).To(Equal(uint32(0)))
114113
})
115114

@@ -127,7 +126,6 @@ var _ = Describe("pool", func() {
127126
stats := pool.Stats()
128127
Expect(stats.Requests).To(Equal(uint32(101)))
129128
Expect(stats.Hits).To(Equal(uint32(100)))
130-
Expect(stats.Waits).To(Equal(uint32(0)))
131129
Expect(stats.Timeouts).To(Equal(uint32(0)))
132130
})
133131
})

pubsub.go

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,6 @@ func (m *Message) String() string {
166166
return fmt.Sprintf("Message<%s: %s>", m.Channel, m.Payload)
167167
}
168168

169-
// TODO: remove PMessage if favor of Message
170-
171-
// Message matching a pattern-matching subscription received as result
172-
// of a PUBLISH command issued by another client.
173-
type PMessage struct {
174-
Channel string
175-
Pattern string
176-
Payload string
177-
}
178-
179-
func (m *PMessage) String() string {
180-
return fmt.Sprintf("PMessage<%s: %s>", m.Channel, m.Payload)
181-
}
182-
183169
// Pong received as result of a PING command issued by another client.
184170
type Pong struct {
185171
Payload string
@@ -206,7 +192,7 @@ func (c *PubSub) newMessage(reply []interface{}) (interface{}, error) {
206192
Payload: reply[2].(string),
207193
}, nil
208194
case "pmessage":
209-
return &PMessage{
195+
return &Message{
210196
Pattern: reply[1].(string),
211197
Channel: reply[2].(string),
212198
Payload: reply[3].(string),
@@ -244,9 +230,9 @@ func (c *PubSub) ReceiveTimeout(timeout time.Duration) (interface{}, error) {
244230
return c.newMessage(cmd.Val())
245231
}
246232

247-
// Receive returns a message as a Subscription, Message, PMessage,
248-
// Pong or error. See PubSub example for details. This is low-level
249-
// API and most clients should use ReceiveMessage.
233+
// Receive returns a message as a Subscription, Message, Pong or error.
234+
// See PubSub example for details. This is low-level API and most clients
235+
// should use ReceiveMessage.
250236
func (c *PubSub) Receive() (interface{}, error) {
251237
return c.ReceiveTimeout(0)
252238
}
@@ -290,12 +276,6 @@ func (c *PubSub) ReceiveMessage() (*Message, error) {
290276
// Ignore.
291277
case *Message:
292278
return msg, nil
293-
case *PMessage:
294-
return &Message{
295-
Channel: msg.Channel,
296-
Pattern: msg.Pattern,
297-
Payload: msg.Payload,
298-
}, nil
299279
default:
300280
return nil, fmt.Errorf("redis: unknown message: %T", msgi)
301281
}

pubsub_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var _ = Describe("PubSub", func() {
5353
{
5454
msgi, err := pubsub.ReceiveTimeout(time.Second)
5555
Expect(err).NotTo(HaveOccurred())
56-
subscr := msgi.(*redis.PMessage)
56+
subscr := msgi.(*redis.Message)
5757
Expect(subscr.Channel).To(Equal("mychannel1"))
5858
Expect(subscr.Pattern).To(Equal("mychannel*"))
5959
Expect(subscr.Payload).To(Equal("hello"))
@@ -69,7 +69,7 @@ var _ = Describe("PubSub", func() {
6969
}
7070

7171
stats := client.PoolStats()
72-
Expect(stats.Requests - stats.Hits - stats.Waits).To(Equal(uint32(2)))
72+
Expect(stats.Requests - stats.Hits).To(Equal(uint32(2)))
7373
})
7474

7575
It("should pub/sub channels", func() {
@@ -196,7 +196,7 @@ var _ = Describe("PubSub", func() {
196196
}
197197

198198
stats := client.PoolStats()
199-
Expect(stats.Requests - stats.Hits - stats.Waits).To(Equal(uint32(2)))
199+
Expect(stats.Requests - stats.Hits).To(Equal(uint32(2)))
200200
})
201201

202202
It("should ping/pong", func() {

redis.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ func (c *Client) PoolStats() *PoolStats {
167167
return &PoolStats{
168168
Requests: s.Requests,
169169
Hits: s.Hits,
170-
Waits: s.Waits,
171170
Timeouts: s.Timeouts,
172171

173172
TotalConns: s.TotalConns,

0 commit comments

Comments
 (0)