packages feed

pgmq-core 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+94/−4 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Pgmq.Types: newtype PgmqError
+ Pgmq.Types: InvalidRoutingKey :: Text -> PgmqError
+ Pgmq.Types: InvalidTopicPattern :: Text -> PgmqError
+ Pgmq.Types: NotifyInsertThrottle :: !Text -> !Int32 -> !UTCTime -> NotifyInsertThrottle
+ Pgmq.Types: RoutingMatch :: !TopicPattern -> !Text -> !Text -> RoutingMatch
+ Pgmq.Types: TopicBinding :: !TopicPattern -> !Text -> !UTCTime -> !Text -> TopicBinding
+ Pgmq.Types: TopicSendResult :: !Text -> !MessageId -> TopicSendResult
+ Pgmq.Types: [bindingBoundAt] :: TopicBinding -> !UTCTime
+ Pgmq.Types: [bindingCompiledRegex] :: TopicBinding -> !Text
+ Pgmq.Types: [bindingPattern] :: TopicBinding -> !TopicPattern
+ Pgmq.Types: [bindingQueueName] :: TopicBinding -> !Text
+ Pgmq.Types: [matchCompiledRegex] :: RoutingMatch -> !Text
+ Pgmq.Types: [matchPattern] :: RoutingMatch -> !TopicPattern
+ Pgmq.Types: [matchQueueName] :: RoutingMatch -> !Text
+ Pgmq.Types: [sentMessageId] :: TopicSendResult -> !MessageId
+ Pgmq.Types: [sentToQueue] :: TopicSendResult -> !Text
+ Pgmq.Types: [throttleIntervalMs] :: NotifyInsertThrottle -> !Int32
+ Pgmq.Types: [throttleLastNotifiedAt] :: NotifyInsertThrottle -> !UTCTime
+ Pgmq.Types: [throttleQueueName] :: NotifyInsertThrottle -> !Text
+ Pgmq.Types: data NotifyInsertThrottle
+ Pgmq.Types: data PgmqError
+ Pgmq.Types: data RoutingKey
+ Pgmq.Types: data RoutingMatch
+ Pgmq.Types: data TopicBinding
+ Pgmq.Types: data TopicPattern
+ Pgmq.Types: data TopicSendResult
+ Pgmq.Types: instance Data.Aeson.Types.FromJSON.FromJSON Pgmq.Types.RoutingKey
+ Pgmq.Types: instance Data.Aeson.Types.FromJSON.FromJSON Pgmq.Types.TopicPattern
+ Pgmq.Types: instance Data.Aeson.Types.ToJSON.ToJSON Pgmq.Types.RoutingKey
+ Pgmq.Types: instance Data.Aeson.Types.ToJSON.ToJSON Pgmq.Types.TopicPattern
+ Pgmq.Types: instance GHC.Classes.Eq Pgmq.Types.NotifyInsertThrottle
+ Pgmq.Types: instance GHC.Classes.Eq Pgmq.Types.RoutingKey
+ Pgmq.Types: instance GHC.Classes.Eq Pgmq.Types.RoutingMatch
+ Pgmq.Types: instance GHC.Classes.Eq Pgmq.Types.TopicBinding
+ Pgmq.Types: instance GHC.Classes.Eq Pgmq.Types.TopicPattern
+ Pgmq.Types: instance GHC.Classes.Eq Pgmq.Types.TopicSendResult
+ Pgmq.Types: instance GHC.Classes.Ord Pgmq.Types.RoutingKey
+ Pgmq.Types: instance GHC.Classes.Ord Pgmq.Types.TopicPattern
+ Pgmq.Types: instance GHC.Internal.Generics.Generic Pgmq.Types.NotifyInsertThrottle
+ Pgmq.Types: instance GHC.Internal.Generics.Generic Pgmq.Types.RoutingKey
+ Pgmq.Types: instance GHC.Internal.Generics.Generic Pgmq.Types.RoutingMatch
+ Pgmq.Types: instance GHC.Internal.Generics.Generic Pgmq.Types.TopicBinding
+ Pgmq.Types: instance GHC.Internal.Generics.Generic Pgmq.Types.TopicPattern
+ Pgmq.Types: instance GHC.Internal.Generics.Generic Pgmq.Types.TopicSendResult
+ Pgmq.Types: instance GHC.Internal.Show.Show Pgmq.Types.NotifyInsertThrottle
+ Pgmq.Types: instance GHC.Internal.Show.Show Pgmq.Types.RoutingKey
+ Pgmq.Types: instance GHC.Internal.Show.Show Pgmq.Types.RoutingMatch
+ Pgmq.Types: instance GHC.Internal.Show.Show Pgmq.Types.TopicBinding
+ Pgmq.Types: instance GHC.Internal.Show.Show Pgmq.Types.TopicPattern
+ Pgmq.Types: instance GHC.Internal.Show.Show Pgmq.Types.TopicSendResult
+ Pgmq.Types: parseRoutingKey :: Text -> Either PgmqError RoutingKey
+ Pgmq.Types: parseTopicPattern :: Text -> Either PgmqError TopicPattern
+ Pgmq.Types: routingKeyToText :: RoutingKey -> Text
+ Pgmq.Types: topicPatternToText :: TopicPattern -> Text

Files

