packages feed

grapesy-1.2.0: grapesy.cabal

cabal-version:      3.0
name:               grapesy
version:            1.2.0
synopsis:           Native Haskell implementation of the gRPC framework
description:        This is a fully compliant and feature complete native Haskell
                    implementation of gRPC, Google's RPC framework.
license:            BSD-3-Clause
license-file:       LICENSE
author:             Edsko de Vries
maintainer:         edsko@well-typed.com
category:           Network
build-type:         Simple
extra-doc-files:    CHANGELOG.md
data-dir:           data
extra-source-files: data/route_guide_db.json
                  data/grpc-demo.pem
                    data/grpc-demo.key
                    data/interop.pem
                    data/interop.key
                    data/interop-ca.pem
tested-with:        GHC==8.10.7
                  , GHC==9.2.8
                  , GHC==9.4.8
                  , GHC==9.6.7
                  , GHC==9.8.4
                  , GHC==9.10.3
                  , GHC==9.12.4
                  , GHC==9.14.1

source-repository head
  type:     git
  location: https://github.com/well-typed/grapesy

common lang
  ghc-options:
      -Wall
      -Wredundant-constraints
      -Wno-unticked-promoted-constructors
      -Wprepositive-qualified-module
      -Widentities
      -Wmissing-export-lists
  build-depends:
      base >= 4.14 && < 4.23
  default-language:
      Haskell2010
  default-extensions:
      BangPatterns
      ConstraintKinds
      DataKinds
      DefaultSignatures
      DeriveAnyClass
      DeriveFunctor
      DeriveGeneric
      DeriveTraversable
      DerivingStrategies
      DerivingVia
      DisambiguateRecordFields
      EmptyCase
      FlexibleContexts
      FlexibleInstances
      GADTs
      GeneralizedNewtypeDeriving
      ImportQualifiedPost
      InstanceSigs
      LambdaCase
      MultiParamTypeClasses
      MultiWayIf
      NamedFieldPuns
      NumericUnderscores
      PatternSynonyms
      PolyKinds
      RankNTypes
      ScopedTypeVariables
      StandaloneDeriving
      TupleSections
      TypeApplications
      TypeFamilies
      TypeOperators
      UndecidableInstances

  if impl(ghc >= 9.0)
    ghc-options:
      -- This was introduced in 8.10, but it does not work reliably until 9.0.
      -- In 8.10 you might get spurious warnings when using re-exported modules
      -- (e.g. in proto-lens-runtime).
      -Wunused-packages

common common-executable-flags
  ghc-options:
      -threaded
      -rtsopts

