Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nomisrev/gcp-pubsub-kt
Ktor Plugin and Kotlin(X) integrations for GCP PubSub
https://github.com/nomisrev/gcp-pubsub-kt
gcp gcp-pubsub google-cloud-platform google-cloud-pubsub kotlin kotlin-coroutines kotlin-serialization kotlinx-coroutines kotlinx-serialization ktor ktor-plugin ktor-server pubsub
Last synced: 21 days ago
JSON representation
Ktor Plugin and Kotlin(X) integrations for GCP PubSub
- Host: GitHub
- URL: https://github.com/nomisrev/gcp-pubsub-kt
- Owner: nomisRev
- License: apache-2.0
- Created: 2022-12-11T18:55:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-09T17:20:22.000Z (about 1 year ago)
- Last Synced: 2024-10-15T06:42:02.579Z (21 days ago)
- Topics: gcp, gcp-pubsub, google-cloud-platform, google-cloud-pubsub, kotlin, kotlin-coroutines, kotlin-serialization, kotlinx-coroutines, kotlinx-serialization, ktor, ktor-plugin, ktor-server, pubsub
- Language: Kotlin
- Homepage: https://nomisrev.github.io/kotlin-gcp-pubsub/
- Size: 360 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kotlin GCP PubSub
Google Cloud PubSub made easy! Kotlin GCP PubSub offers idiomatic KotlinX & Ktor integration for GCP.
```kotlin
@Serializable
data class Event(val key: String, val message: String)fun Application.pubSubApp() {
pubSub(ProjectId("my-project")) {
subscribe(SubscriptionId("my-subscription")) { (event, record) ->
println("event.key: ${event.key}, event.message: ${event.message}")
record.ack()
}
}routing {
post("/publish/{key}/{message}") {
val event = Event(call.parameters["key"]!!, call.parameters["message"]!!)
pubSub()
.publisher(ProjectId("my-project"))
.publish(TopicId("my-topic"), event)
call.respond(HttpStatusCode.Accepted)
}
}
}
```## Modules
- [PubSub Ktor plugin](pubsub-ktor/README.MD) to conveniently consume messages from GCP PubSub, and publish messages to
GCP PubSub
- [PubSub Ktor KotlinX Serialization Json](pubsub-ktor-kotlinx-serialization-json/README.MD) to conveniently consume
messages from GCP PubSub, and publish messages to GCP PubSub using KotlinX Serialization Json
- [PubSub test](pubsub-test/README.MD) one-line testing support powered by testcontainers
- [GCP PubSub](pubsub/README.MD): KotlinX integration for `TopicAdminClient`, `SubscriptionAdminClient`, `Susbcriber`
and `Publisher`.
- [PubSub Ktor KotlinX Serialization Json](pubsub-kotlinx-serialization-json/README.MD) to conveniently consume messages
from GCP PubSub, and publish messages to GCP PubSub
- [Google Common API](api-core/README.MD): KotlinX integration for `ApiFuture`## Using in your projects
### Gradle
Add dependencies (you can also add other modules that you need):
```kotlin
dependencies {
implementation("io.github.nomisrev:gcp-pubsub-ktor:1.0.0")
implementation("io.github.nomisrev:gcp-pubsub-ktor-kotlinx-serialization-json:1.0.0")
testImplementation("io.github.nomisrev:gcp-pubsub-test:1.0.0")
}
```### Maven
Add dependencies (you can also add other modules that you need):
```xml
io.github.nomisrev
gcp-pubsub-ktor
1.0.0```