-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added PubSub Module * Updated GCS Module (Added pubsub notifications api's)
- Loading branch information
1 parent
2a03575
commit 24201de
Showing
51 changed files
with
1,133 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
IF (breaking changes) // major version will be bumped up | ||
## STEP 1 => Update Readme.md | ||
|
||
## STEP 2 => Merge PR into main | ||
|
||
set ThisBuild / versionPolicyIntention := Compatibility.None | ||
release | ||
## STEP 3 => Create tag(x.x.x) in main branch locally for the latest version and update remotely (use GitHub Desktop) | ||
|
||
## STEP 4 => Follow below release process locally from the main branch | ||
IF (breaking changes) // major version will be bumped up | ||
``` | ||
set ThisBuild / versionPolicyIntention := Compatibility.None | ||
release | ||
``` | ||
ELSE // patch version will be bumped up | ||
``` | ||
release | ||
``` | ||
|
||
## STEP 5 => Create release using the above tag (Using github.com) | ||
|
||
release | ||
## STEP 6 => Create new branch (vnext) from main with version(+1) changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Run PubSub Emulator in one terminal | ||
```shell | ||
gcloud beta emulators pubsub start --project=testproject --host-port=0.0.0.0:8085 | ||
``` | ||
|
||
Run below commands in other terminal | ||
```shell | ||
export GCS_PROJECT=testproject | ||
export TOPIC=testtopic | ||
export SUBSCRIPTION=testsub | ||
|
||
$(gcloud beta emulators pubsub env-init) | ||
|
||
sbt "project examples; runMain PS" | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import gcp4zio.pubsub.publisher.{MessageEncoder, PSPublisher} | ||
import gcp4zio.pubsub.subscriber.PSSubscriber | ||
import gcp4zio.pubsub.subscription.PSSubscription | ||
import gcp4zio.pubsub.topic.PSTopic | ||
import zio._ | ||
import zio.logging.backend.SLF4J | ||
import java.nio.charset.Charset | ||
|
||
@SuppressWarnings(Array("org.wartremover.warts.ToString")) | ||
object PS extends ZIOAppDefault { | ||
|
||
override val bootstrap = Runtime.removeDefaultLoggers >>> SLF4J.slf4j | ||
|
||
lazy val gcsProject: String = sys.env("GCS_PROJECT") | ||
lazy val subscription: String = sys.env("SUBSCRIPTION") | ||
lazy val topic: String = sys.env("TOPIC") | ||
|
||
private val createTopic = PSTopic.createTopic(gcsProject, topic) | ||
|
||
private val deleteTopic = PSTopic.deleteTopic(gcsProject, topic) | ||
|
||
private val createSubscription = PSSubscription.createPullSubscription(gcsProject, subscription, topic) | ||
|
||
private val deleteSubscription = PSSubscription.deleteSubscription(gcsProject, subscription) | ||
|
||
implicit val encoder: MessageEncoder[String] = (a: String) => Right(a.getBytes(Charset.defaultCharset())) | ||
|
||
private val produceMessages = Random.nextInt | ||
.flatMap(ri => PSPublisher.produce(s"Test Message $ri")) | ||
.tap(msgId => ZIO.logInfo(s"Message ID $msgId published")) | ||
.repeat(Schedule.spaced(5.seconds) && Schedule.forever) | ||
|
||
private val consumeMessages = PSSubscriber.subscribe | ||
.mapZIO { msg => | ||
ZIO.logInfo(msg.value.toString) *> msg.ack | ||
} | ||
.take(10) | ||
.runDrain | ||
|
||
private val setup = for { | ||
_ <- createTopic.tap(t => ZIO.logInfo(s"Created Topic ${t.toString}")) | ||
_ <- createSubscription.tap(s => ZIO.logInfo(s"Created Subscription ${s.toString}")) | ||
} yield () | ||
|
||
private val flow = for { | ||
_ <- ZIO.logInfo("Starting Publisher") *> produceMessages.fork | ||
_ <- ZIO.logInfo("Starting Subscriber") *> consumeMessages | ||
} yield () | ||
|
||
private val cleanup = for { | ||
_ <- deleteSubscription.zipLeft(ZIO.logInfo(s"Deleted Subscription")) | ||
_ <- deleteTopic.zipLeft(ZIO.logInfo(s"Deleted Topic")) | ||
} yield () | ||
|
||
override def run: ZIO[Scope, Throwable, Unit] = | ||
(setup *> flow) | ||
.ensuring(cleanup.ignore) | ||
.provideSome[Scope]( | ||
PSTopic.test, | ||
PSSubscription.test, | ||
PSPublisher.test(gcsProject, topic), | ||
PSSubscriber.test(gcsProject, subscription) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.