-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
78 lines (65 loc) · 1.93 KB
/
options.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
67
68
69
70
71
72
73
74
75
76
77
78
package realtime_pubsub
// PublishOptions represents options for publishing messages.
type PublishOptions struct {
ID string
MessageType string
Compress bool
}
// PublishOption defines a function type for setting PublishOptions.
type PublishOption func(*PublishOptions)
// WithPublishID sets the ID in PublishOptions.
func WithPublishID(id string) PublishOption {
return func(opts *PublishOptions) {
opts.ID = id
}
}
// WithPublishMessageType sets the MessageType in PublishOptions.
func WithPublishMessageType(messageType string) PublishOption {
return func(opts *PublishOptions) {
opts.MessageType = messageType
}
}
// WithPublishCompress sets the Compress flag in PublishOptions.
func WithPublishCompress(compress bool) PublishOption {
return func(opts *PublishOptions) {
opts.Compress = compress
}
}
// SendOptions represents options for sending messages.
type SendOptions struct {
ID string
MessageType string
Compress bool
}
// SendOption defines a function type for setting SendOptions.
type SendOption func(*SendOptions)
// WithSendID sets the ID in SendOptions.
func WithSendID(id string) SendOption {
return func(opts *SendOptions) {
opts.ID = id
}
}
// WithSendMessageType sets the MessageType in SendOptions.
func WithSendMessageType(messageType string) SendOption {
return func(opts *SendOptions) {
opts.MessageType = messageType
}
}
// WithSendCompress sets the Compress flag in SendOptions.
func WithSendCompress(compress bool) SendOption {
return func(opts *SendOptions) {
opts.Compress = compress
}
}
// ReplyOptions represents options for replying to messages.
type ReplyOptions struct {
Compress bool
}
// ReplyOption defines a function type for setting ReplyOptions.
type ReplyOption func(*ReplyOptions)
// WithReplyCompress sets the Compress flag in ReplyOptions.
func WithReplyCompress(compress bool) ReplyOption {
return func(opts *ReplyOptions) {
opts.Compress = compress
}
}