Point briantigerchow/pubsub GoDep'ed module to the gx'ed version
This removes briantigerchow/pubsub from Godeps and uses our gx'ed version instead. License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
Hector Sanjuan committed
Feb 15, 2018 at 23:03 UTC
6950d0688ea5b97d7d2eb045279dd12ca9aebef4
6 files changed
+8
-519
Godeps/Godeps.json
-4
@@ -9,10 +9,6 @@
9
"ImportPath": "bazil.org/fuse",
10
"Rev": "e4fcc9a2c7567d1c42861deebeb483315d222262"
11
},
12
- {
13
- "ImportPath": "github.com/briantigerchow/pubsub",
14
- "Rev": "39ce5f556423a4c7223b370fa17a3bbd75b2d197"
15
- },
12
{
13
"ImportPath": "github.com/camlistore/lock",
14
"Rev": "ae27720f340952636b826119b58130b9c1a847a0"
Godeps/_workspace/src/github.com/briantigerchow/pubsub/README.md
deleted
-30
@@ -1,30 +0,0 @@
1
-Install pubsub with,
2
-
3
- go get github.com/tuxychandru/pubsub
4
-
5
-View the [API Documentation](http://godoc.org/github.com/tuxychandru/pubsub).
6
-
7
-## License
8
-
9
-Copyright (c) 2013, Chandra Sekar S
10
-All rights reserved.
11
-
12
-Redistribution and use in source and binary forms, with or without
13
-modification, are permitted provided that the following conditions are met:
14
-
15
-1. Redistributions of source code must retain the above copyright notice, this
16
- list of conditions and the following disclaimer.
17
-2. Redistributions in binary form must reproduce the above copyright notice,
18
- this list of conditions and the following disclaimer in the documentation
19
- and/or other materials provided with the distribution.
20
-
21
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Godeps/_workspace/src/github.com/briantigerchow/pubsub/pubsub.go
deleted
-235
@@ -1,235 +0,0 @@
1
-// Copyright 2013, Chandra Sekar S. All rights reserved.
2
-// Use of this source code is governed by a BSD-style
3
-// license that can be found in the README.md file.
4
-
5
-// Package pubsub implements a simple multi-topic pub-sub
6
-// library.
7
-//
8
-// Topics must be strings and messages of any type can be
9
-// published. A topic can have any number of subcribers and
10
-// all of them receive messages published on the topic.
11
-package pubsub
12
-
13
-type operation int
14
-
15
-const (
16
- sub operation = iota
17
- subOnce
18
- subOnceEach
19
- pub
20
- unsub
21
- unsubAll
22
- closeTopic
23
- shutdown
24
-)
25
-
26
-// PubSub is a collection of topics.
27
-type PubSub struct {
28
- cmdChan chan cmd
29
- capacity int
30
-}
31
-
32
-type cmd struct {
33
- op operation
34
- topics []string
35
- ch chan interface{}
36
- msg interface{}
37
-}
38
-
39
-// New creates a new PubSub and starts a goroutine for handling operations.
40
-// The capacity of the channels created by Sub and SubOnce will be as specified.
41
-func New(capacity int) *PubSub {
42
- ps := &PubSub{make(chan cmd), capacity}
43
- go ps.start()
44
- return ps
45
-}
46
-
47
-// Sub returns a channel on which messages published on any of
48
-// the specified topics can be received.
49
-func (ps *PubSub) Sub(topics ...string) chan interface{} {
50
- return ps.sub(sub, topics...)
51
-}
52
-
53
-// SubOnce is similar to Sub, but only the first message published, after subscription,
54
-// on any of the specified topics can be received.
55
-func (ps *PubSub) SubOnce(topics ...string) chan interface{} {
56
- return ps.sub(subOnce, topics...)
57
-}
58
-
59
-// SubOnceEach returns a channel on which callers receive, at most, one message
60
-// for each topic.
61
-func (ps *PubSub) SubOnceEach(topics ...string) chan interface{} {
62
- return ps.sub(subOnceEach, topics...)
63
-}
64
-
65
-func (ps *PubSub) sub(op operation, topics ...string) chan interface{} {
66
- ch := make(chan interface{}, ps.capacity)
67
- ps.cmdChan <- cmd{op: op, topics: topics, ch: ch}
68
- return ch
69
-}
70
-
71
-// AddSub adds subscriptions to an existing channel.
72
-func (ps *PubSub) AddSub(ch chan interface{}, topics ...string) {
73
- ps.cmdChan <- cmd{op: sub, topics: topics, ch: ch}
74
-}
75
-
76
-// AddSubOnceEach adds subscriptions to an existing channel with SubOnceEach
77
-// behavior.
78
-func (ps *PubSub) AddSubOnceEach(ch chan interface{}, topics ...string) {
79
- ps.cmdChan <- cmd{op: subOnceEach, topics: topics, ch: ch}
80
-}
81
-
82
-// Pub publishes the given message to all subscribers of
83
-// the specified topics.
84
-func (ps *PubSub) Pub(msg interface{}, topics ...string) {
85
- ps.cmdChan <- cmd{op: pub, topics: topics, msg: msg}
86
-}
87
-
88
-// Unsub unsubscribes the given channel from the specified
89
-// topics. If no topic is specified, it is unsubscribed
90
-// from all topics.
91
-func (ps *PubSub) Unsub(ch chan interface{}, topics ...string) {
92
- if len(topics) == 0 {
93
- ps.cmdChan <- cmd{op: unsubAll, ch: ch}
94
- return
95
- }
96
-
97
- ps.cmdChan <- cmd{op: unsub, topics: topics, ch: ch}
98
-}
99
-
100
-// Close closes all channels currently subscribed to the specified topics.
101
-// If a channel is subscribed to multiple topics, some of which is
102
-// not specified, it is not closed.
103
-func (ps *PubSub) Close(topics ...string) {
104
- ps.cmdChan <- cmd{op: closeTopic, topics: topics}
105
-}
106
-
107
-// Shutdown closes all subscribed channels and terminates the goroutine.
108
-func (ps *PubSub) Shutdown() {
109
- ps.cmdChan <- cmd{op: shutdown}
110
-}
111
-
112
-func (ps *PubSub) start() {
113
- reg := registry{
114
- topics: make(map[string]map[chan interface{}]subtype),
115
- revTopics: make(map[chan interface{}]map[string]bool),
116
- }
117
-
118
-loop:
119
- for cmd := range ps.cmdChan {
120
- if cmd.topics == nil {
121
- switch cmd.op {
122
- case unsubAll:
123
- reg.removeChannel(cmd.ch)
124
-
125
- case shutdown:
126
- break loop
127
- }
128
-
129
- continue loop
130
- }
131
-
132
- for _, topic := range cmd.topics {
133
- switch cmd.op {
134
- case sub:
135
- reg.add(topic, cmd.ch, stNorm)
136
-
137
- case subOnce:
138
- reg.add(topic, cmd.ch, stOnceAny)
139
-
140
- case subOnceEach:
141
- reg.add(topic, cmd.ch, stOnceEach)
142
-
143
- case pub:
144
- reg.send(topic, cmd.msg)
145
-
146
- case unsub:
147
- reg.remove(topic, cmd.ch)
148
-
149
- case closeTopic:
150
- reg.removeTopic(topic)
151
- }
152
- }
153
- }
154
-
155
- for topic, chans := range reg.topics {
156
- for ch, _ := range chans {
157
- reg.remove(topic, ch)
158
- }
159
- }
160
-}
161
-
162
-// registry maintains the current subscription state. It's not
163
-// safe to access a registry from multiple goroutines simultaneously.
164
-type registry struct {
165
- topics map[string]map[chan interface{}]subtype
166
- revTopics map[chan interface{}]map[string]bool
167
-}
168
-
169
-type subtype int
170
-
171
-const (
172
- stOnceAny = iota
173
- stOnceEach
174
- stNorm
175
-)
176
-
177
-func (reg *registry) add(topic string, ch chan interface{}, st subtype) {
178
- if reg.topics[topic] == nil {
179
- reg.topics[topic] = make(map[chan interface{}]subtype)
180
- }
181
- reg.topics[topic][ch] = st
182
-
183
- if reg.revTopics[ch] == nil {
184
- reg.revTopics[ch] = make(map[string]bool)
185
- }
186
- reg.revTopics[ch][topic] = true
187
-}
188
-
189
-func (reg *registry) send(topic string, msg interface{}) {
190
- for ch, st := range reg.topics[topic] {
191
- ch <- msg
192
- switch st {
193
- case stOnceAny:
194
- for topic := range reg.revTopics[ch] {
195
- reg.remove(topic, ch)
196
- }
197
- case stOnceEach:
198
- reg.remove(topic, ch)
199
- }
200
- }
201
-}
202
-
203
-func (reg *registry) removeTopic(topic string) {
204
- for ch := range reg.topics[topic] {
205
- reg.remove(topic, ch)
206
- }
207
-}
208
-
209
-func (reg *registry) removeChannel(ch chan interface{}) {
210
- for topic := range reg.revTopics[ch] {
211
- reg.remove(topic, ch)
212
- }
213
-}
214
-
215
-func (reg *registry) remove(topic string, ch chan interface{}) {
216
- if _, ok := reg.topics[topic]; !ok {
217
- return
218
- }
219
-
220
- if _, ok := reg.topics[topic][ch]; !ok {
221
- return
222
- }
223
-
224
- delete(reg.topics[topic], ch)
225
- delete(reg.revTopics[ch], topic)
226
-
227
- if len(reg.topics[topic]) == 0 {
228
- delete(reg.topics, topic)
229
- }
230
-
231
- if len(reg.revTopics[ch]) == 0 {
232
- close(ch)
233
- delete(reg.revTopics, ch)
234
- }
235
-}
Godeps/_workspace/src/github.com/briantigerchow/pubsub/pubsub_test.go
deleted
-247
@@ -1,247 +0,0 @@
1
-// Copyright 2013, Chandra Sekar S. All rights reserved.
2
-// Use of this source code is governed by a BSD-style
3
-// license that can be found in the README.md file.
4
-
5
-package pubsub
6
-
7
-import (
8
- check "gopkg.in/check.v1"
9
- "runtime"
10
- "testing"
11
- "time"
12
-)
13
-
14
-var _ = check.Suite(new(Suite))
15
-
16
-func Test(t *testing.T) {
17
- check.TestingT(t)
18
-}
19
-
20
-type Suite struct{}
21
-
22
-func (s *Suite) TestSub(c *check.C) {
23
- ps := New(1)
24
- ch1 := ps.Sub("t1")
25
- ch2 := ps.Sub("t1")
26
- ch3 := ps.Sub("t2")
27
-
28
- ps.Pub("hi", "t1")
29
- c.Check(<-ch1, check.Equals, "hi")
30
- c.Check(<-ch2, check.Equals, "hi")
31
-
32
- ps.Pub("hello", "t2")
33
- c.Check(<-ch3, check.Equals, "hello")
34
-
35
- ps.Shutdown()
36
- _, ok := <-ch1
37
- c.Check(ok, check.Equals, false)
38
- _, ok = <-ch2
39
- c.Check(ok, check.Equals, false)
40
- _, ok = <-ch3
41
- c.Check(ok, check.Equals, false)
42
-}
43
-
44
-func (s *Suite) TestSubOnce(c *check.C) {
45
- ps := New(1)
46
- ch := ps.SubOnce("t1")
47
-
48
- ps.Pub("hi", "t1")
49
- c.Check(<-ch, check.Equals, "hi")
50
-
51
- _, ok := <-ch
52
- c.Check(ok, check.Equals, false)
53
- ps.Shutdown()
54
-}
55
-
56
-func (s *Suite) TestAddSub(c *check.C) {
57
- ps := New(1)
58
- ch1 := ps.Sub("t1")
59
- ch2 := ps.Sub("t2")
60
-
61
- ps.Pub("hi1", "t1")
62
- c.Check(<-ch1, check.Equals, "hi1")
63
-
64
- ps.Pub("hi2", "t2")
65
- c.Check(<-ch2, check.Equals, "hi2")
66
-
67
- ps.AddSub(ch1, "t2", "t3")
68
- ps.Pub("hi3", "t2")
69
- c.Check(<-ch1, check.Equals, "hi3")
70
- c.Check(<-ch2, check.Equals, "hi3")
71
-
72
- ps.Pub("hi4", "t3")
73
- c.Check(<-ch1, check.Equals, "hi4")
74
-
75
- ps.Shutdown()
76
-}
77
-
78
-func (s *Suite) TestUnsub(c *check.C) {
79
- ps := New(1)
80
- ch := ps.Sub("t1")
81
-
82
- ps.Pub("hi", "t1")
83
- c.Check(<-ch, check.Equals, "hi")
84
-
85
- ps.Unsub(ch, "t1")
86
- _, ok := <-ch
87
- c.Check(ok, check.Equals, false)
88
- ps.Shutdown()
89
-}
90
-
91
-func (s *Suite) TestUnsubAll(c *check.C) {
92
- ps := New(1)
93
- ch1 := ps.Sub("t1", "t2", "t3")
94
- ch2 := ps.Sub("t1", "t3")
95
-
96
- ps.Unsub(ch1)
97
-
98
- m, ok := <-ch1
99
- c.Check(ok, check.Equals, false)
100
-
101
- ps.Pub("hi", "t1")
102
- m, ok = <-ch2
103
- c.Check(m, check.Equals, "hi")
104
-
105
- ps.Shutdown()
106
-}
107
-
108
-func (s *Suite) TestClose(c *check.C) {
109
- ps := New(1)
110
- ch1 := ps.Sub("t1")
111
- ch2 := ps.Sub("t1")
112
- ch3 := ps.Sub("t2")
113
- ch4 := ps.Sub("t3")
114
-
115
- ps.Pub("hi", "t1")
116
- ps.Pub("hello", "t2")
117
- c.Check(<-ch1, check.Equals, "hi")
118
- c.Check(<-ch2, check.Equals, "hi")
119
- c.Check(<-ch3, check.Equals, "hello")
120
-
121
- ps.Close("t1", "t2")
122
- _, ok := <-ch1
123
- c.Check(ok, check.Equals, false)
124
- _, ok = <-ch2
125
- c.Check(ok, check.Equals, false)
126
- _, ok = <-ch3
127
- c.Check(ok, check.Equals, false)
128
-
129
- ps.Pub("welcome", "t3")
130
- c.Check(<-ch4, check.Equals, "welcome")
131
-
132
- ps.Shutdown()
133
-}
134
-
135
-func (s *Suite) TestUnsubAfterClose(c *check.C) {
136
- ps := New(1)
137
- ch := ps.Sub("t1")
138
- defer func() {
139
- ps.Unsub(ch, "t1")
140
- ps.Shutdown()
141
- }()
142
-
143
- ps.Close("t1")
144
- _, ok := <-ch
145
- c.Check(ok, check.Equals, false)
146
-}
147
-
148
-func (s *Suite) TestShutdown(c *check.C) {
149
- start := runtime.NumGoroutine()
150
- New(10).Shutdown()
151
- time.Sleep(1)
152
- c.Check(runtime.NumGoroutine()-start, check.Equals, 1)
153
-}
154
-
155
-func (s *Suite) TestMultiSub(c *check.C) {
156
- ps := New(1)
157
- ch := ps.Sub("t1", "t2")
158
-
159
- ps.Pub("hi", "t1")
160
- c.Check(<-ch, check.Equals, "hi")
161
-
162
- ps.Pub("hello", "t2")
163
- c.Check(<-ch, check.Equals, "hello")
164
-
165
- ps.Shutdown()
166
- _, ok := <-ch
167
- c.Check(ok, check.Equals, false)
168
-}
169
-
170
-func (s *Suite) TestMultiSubOnce(c *check.C) {
171
- ps := New(1)
172
- ch := ps.SubOnce("t1", "t2")
173
-
174
- ps.Pub("hi", "t1")
175
- c.Check(<-ch, check.Equals, "hi")
176
-
177
- ps.Pub("hello", "t2")
178
-
179
- _, ok := <-ch
180
- c.Check(ok, check.Equals, false)
181
- ps.Shutdown()
182
-}
183
-
184
-func (s *Suite) TestMultiSubOnceEach(c *check.C) {
185
- ps := New(1)
186
- ch := ps.SubOnceEach("t1", "t2")
187
-
188
- ps.Pub("hi", "t1")
189
- c.Check(<-ch, check.Equals, "hi")
190
-
191
- ps.Pub("hi!", "t1") // ignored
192
-
193
- ps.Pub("hello", "t2")
194
- c.Check(<-ch, check.Equals, "hello")
195
-
196
- _, ok := <-ch
197
- c.Check(ok, check.Equals, false)
198
- ps.Shutdown()
199
-}
200
-
201
-func (s *Suite) TestMultiPub(c *check.C) {
202
- ps := New(1)
203
- ch1 := ps.Sub("t1")
204
- ch2 := ps.Sub("t2")
205
-
206
- ps.Pub("hi", "t1", "t2")
207
- c.Check(<-ch1, check.Equals, "hi")
208
- c.Check(<-ch2, check.Equals, "hi")
209
-
210
- ps.Shutdown()
211
-}
212
-
213
-func (s *Suite) TestMultiUnsub(c *check.C) {
214
- ps := New(1)
215
- ch := ps.Sub("t1", "t2", "t3")
216
-
217
- ps.Unsub(ch, "t1")
218
-
219
- ps.Pub("hi", "t1")
220
-
221
- ps.Pub("hello", "t2")
222
- c.Check(<-ch, check.Equals, "hello")
223
-
224
- ps.Unsub(ch, "t2", "t3")
225
- _, ok := <-ch
226
- c.Check(ok, check.Equals, false)
227
-
228
- ps.Shutdown()
229
-}
230
-
231
-func (s *Suite) TestMultiClose(c *check.C) {
232
- ps := New(1)
233
- ch := ps.Sub("t1", "t2")
234
-
235
- ps.Pub("hi", "t1")
236
- c.Check(<-ch, check.Equals, "hi")
237
-
238
- ps.Close("t1")
239
- ps.Pub("hello", "t2")
240
- c.Check(<-ch, check.Equals, "hello")
241
-
242
- ps.Close("t2")
243
- _, ok := <-ch
244
- c.Check(ok, check.Equals, false)
245
-
246
- ps.Shutdown()
247
-}
exchange/bitswap/notifications/notifications.go
+2
-3
@@ -4,10 +4,9 @@ import (
4
"context"
5
"sync"
6
7
- blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
8
-
9
- pubsub "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/briantigerchow/pubsub"
7
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
8
+ pubsub "gx/ipfs/QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2/pubsub"
9
+ blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
10
)
11
12
const bufferSize = 16
package.json
+6
@@ -563,6 +563,12 @@
563
"hash": "QmTVDM4LCSUMFNQzbDLL9zQwp8usE6QHymFdh3h8vL9v6b",
564
"name": "go-ipfs-blockstore",
565
"version": "0.0.1"
566
+ },
567
+ {
568
+ "author": "why",
569
+ "hash": "QmdbxjQWogRCHRaxhhGnYdT1oQJzL9GdqSKzCdqWr85AP2",
570
+ "name": "pubsub",
571
+ "version": "1.0.0"
572
}
573
],
574
"gxVersion": "0.10.0",