BroadwayCloudPubSub
A Google Cloud Pub/Sub connector for Broadway.
Documentation can be found at https://hexdocs.pm/broadway_cloud_pub_sub.
This project provides:
BroadwayCloudPubSub.Producer
- A GenStage producer that continuously receives messages from a Pub/Sub subscription acknowledges them after being successfully processed.BroadwayCloudPubSub.RestClient
- A generic behaviour to implement Pub/Sub clients using the REST API.BroadwayCloudPubSub.GoogleApiClient
- Default REST client used byBroadwayCloudPubSub.Producer
.BroadwayCloudPubSub.Token
- A generic behaviour to implement token authentication for Pub/Sub clients.BroadwayCloudPubSub.GothToken
- Default token provider used byBroadwayCloudPubSub.Producer
.
Installation
Add :broadway_cloud_pub_sub
to the list of dependencies in mix.exs
, along with the authentication
library of your choice (defaults to :goth
):
def deps do
[
{:broadway_cloud_pub_sub, "~> 0.1.0"},
{:goth, "~> 0.11"}
]
end
By default, :goth
will include :hackney
as its HTTP client. If you choose to use an alternative
authentication library, you may need to explicitly include an HTTP client (such as :hackney
):
def deps do
[
{:broadway_cloud_pub_sub, "~> 0.1.0"},
{:hackney, "~> 1.9"}
]
end
Usage
Configure Broadway with one or more producers using BroadwayCloudPubSub.Producer
:
Broadway.start_link(
MyBroadway,
name: MyBroadway,
producers: [
default: [
module:
{BroadwayCloudPubSub.Producer,
subscription: "projects/my-project/subscriptions/my-subscription"}
]
]
)
For more information, please see the docs for Broadway.
There is also an example app available at: https://github.com/mcrumm/broadway_cloud_pub_sub_example