google-cloud-pubsub: GCP Pub/Sub Client for Haskell

[ library, mit, web ] [ Propose Tags ] [ Report a vulnerability ]

GCP Pub/Sub topic and subscription client for Haskell.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.1.0.0
Change log CHANGELOG.md
Dependencies aeson (<3), base (>=4.7 && <5), base64-bytestring, bytestring (>=0.9.1.4), containers, google-cloud-common (>=1.1.0.0 && <1.2.0.0), http-conduit, http-types, text (>=1.2 && <3) [details]
License MIT
Copyright 2025 tushar
Author tushar
Maintainer tusharadhatrao@gmail.com
Category Web
Home page https://github.com/tusharad/google-cloud-haskell#readme
Bug tracker https://github.com/tusharad/google-cloud-haskell/issues
Source repo head: git clone https://github.com/tusharad/google-cloud-haskell
Uploaded by tusharad at 2025-09-11T14:25:45Z
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for google-cloud-pubsub-1.1.0.0

[back to package description]

google-cloud-pubsub

A thin wrapper around Google Cloud Pub/Sub for Haskell.

Features

Topic Operations

  • Create topics
  • Delete topics
  • Publish messages to topics

Subscription Operations

  • Create subscriptions
  • Delete subscriptions
  • Acknowledge messages
  • Modify acknowledgment deadlines
  • Pull messages from subscriptions

Installation

  • Cabal: add to your .cabal
    • build-depends: google-cloud-pubsub == 1.1.0.0
  • Stack: add to your package.yaml
    • dependencies: - google-cloud-pubsub == 1.1.0.0

This package depends on google-cloud-common for authentication and HTTP helpers.

Usage

Topic Operations

import Google.Cloud.PubSub.Topic

-- Create a topic
result <- createTopic "my-project" "my-topic"
case result of
  Left err -> putStrLn $ "Error: " ++ err
  Right topic -> print topic

-- Publish a message
let message = Message "Hello World" Nothing Nothing
publishResult <- publishMessage "my-project" "my-topic" [message]
case publishResult of
  Left err -> putStrLn $ "Error: " ++ err
  Right response -> print $ messageIds response

-- Delete a topic
deleteResult <- deleteTopic "my-project" "my-topic"
case deleteResult of
  Left err -> putStrLn $ "Error: " ++ err
  Right _ -> putStrLn "Topic deleted successfully"

Subscription Operations

import Google.Cloud.PubSub.Subscription

-- Create a subscription
let config = SubscriptionConfig 
  { topic = "projects/my-project/topics/my-topic"
  , pushConfig = Nothing
  , ackDeadlineSeconds = 600
  , retainAckedMessages = False
  , messageRetentionDuration = Nothing
  , labels = Nothing
  , enableMessageOrdering = False
  , expirationPolicy = Nothing
  , filter = Nothing
  , deadLetterPolicy = Nothing
  , retryPolicy = Nothing
  , enableExactlyOnceDelivery = Nothing
  }

createResult <- createSubscription "my-project" "my-subscription" config
case createResult of
  Left err -> putStrLn $ "Error: " ++ err
  Right subscription -> print subscription

-- Pull messages
pullResult <- pullMessages "my-project" "my-subscription" 10
case pullResult of
  Left err -> putStrLn $ "Error: " ++ err
  Right response -> do
    mapM_ print $ receivedMessages response
    -- Acknowledge messages
    let ackIds = map ackId $ receivedMessages response
    ackResult <- acknowledgeMessages "my-project" "my-subscription" ackIds
    case ackResult of
      Left err -> putStrLn $ "Ack error: " ++ err
      Right _ -> putStrLn "Messages acknowledged"

-- Delete a subscription
deleteResult <- deleteSubscription "my-project" "my-subscription"
case deleteResult of
  Left err -> putStrLn $ "Error: " ++ err
  Right _ -> putStrLn "Subscription deleted successfully"

Authentication

Authentication is handled by google-cloud-common and follows this order:

  1. If GOOGLE_APPLICATION_CREDENTIALS is set, a Service Account JSON is used to create a signed JWT which is exchanged for an access token.
  2. Otherwise, the Compute metadata server is used (suitable for GCE/GKE).

Dependencies

  • google-cloud-common - Common functionality for Google Cloud libraries

License

MIT © Contributors