library
  import:          lang
  hs-source-dirs:  src

  exposed-modules:
      Network.GRPC.Client
      Network.GRPC.Client.Binary
      Network.GRPC.Client.StreamType.CanCallRPC
      Network.GRPC.Client.StreamType.Conduit
      Network.GRPC.Client.StreamType.IO
      Network.GRPC.Client.StreamType.IO.Binary
      Network.GRPC.Common
      Network.GRPC.Common.Binary
      Network.GRPC.Common.Compression
      Network.GRPC.Common.Exception
      Network.GRPC.Common.Headers
      Network.GRPC.Common.HTTP2Settings
      Network.GRPC.Common.JSON
      Network.GRPC.Common.NextElem
      Network.GRPC.Common.Protobuf
      Network.GRPC.Common.Protobuf.Any
      Network.GRPC.Common.StreamElem
      Network.GRPC.Common.StreamType
      Network.GRPC.Server
      Network.GRPC.Server.Binary
      Network.GRPC.Server.Protobuf
      Network.GRPC.Server.Run
      Network.GRPC.Server.StreamType
      Network.GRPC.Server.StreamType.Binary
  other-modules:
      Network.GRPC.Client.Call
      Network.GRPC.Client.Connection
      Network.GRPC.Client.Meta
      Network.GRPC.Client.Run
      Network.GRPC.Client.Session
      Network.GRPC.Client.StreamType
      Network.GRPC.Common.ProtocolException
      Network.GRPC.Server.Call
      Network.GRPC.Server.Context
      Network.GRPC.Server.Handler
      Network.GRPC.Server.HandlerMap
      Network.GRPC.Server.RequestHandler
      Network.GRPC.Server.RequestHandler.API
      Network.GRPC.Server.Session
      Network.GRPC.Util.AccumulatedByteString
      Network.GRPC.Util.ClientStream
      Network.GRPC.Util.GHC
      Network.GRPC.Util.HeaderTable
      Network.GRPC.Util.HTTP2
      Network.GRPC.Util.Imports
      Network.GRPC.Util.RedundantConstraint
      Network.GRPC.Util.ServerStream
      Network.GRPC.Util.Session.API
      Network.GRPC.Util.Session.Channel
      Network.GRPC.Util.Session.Client
      Network.GRPC.Util.Session.Server
      Network.GRPC.Util.Stream
      Network.GRPC.Util.Thread
      Network.GRPC.Util.TimeManager
      Network.GRPC.Util.TLS
      Network.GRPC.Util.Version

      -- Exception utilities
      --
      -- Perhaps this could become its own little library?
      Network.GRPC.Util.Exception.Doc
      Network.GRPC.Util.Exception.Exact
      Network.GRPC.Util.Exception.FormatCtx
      Network.GRPC.Util.Exception.Shims
      Network.GRPC.Util.Exception.ToExceptionDoc

  build-depends:
    , aeson                >= 1.5     && < 2.4
    , async                >= 2.2     && < 2.3
    , binary               >= 0.8     && < 0.9
    , bytestring           >= 0.10.12 && < 0.13
    , conduit              >= 1.3     && < 1.4
    , containers           >= 0.6     && < 0.9
    , crypton-x509         >= 1.7     && < 1.10
    , crypton-x509-store   >= 1.6     && < 1.10
    , crypton-x509-system  >= 1.6     && < 1.10
    , data-default         >= 0.7     && < 0.9
    , deepseq              >= 1.4     && < 1.6
    , grpc-spec            >= 1.1     && < 1.2
    , http-types           >= 0.12    && < 0.13
    , lens                 >= 5.0     && < 5.4
    , mtl                  >= 2.2     && < 2.4
    , network              >= 3.2.4   && < 3.3
    , proto-lens           >= 0.7     && < 0.8
    , random               >= 1.2     && < 1.4
    , recv                 >= 0.1     && < 0.2
    , stm                  >= 2.5     && < 2.6
    , text                 >= 1.2     && < 2.2
    , time-manager         >= 0.3.2   && < 0.4
    , tls                  >= 1.7     && < 2.5
    , unbounded-delays     >= 0.1.1   && < 0.2
    , unordered-containers >= 0.2     && < 0.3
    , utf8-string          >= 1.0     && < 1.1

      -- NOTE: If you want good backtraces, you'll want exceptions >= 0.10.12
    , exceptions >= 0.10 && < 0.11

      -- NOTE: If you want to avoid bringing in unnecessary IsLabel instances,
      -- you'll want proto-lens-protobuf-types >= 0.7.2.3.
      -- See also <https://github.com/well-typed/grapesy/pull/283>.
    , proto-lens-protobuf-types >= 0.7 && < 0.8

  -- The following set of packages are all tightly coupled, and should be
  -- bumped all at once. Moreover, we pin a very specific version of http2;
  -- any new version should be tested against the full grapesy test suite
  -- (regular tests, stress tests and interop tests).
  build-depends:
    , http2          == 5.4.4
    , http-semantics >= 0.4 && < 0.5
    , http2-tls      >= 0.5 && < 0.6
    , network-run    >= 0.5 && < 0.6

  if(flag(patched-ghc-for-exception-debugging))
    cpp-options: -DPATCHED_GHC_FOR_EXCEPTION_DEBUGGING

test-suite test-record-dot
  import:         lang, common-executable-flags
  type:           exitcode-stdio-1.0
  hs-source-dirs: test-record-dot, proto
  main-is:        Main.hs
  build-depends:  grapesy

  other-modules:
      Test.OverloadedRecordDot
      Test.OverloadedRecordUpdate
      Proto.Spec

  build-depends:
      -- Inherited dependencies
    , bytestring
    , containers
    , text

  build-depends:
      -- Additional dependencies
    , proto-lens-runtime >= 0.7  && < 0.8
    , tasty              >= 1.4  && < 1.6
    , tasty-hunit        >= 0.10 && < 0.11
    , vector             >= 0.13 && < 0.14
    , record-hasfield    >= 1.0  && < 1.1

  if impl(ghc < 9.2)
    buildable: False

