blob: 30de47665482305b1473f1e7e3bf184fa37ec666 (
plain)
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
|
package client
import (
"github.com/seaweedfs/seaweedfs/weed/pb"
"time"
)
type PublishProcessor interface {
AddMessage(m *Message) error
Shutdown() error
}
type PublisherOption struct {
Masters string
Topic string
}
type Publisher struct {
option *PublisherOption
masters []pb.ServerAddress
processor *PublishStreamProcessor
}
func NewPublisher(option *PublisherOption) *Publisher {
p := &Publisher{
masters: pb.ServerAddresses(option.Masters).ToAddresses(),
option: option,
processor: NewPublishStreamProcessor(3, 887*time.Millisecond),
}
return p
}
type Message struct {
Key []byte
Content []byte
Properties map[string]string
Ts time.Time
}
func (p Publisher) Publish(m *Message) error {
return p.processor.AddMessage(m)
}
func (p Publisher) Shutdown() error {
return p.processor.Shutdown()
}
|