-
Notifications
You must be signed in to change notification settings - Fork 3
/
option.go
48 lines (41 loc) · 1.17 KB
/
option.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
package server
import (
"github.com/bizflycloud/bizfly-backup/pkg/backupapi"
"github.com/bizflycloud/bizfly-backup/pkg/broker"
)
type Option func(s *Server) error
// WithAddr returns an Option which set the server listening address.
func WithAddr(addr string) Option {
return func(s *Server) error {
s.Addr = addr
return nil
}
}
// WithBroker returns an Option which set the server broker for async messaging.
func WithBroker(b broker.Broker) Option {
return func(s *Server) error {
s.b = b
return nil
}
}
// WithSubscribeTopics returns an Option which set the subscribeTopics that server broker will subscribe to.
func WithSubscribeTopics(topics ...string) Option {
return func(s *Server) error {
s.subscribeTopics = topics
return nil
}
}
// WithPublishTopic returns an Option which set the server topic that server broker will publish message.
func WithPublishTopics(topics ...string) Option {
return func(s *Server) error {
s.publishTopics = topics
return nil
}
}
// WithBackupClient returns an Option which set the backup client for Server.
func WithBackupClient(c *backupapi.Client) Option {
return func(s *Server) error {
s.backupClient = c
return nil
}
}