test-suite test-grapesy
  import:          lang, common-executable-flags
  type:            exitcode-stdio-1.0
  hs-source-dirs:  test-grapesy, proto, paths
  main-is:         Main.hs
  build-depends:   grapesy
  ghc-options:     -with-rtsopts=-N

  other-modules:
      Test.Common.Exception
      Test.Driver.ClientServer
      Test.Driver.Dialogue
      Test.Driver.Dialogue.Definition
      Test.Driver.Dialogue.Execution
      Test.Driver.Dialogue.Generation
      Test.Driver.Dialogue.TestClock
      Test.Prop.Dialogue
      Test.Regression.Issue102
      Test.Regression.Issue238
      Test.Sanity.Any
      Test.Sanity.BrokenDeployments
      Test.Sanity.Cancellation
      Test.Sanity.Compression
      Test.Sanity.EndOfStream
      Test.Sanity.Interop
      Test.Sanity.Metadata
      Test.Sanity.NoIsLabel
      Test.Sanity.Reclamation
      Test.Sanity.StreamingType.CustomFormat
      Test.Sanity.StreamingType.NonStreaming
      Test.Util
      Test.Util.Exception
      Test.Util.RawTestServer

      Paths_

      Proto.API.Helloworld
      Proto.API.Interop
      Proto.API.Ping
      Proto.API.RouteGuide
      Proto.API.TestAny
      Proto.API.Trivial
      Proto.Empty
      Proto.Helloworld
      Proto.Messages
      Proto.Ping
      Proto.RouteGuide
      Proto.Test
      Proto.TestAny

  build-depends:
      -- Inherited dependencies
    , async
    , binary
    , bytestring
    , containers
    , deepseq
    , exceptions
    , grpc-spec
    , http-types
    , http2
    , mtl
    , network
    , proto-lens
    , proto-lens-protobuf-types
    , stm
    , text
    , time-manager
    , tls
    , utf8-string

  build-depends:
      -- Additional dependencies
    , filepath           >= 1.4.2.1 && < 1.6
    , proto-lens-runtime >= 0.7     && < 0.8
    , QuickCheck         >= 2.14    && < 2.19
    , serialise          >= 0.2     && < 0.3
    , tasty              >= 1.4     && < 1.6
    , tasty-hunit        >= 0.10    && < 0.11
    , tasty-quickcheck   >= 0.10    && < 0.12
    , temporary          >= 1.3     && < 1.4
    , tree-diff          >= 0.4.1   && < 0.5

  if(flag(test-no-islabel))
    build-depends: proto-lens-protobuf-types >= 0.7.2.3
    cpp-options:   -DTEST_NO_ISLABEL

test-suite test-disconnect
  import:         lang, common-executable-flags
  type:           exitcode-stdio-1.0
  hs-source-dirs: test-disconnect, proto
  main-is:        Main.hs
  build-depends:  grapesy

  -- 'forkProcess' does not like multiple capabilities
  ghc-options: -with-rtsopts=-N1

  other-modules:
      Test.Disconnect.Echo.Client
      Test.Disconnect.Echo.RPC
      Test.Disconnect.Echo.Server
      Test.Disconnect.Util.Client
      Test.Disconnect.Util.Exception
      Test.Disconnect.Util.Process
      Test.Disconnect.Util.Server

      Proto.API.Trivial

  build-depends:
      -- Inherited dependencies
    , http2
    , network
    , stm

  build-depends:
      -- Additional dependencies
    , HUnit     >= 1.6 && < 1.7
    , temporary >= 1.3 && < 1.4
    , unix      >= 2.7 && < 2.9

test-suite test-stress
  import:             lang, common-executable-flags
  type:               exitcode-stdio-1.0
  hs-source-dirs:     test-stress, proto, paths
  main-is:            Main.hs
  build-depends:      grapesy
  default-extensions: RecordWildCards

  other-modules:
      Test.Stress.Client
      Test.Stress.Cmdline
      Test.Stress.Common
      Test.Stress.Driver
      Test.Stress.Driver.Summary
      Test.Stress.Server

      Proto.API.Trivial

      Paths_

  build-depends:
      -- Inherited dependencies
    , async
    , bytestring
    , exceptions
    , http2
    , network
    , text
    , tls

  build-depends:
      -- Additional dependencies
    , Chart                >= 1.9     && < 1.10
    , Chart-diagrams       >= 1.9     && < 1.10
    , directory            >= 1.3     && < 1.4
    , filepath             >= 1.4.2.1 && < 1.6
    , ghc-events           >= 0.17    && < 0.22
    , optparse-applicative >= 0.16    && < 0.20
    , pretty-show          >= 1.10    && < 1.11
    , process              >= 1.6.12  && < 1.7
    , random               >= 1.2     && < 1.4
    , temporary            >= 1.3     && < 1.4

  if !flag(build-stress-test)
    buildable:
      False

