@@ -14,7 +14,7 @@ public interface MessageEncoder<A> {
14
14
15
15
public fun GcpPublisher (
16
16
projectId : ProjectId ,
17
- configure : Publisher .Builder .(topicId: TopicId ) -> Unit = {}
17
+ configure : Publisher .Builder .(topicId: TopicId ) -> Unit = {},
18
18
): GcpPublisher = DefaultGcpPublisher (projectId, configure)
19
19
20
20
public interface GcpPublisher : AutoCloseable {
@@ -25,43 +25,43 @@ public interface GcpPublisher : AutoCloseable {
25
25
public suspend fun <A > publish (
26
26
topicId : TopicId ,
27
27
messages : Iterable <A >,
28
- encoder : MessageEncoder <A >
28
+ encoder : MessageEncoder <A >,
29
29
): List <String > = publish(topicId, messages.map { encoder.encode(it) })
30
30
31
31
public suspend fun publish (
32
32
topicId : TopicId ,
33
33
message : ByteString ,
34
- configure : PubsubMessage .Builder .() -> Unit = {}
34
+ configure : PubsubMessage .Builder .() -> Unit = {},
35
35
): String = publish(topicId, PubsubMessage .newBuilder().setData(message).apply (configure).build())
36
36
37
37
public suspend fun publish (
38
38
topicId : TopicId ,
39
39
message : String ,
40
- configure : PubsubMessage .Builder .() -> Unit = {}
40
+ configure : PubsubMessage .Builder .() -> Unit = {},
41
41
): String =
42
42
publish(
43
43
topicId,
44
- PubsubMessage .newBuilder().setData(ByteString .copyFromUtf8(message)).apply (configure).build()
44
+ PubsubMessage .newBuilder().setData(ByteString .copyFromUtf8(message)).apply (configure).build(),
45
45
)
46
46
47
47
public suspend fun publish (
48
48
topicId : TopicId ,
49
49
message : ByteBuffer ,
50
- configure : PubsubMessage .Builder .() -> Unit = {}
50
+ configure : PubsubMessage .Builder .() -> Unit = {},
51
51
): String =
52
52
publish(
53
53
topicId,
54
- PubsubMessage .newBuilder().setData(ByteString .copyFrom(message)).apply (configure).build()
54
+ PubsubMessage .newBuilder().setData(ByteString .copyFrom(message)).apply (configure).build(),
55
55
)
56
56
57
57
public suspend fun publish (
58
58
topicId : TopicId ,
59
59
message : ByteArray ,
60
- configure : PubsubMessage .Builder .() -> Unit = {}
60
+ configure : PubsubMessage .Builder .() -> Unit = {},
61
61
): String =
62
62
publish(
63
63
topicId,
64
- PubsubMessage .newBuilder().setData(ByteString .copyFrom(message)).apply (configure).build()
64
+ PubsubMessage .newBuilder().setData(ByteString .copyFrom(message)).apply (configure).build(),
65
65
)
66
66
67
67
public suspend fun <A > publish (topicId : TopicId , message : A , encoder : MessageEncoder <A >): String =
@@ -72,52 +72,52 @@ public interface GcpPublisher : AutoCloseable {
72
72
public suspend fun GcpPublisher.publish (
73
73
topicId : TopicId ,
74
74
messages : Iterable <ByteString >,
75
- configure : PubsubMessage .Builder .() -> Unit = {}
75
+ configure : PubsubMessage .Builder .() -> Unit = {},
76
76
): List <String > =
77
77
publish(topicId, messages.map { PubsubMessage .newBuilder().setData(it).apply (configure).build() })
78
78
79
79
@JvmName(" publishString" )
80
80
public suspend fun GcpPublisher.publish (
81
81
topicId : TopicId ,
82
82
messages : Iterable <String >,
83
- configure : PubsubMessage .Builder .() -> Unit = {}
83
+ configure : PubsubMessage .Builder .() -> Unit = {},
84
84
): List <String > =
85
85
publish(
86
86
topicId,
87
87
messages.map {
88
88
PubsubMessage .newBuilder().setData(ByteString .copyFromUtf8(it)).apply (configure).build()
89
- }
89
+ },
90
90
)
91
91
92
92
@JvmName(" publishByteBuffer" )
93
93
public suspend fun GcpPublisher.publish (
94
94
topicId : TopicId ,
95
95
messages : Iterable <ByteBuffer >,
96
- configure : PubsubMessage .Builder .() -> Unit = {}
96
+ configure : PubsubMessage .Builder .() -> Unit = {},
97
97
): List <String > =
98
98
publish(
99
99
topicId,
100
100
messages.map {
101
101
PubsubMessage .newBuilder().setData(ByteString .copyFrom(it)).apply (configure).build()
102
- }
102
+ },
103
103
)
104
104
105
105
@JvmName(" publishByteArray" )
106
106
public suspend fun GcpPublisher.publish (
107
107
topicId : TopicId ,
108
108
messages : Iterable <ByteArray >,
109
- configure : PubsubMessage .Builder .() -> Unit = {}
109
+ configure : PubsubMessage .Builder .() -> Unit = {},
110
110
): List <String > =
111
111
publish(
112
112
topicId,
113
113
messages.map {
114
114
PubsubMessage .newBuilder().setData(ByteString .copyFrom(it)).apply (configure).build()
115
- }
115
+ },
116
116
)
117
117
118
118
private class DefaultGcpPublisher (
119
119
val projectId : ProjectId ,
120
- val configure : Publisher .Builder .(topicId: TopicId ) -> Unit
120
+ val configure : Publisher .Builder .(topicId: TopicId ) -> Unit ,
121
121
) : GcpPublisher {
122
122
val publisherCache = ConcurrentHashMap <TopicId , Publisher >()
123
123
0 commit comments