hw-kafka-avro 4.0.0 → 4.0.1
raw patch · 2 files changed
+10/−32 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- hw-kafka-avro.cabal +6/−18
- src/Kafka/Avro/SchemaRegistry.hs +4/−14
hw-kafka-avro.cabal view
@@ -1,13 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.28.2.------ see: https://github.com/sol/hpack------ hash: 30f52e81862851b4a683aac241a304455f46ec73f8d755304cd003bc7a6fb41b+cabal-version: 1.12 name: hw-kafka-avro-version: 4.0.0+version: 4.0.1 synopsis: Avro support for Kafka infrastructure-description: Please see README.md+description: Avro support for Kafka infrastructure. category: Services homepage: https://github.com/haskell-works/hw-kafka-avro#readme bug-reports: https://github.com/haskell-works/hw-kafka-avro/issues@@ -17,7 +13,6 @@ license: BSD3 license-file: LICENSE build-type: Simple-cabal-version: >= 1.10 extra-source-files: README.md @@ -36,10 +31,7 @@ Kafka.Avro.Decode Kafka.Avro.Encode Kafka.Avro.SchemaRegistry- other-modules:- Paths_hw_kafka_avro- hs-source-dirs:- src+ hs-source-dirs: src build-depends: aeson , avro >=0.4@@ -67,9 +59,7 @@ main-is: Main.hs other-modules: Message- Paths_hw_kafka_avro- hs-source-dirs:- example+ hs-source-dirs: example ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: aeson@@ -97,9 +87,7 @@ type: exitcode-stdio-1.0 main-is: Spec.hs other-modules:- Paths_hw_kafka_avro- hs-source-dirs:- test+ hs-source-dirs: test ghc-options: -threaded -rtsopts -with-rtsopts=-N build-depends: QuickCheck
src/Kafka/Avro/SchemaRegistry.hs view
@@ -35,12 +35,9 @@ import qualified Data.Text.Encoding as Text import qualified Data.Text.Lazy.Encoding as LText import Data.Word (Word32)-import GHC.Exception (SomeException, displayException,- fromException)+import GHC.Exception (SomeException, displayException, fromException) import GHC.Generics (Generic)-import Network.HTTP.Client (HttpException (..),- HttpExceptionContent (..), Manager,- defaultManagerSettings, newManager)+import Network.HTTP.Client (HttpException (..), HttpExceptionContent (..), Manager, defaultManagerSettings, newManager) import qualified Network.Wreq as Wreq newtype SchemaId = SchemaId { unSchemaId :: Int32} deriving (Eq, Ord, Show, Hashable)@@ -84,7 +81,7 @@ Just s -> return (Right s) Nothing -> liftIO $ do res <- getSchemaById (srBaseUrl sr) sid- pure (unRegisteredSchema <$> res)+ traverse ((\schema -> schema <$ cacheSchema sr sid schema) . unRegisteredSchema) res loadSubjectSchema :: MonadIO m => SchemaRegistry -> Subject -> Version -> m (Either SchemaRegistryError Schema) loadSubjectSchema sr (Subject sbj) (Version version) = do@@ -96,7 +93,7 @@ schemaId <- getData "id" wrapped case (,) <$> schema <*> schemaId of- Left err -> return $ Left err+ Left err -> return $ Left err Right ((RegisteredSchema schema), schemaId) -> cacheSchema sr schemaId schema *> (return $ Right schema) where getData :: (MonadIO m, FromJSON a) => String -> Either e Value -> m (Either e a)@@ -179,13 +176,6 @@ let schemaUrl = baseUrl ++ "/schemas/ids/" ++ show i resp <- Wreq.getWith wreqOpts schemaUrl pure $ bimap (const (SchemaRegistryLoadError sid)) (view Wreq.responseBody) (Wreq.asJSON resp)- where- wrapError :: SomeException -> SchemaRegistryError- wrapError someErr = case fromException someErr of- Nothing -> SchemaRegistryLoadError sid- Just httpErr -> fromHttpError httpErr $ \case- StatusCodeException r _ | r ^. Wreq.responseStatus . Wreq.statusCode == 404 -> SchemaRegistrySchemaNotFound sid- _ -> SchemaRegistryLoadError sid putSchema :: String -> Subject -> RegisteredSchema -> IO (Either SchemaRegistryError SchemaId) putSchema baseUrl (Subject sbj) schema = do