This repository has been archived by the owner on Jun 19, 2023. It is now read-only.
/
pubsub.go
66 lines (54 loc) · 1.65 KB
/
pubsub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package options
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSubPeersSettings
type PubSubPeersSettings struct {
Topic string
}
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSubSubscribeSettings
type PubSubSubscribeSettings struct {
Discover bool
}
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSubPeersOption
type PubSubPeersOption func(*PubSubPeersSettings) error
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSubSubscribeOption
type PubSubSubscribeOption func(*PubSubSubscribeSettings) error
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSubPeersOptions
func PubSubPeersOptions(opts ...PubSubPeersOption) (*PubSubPeersSettings, error) {
options := &PubSubPeersSettings{
Topic: "",
}
for _, opt := range opts {
err := opt(options)
if err != nil {
return nil, err
}
}
return options, nil
}
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSubSubscribeOptions
func PubSubSubscribeOptions(opts ...PubSubSubscribeOption) (*PubSubSubscribeSettings, error) {
options := &PubSubSubscribeSettings{
Discover: false,
}
for _, opt := range opts {
err := opt(options)
if err != nil {
return nil, err
}
}
return options, nil
}
type pubsubOpts struct{}
// Deprecated: use github.com/ipfs/boxo/coreiface/options.PubSub
var PubSub pubsubOpts
func (pubsubOpts) Topic(topic string) PubSubPeersOption {
return func(settings *PubSubPeersSettings) error {
settings.Topic = topic
return nil
}
}
func (pubsubOpts) Discover(discover bool) PubSubSubscribeOption {
return func(settings *PubSubSubscribeSettings) error {
settings.Discover = discover
return nil
}
}