@@ -33,11 +33,11 @@ type state struct {
33
33
34
34
// Returns a slice containing a client's current queues, or empty slice if there
35
35
// are none registered
36
- func (s * state ) clientQueues (clientId string ) []string {
36
+ func (s * state ) clientQueues (clientID string ) []string {
37
37
queues := make ([]string , 0 , 8 )
38
38
for q , clients := range s .queueM {
39
39
for _ , client := range clients {
40
- if client .Id == clientId {
40
+ if client .ID == clientID {
41
41
queues = append (queues , q )
42
42
}
43
43
}
@@ -50,9 +50,9 @@ func (s *state) clientQueues(clientId string) []string {
50
50
func (s * state ) addClientQueues (client * clients.Client , queues []string ) {
51
51
for _ , q := range queues {
52
52
if mc := s .queueM [q ]; mc != nil {
53
- mc [client .Id ] = client
53
+ mc [client .ID ] = client
54
54
} else {
55
- s .queueM [q ] = map [string ]* clients.Client {client .Id : client }
55
+ s .queueM [q ] = map [string ]* clients.Client {client .ID : client }
56
56
}
57
57
}
58
58
}
@@ -61,7 +61,7 @@ func (s *state) addClientQueues(client *clients.Client, queues []string) {
61
61
func (s * state ) removeClientQueues (client * clients.Client , queues []string ) {
62
62
for _ , q := range queues {
63
63
if mc := s .queueM [q ]; mc != nil {
64
- delete (mc , client .Id )
64
+ delete (mc , client .ID )
65
65
if len (mc ) == 0 {
66
66
delete (s .queueM , q )
67
67
}
@@ -72,33 +72,33 @@ func (s *state) removeClientQueues(client *clients.Client, queues []string) {
72
72
// Returns a slice containing a queue's currently registered clients, or empty
73
73
// slice if there are none registered
74
74
func (s * state ) queueClients (queue string ) []* clients.Client {
75
- if mc := s .queueM [queue ]; mc == nil {
75
+ mc := s .queueM [queue ]
76
+ if mc == nil {
76
77
return []* clients.Client {}
77
- } else {
78
- cs := make ([]* clients.Client , 0 , len (mc ))
79
- for _ , c := range mc {
80
- cs = append (cs , c )
81
- }
82
- return cs
83
78
}
79
+ cs := make ([]* clients.Client , 0 , len (mc ))
80
+ for _ , c := range mc {
81
+ cs = append (cs , c )
82
+ }
83
+ return cs
84
84
}
85
85
86
86
// Returns a slice of all queues currently registered by at least one client
87
87
func (s * state ) registeredQueues () []string {
88
88
qs := make ([]string , 0 , len (s .queueM ))
89
- for q , _ := range s .queueM {
89
+ for q := range s .queueM {
90
90
qs = append (qs , q )
91
91
}
92
92
return qs
93
93
}
94
94
95
- // Should be called whenever a client changes what queues it's registered for.
96
- // The new full list of registered queues should be passed in, this method will
97
- // do a diff and figure it out what was removed
95
+ // UpdateQueues should be called whenever a client changes what queues it's
96
+ // registered for. The new full list of registered queues should be passed in,
97
+ // this method will do a diff and figure it out what was removed
98
98
func UpdateQueues (client * clients.Client , queues []string ) error {
99
99
respCh := make (chan error )
100
100
callCh <- func (s * state ) {
101
- oldQueues := s .clientQueues (client .Id )
101
+ oldQueues := s .clientQueues (client .ID )
102
102
removed := stringSliceSub (oldQueues , queues )
103
103
s .addClientQueues (client , queues )
104
104
s .removeClientQueues (client , removed )
@@ -120,12 +120,12 @@ func UpdateQueues(client *clients.Client, queues []string) error {
120
120
121
121
for _ , queueName := range removed {
122
122
consumersKey := db .ConsumersKey (queueName )
123
- redisClient .Append ("ZREM" , consumersKey , client .Id )
123
+ redisClient .Append ("ZREM" , consumersKey , client .ID )
124
124
pipelineSize ++
125
125
}
126
126
for _ , queueName := range queues {
127
127
consumersKey := db .ConsumersKey (queueName )
128
- redisClient .Append ("ZADD" , consumersKey , ts , client .Id )
128
+ redisClient .Append ("ZADD" , consumersKey , ts , client .ID )
129
129
pipelineSize ++
130
130
}
131
131
for i := 0 ; i < pipelineSize ; i ++ {
@@ -173,8 +173,8 @@ outer:
173
173
return ret
174
174
}
175
175
176
- // Returns the total number of consumers registered for the given queue, either
177
- // on this okq instance or others
176
+ // QueueConsumerCount returns the total number of consumers registered for the
177
+ // given queue, either on this okq instance or others
178
178
func QueueConsumerCount (queue string ) (int64 , error ) {
179
179
consumersKey := db .ConsumersKey (queue )
180
180
0 commit comments