CHANGELOG.md view
@@ -1,5 +1,14 @@ # Revision history for pgmq-core +## 0.1.1.0 -- 2026-02-23++### New Features++* Topic routing types (pgmq 1.11.0+): `RoutingKey`, `TopicPattern`, `TopicBinding`, `RoutingMatch`, `TopicSendResult`+* Notification throttle type: `NotifyInsertThrottle`+* Validation functions: `parseRoutingKey`, `routingKeyToText`, `parseTopicPattern`, `topicPatternToText`+* Extended `PgmqError` with `InvalidRoutingKey` and `InvalidTopicPattern` constructors+ ## 0.1.0.0 -- 2026-02-21  * Initial release
pgmq-core.cabal view
@@ -1,6 +1,6 @@ cabal-version:   3.4 name:            pgmq-core-version:         0.1.0.0+version:         0.1.1.0 synopsis:        Core types for pgmq-hs, a Haskell client for PGMQ description:   Core types and type classes for pgmq-hs, a Haskell client library@@ -11,7 +11,7 @@ license:         MIT license-file:    LICENSE author:          Nadeem Bitar-maintainer:      nadeem@topagentnetwork.com+maintainer:      Nadeem Bitar category:        Database build-type:      Simple extra-doc-files: CHANGELOG.md
src/Pgmq/Types.hs view
@@ -10,12 +10,24 @@     parseQueueName,     queueNameToText,     PgmqError (..),++    -- * Topic Routing (pgmq 1.11.0+)+    RoutingKey,+    parseRoutingKey,+    routingKeyToText,+    TopicPattern,+    parseTopicPattern,+    topicPatternToText,+    TopicBinding (..),+    RoutingMatch (..),+    TopicSendResult (..),+    NotifyInsertThrottle (..),   ) where  import Data.Aeson (FromJSON, ToJSON, Value) import Data.Char (isAlphaNum, isAscii)-import Data.Int (Int64)+import Data.Int (Int32, Int64) import Data.Text (Text) import Data.Text qualified as T import Data.Time (UTCTime)@@ -69,7 +81,10 @@ queueNameToText :: QueueName -> Text queueNameToText (QueueName t) = t -newtype PgmqError = InvalidQueueName Text+data PgmqError+  = InvalidQueueName Text+  | InvalidRoutingKey Text+  | InvalidTopicPattern Text   deriving stock (Show, Generic)  -- Adopted from https://github.com/tembo-io/pgmq/blob/e4d4b84bf302df77be2d1f877c5cf8ef8861bfc7/pgmq-rs/src/util.rs#L94@@ -88,3 +103,69 @@     maxIdentifierLength = 63 -- PostgreSQL truncates beyond this length     longestPrefix :: Text = "archived_at_idx_"     maxQueueNameLength = maxIdentifierLength - T.length longestPrefix++-- | A validated routing key for topic-based message routing (pgmq 1.11.0+)+-- Routing keys are dot-separated segments of alphanumeric characters, hyphens,+-- and underscores. Max 255 characters. No wildcards allowed.+newtype RoutingKey = RoutingKey Text+  deriving newtype (Eq, Ord, FromJSON, ToJSON)+  deriving stock (Show, Generic)++parseRoutingKey :: Text -> Either PgmqError RoutingKey+parseRoutingKey t+  | T.null t = Left $ InvalidRoutingKey "Routing key cannot be empty."+  | T.length t > 255 = Left $ InvalidRoutingKey "Routing key exceeds 255 characters."+  | not (T.all isValidChar t) = Left $ InvalidRoutingKey "Routing key contains invalid characters."+  | otherwise = Right $ RoutingKey t+  where+    isValidChar c = (isAscii c && isAlphaNum c) || c == '.' || c == '-' || c == '_'++routingKeyToText :: RoutingKey -> Text+routingKeyToText (RoutingKey t) = t++-- | A topic pattern for binding to queues (pgmq 1.11.0+)+-- Patterns support wildcards: '*' matches one segment, '#' matches zero or more.+newtype TopicPattern = TopicPattern Text+  deriving newtype (Eq, Ord, FromJSON, ToJSON)+  deriving stock (Show, Generic)++parseTopicPattern :: Text -> Either PgmqError TopicPattern+parseTopicPattern t+  | T.null t = Left $ InvalidTopicPattern "Topic pattern cannot be empty."+  | T.length t > 255 = Left $ InvalidTopicPattern "Topic pattern exceeds 255 characters."+  | otherwise = Right $ TopicPattern t++topicPatternToText :: TopicPattern -> Text+topicPatternToText (TopicPattern t) = t++-- | A topic binding record returned by list_topic_bindings (pgmq 1.11.0+)+data TopicBinding = TopicBinding+  { bindingPattern :: !TopicPattern,+    bindingQueueName :: !Text,+    bindingBoundAt :: !UTCTime,+    bindingCompiledRegex :: !Text+  }+  deriving stock (Eq, Generic, Show)++-- | A routing match result from test_routing (pgmq 1.11.0+)+data RoutingMatch = RoutingMatch+  { matchPattern :: !TopicPattern,+    matchQueueName :: !Text,+    matchCompiledRegex :: !Text+  }+  deriving stock (Eq, Generic, Show)++-- | Result row from send_batch_topic (pgmq 1.11.0+)+data TopicSendResult = TopicSendResult+  { sentToQueue :: !Text,+    sentMessageId :: !MessageId+  }+  deriving stock (Eq, Generic, Show)++-- | Notification throttle settings returned by list_notify_insert_throttles (pgmq 1.11.0+)+data NotifyInsertThrottle = NotifyInsertThrottle+  { throttleQueueName :: !Text,+    throttleIntervalMs :: !Int32,+    throttleLastNotifiedAt :: !UTCTime+  }+  deriving stock (Eq, Generic, Show)