test-suite grapesy-interop
  import:             lang, common-executable-flags
  type:               exitcode-stdio-1.0
  hs-source-dirs:     interop, proto, paths
  main-is:            Main.hs
  build-depends:      grapesy
  default-extensions: OverloadedLabels

  other-modules:
      Interop.Client
      Interop.Client.Common
      Interop.Client.Connect
      Interop.Client.Ping
      Interop.Client.TestCase.CancelAfterBegin
      Interop.Client.TestCase.CancelAfterFirstResponse
      Interop.Client.TestCase.ClientCompressedStreaming
      Interop.Client.TestCase.ClientCompressedUnary
      Interop.Client.TestCase.ClientStreaming
      Interop.Client.TestCase.CustomMetadata
      Interop.Client.TestCase.EmptyStream
      Interop.Client.TestCase.EmptyUnary
      Interop.Client.TestCase.LargeUnary
      Interop.Client.TestCase.PingPong
      Interop.Client.TestCase.ServerCompressedStreaming
      Interop.Client.TestCase.ServerCompressedUnary
      Interop.Client.TestCase.ServerStreaming
      Interop.Client.TestCase.SpecialStatusMessage
      Interop.Client.TestCase.StatusCodeAndMessage
      Interop.Client.TestCase.TimeoutOnSleepingServer
      Interop.Client.TestCase.UnimplementedMethod
      Interop.Client.TestCase.UnimplementedService
      Interop.Cmdline
      Interop.SelfTest
      Interop.Server
      Interop.Server.Common
      Interop.Server.PingService.Ping
      Interop.Server.TestService.EmptyCall
      Interop.Server.TestService.FullDuplexCall
      Interop.Server.TestService.StreamingInputCall
      Interop.Server.TestService.StreamingOutputCall
      Interop.Server.TestService.UnaryCall
      Interop.Util.ANSI
      Interop.Util.Exceptions
      Interop.Util.Messages
      Interop.Util.NonInterleaved

      Paths_

      Proto.API.Interop
      Proto.API.Ping
      Proto.Empty
      Proto.Messages
      Proto.Ping
      Proto.Test

  build-depends:
      -- Inherited dependencies
    , bytestring
    , exceptions
    , grpc-spec
    , mtl
    , network
    , proto-lens
    , text
    , filepath

  build-depends:
      -- Additional dependencies
    , ansi-terminal        >= 1.1  && < 1.2
    , optparse-applicative >= 0.16 && < 0.20
    , proto-lens-runtime   >= 0.7  && < 0.8

benchmark grapesy-kvstore
  import:             lang, common-executable-flags
  type:               exitcode-stdio-1.0
  main-is:            Main.hs
  hs-source-dirs:     kvstore, proto, paths
  build-depends:      grapesy
  default-extensions: OverloadedLabels

  other-modules:
      KVStore.API
      KVStore.API.JSON
      KVStore.API.Protobuf
      KVStore.Client
      KVStore.Cmdline
      KVStore.Server
      KVStore.Util.Profiling
      KVStore.Util.RandomAccessSet
      KVStore.Util.RandomGen
      KVStore.Util.Store

      Proto.Kvstore

      Paths_

  build-depends:
      -- Inherited dependencies
    , aeson
    , bytestring
    , containers
    , deepseq
    , proto-lens
    , text
    , unordered-containers
    , filepath

  build-depends:
      -- Additional dependencies
    , base16-bytestring    >= 1.0  && < 1.1
    , base64-bytestring    >= 1.2  && < 1.3
    , hashable             >= 1.3  && < 1.6
    , optparse-applicative >= 0.16 && < 0.20
    , proto-lens-runtime   >= 0.7  && < 0.8
    , splitmix             >= 0.1  && < 0.2

  if flag(strace)
    cpp-options: -DSTRACE
    build-depends: unix >= 2.7 && < 2.9

Flag build-stress-test
  description: Build the stress test
  default: False
  manual: True

Flag strace
  description: Write events to /dev/null in @grapesy-kvstore@ so that they show up in strace
  default: False
  manual: True

Flag test-no-islabel
  description: Enable the test that checks that no IsLabel instances are in scope
  default: True
  manual: False

Flag patched-ghc-for-exception-debugging
  description: Use custom patched GHC with some exception improvements (probably useful for grapesy devs only)
  default: False
  manual: True