├── .ghci ├── .github ├── dependabot.yml └── workflows │ └── ci.yml ├── .gitignore ├── CHANGELOG ├── LICENSE ├── Makefile ├── README.md ├── README.template.md ├── cabal.project ├── examples ├── readme │ └── Main.hs ├── req │ └── Main.hs └── wai │ └── Main.hs ├── gen └── Proto │ ├── Collector.hs │ ├── Collector_Fields.hs │ └── Google │ ├── Api │ ├── Annotations.hs │ ├── Annotations_Fields.hs │ ├── Http.hs │ └── Http_Fields.hs │ └── Protobuf │ ├── Timestamp.hs │ └── Timestamp_Fields.hs ├── lightstep-haskell.cabal ├── propagation-test ├── go.mod ├── okhttp_client.sc ├── propagation_client.go ├── python_client.py └── python_server.py ├── proto ├── collector.proto └── google │ ├── api │ ├── annotations.proto │ └── http.proto │ └── protobuf │ └── timestamp.proto ├── src ├── LightStep │ ├── Config.hs │ ├── Diagnostics.hs │ ├── HighLevel │ │ └── IO.hs │ ├── Internal │ │ └── Debug.hs │ ├── LowLevel.hs │ └── Propagation.hs └── Network │ └── Wai │ └── Middleware │ └── LightStep.hs ├── stress-test └── Main.hs └── unit-test ├── Main.hs └── TestPropagation.hs /.ghci: -------------------------------------------------------------------------------- 1 | :set prompt "> " -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | assignees: 8 | - "ethercrow" 9 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: 3 | push: 4 | branches: 5 | - master 6 | pull_request: {} 7 | 8 | jobs: 9 | linux-cabal: 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | ghc: ['8.10', '9.0', '9.2'] 14 | fail-fast: false 15 | steps: 16 | - uses: actions/checkout@v3 17 | - uses: actions/cache@v2.1.7 18 | name: Cache ~/.cabal/packages 19 | with: 20 | path: ~/.cabal/packages 21 | key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-packages 22 | - uses: actions/cache@v2.1.7 23 | name: Cache ~/.cabal/store 24 | with: 25 | path: ~/.cabal/store 26 | key: ${{ runner.os }}-${{ matrix.ghc }}-cabal-store 27 | # - uses: actions/cache@v2.1.7 28 | # name: Cache dist-newstyle 29 | # with: 30 | # path: dist-newstyle 31 | # key: ${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle 32 | - uses: haskell/actions/setup@v1.2.9 33 | with: 34 | ghc-version: ${{ matrix.ghc }} 35 | cabal-version: '3.4' 36 | - name: Install protobuf compiler 37 | run: | 38 | sudo apt-get update 39 | sudo apt-get install -y protobuf-compiler 40 | - name: Update package database 41 | run: | 42 | cabal v2-update 43 | - name: Build 44 | run: | 45 | cabal v2-build -f examples 46 | - name: Test 47 | run: | 48 | cabal install tasty-discover 49 | env PATH="$HOME/.cabal/bin:$PATH" cabal test 50 | cabal v2-test 51 | 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .stack-work 2 | *.yaml.lock 3 | /bash_completion.sh 4 | cabal.project.* 5 | dist-newstyle 6 | go.sum 7 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 0.10.4 2 | * Tolerate Lightstep being down 3 | 4 | 0.10.3 5 | * Track heap allocations per span 6 | 7 | 0.10.2 8 | * Change reporter_id from 2 to a random number 9 | 10 | 0.10.1 11 | * Fix withSpanAndTags losing tags when it was not a root span 12 | 13 | 0.10.0 14 | * Rename withSpanAndSomeInitialTags to withSpanAndTags by popular demand 15 | 16 | 0.9.0 17 | * Introduce withTags and withSpanAndSomeInitialTags for more efficient tagging 18 | 19 | 0.8.0 20 | * Configurable compression 21 | 22 | 0.7.0 23 | * New diagnostic counter: number of sent batches 24 | * Configurable minimum size of a batch to send to the collector, default is 1 span 25 | 26 | 0.6.1 27 | * Removed a forgotten debug print statement 28 | 29 | 0.6.0 30 | * Fixed context propagation, changed API a bit, please consult example-req for usage. 31 | 32 | 0.5.2: 33 | * Make `modifyCurrentSpan` and `currentSpanContext` functions safe to call not within a span 34 | 35 | 0.5.1: 36 | * Trace and span ids are now random instead of timestamps 37 | 38 | 0.5.0: 39 | * Introduce getEnvConfig 40 | * [Highlevel.IO] Auto-tag root spans with a thread id 41 | * Introduce LightStep.Diagnostics module that exposes some internal metrics that may be of interest when debugging or optimizing this library 42 | 43 | 0.4.5: 44 | * [Highlevel.IO] Fix a memory leak of several bytes per instrumented thread 45 | 46 | 0.4.4: 47 | * Always include x-b3-sampled=true in B3 context propagation headers 48 | 49 | 0.4.3: 50 | * Support B3 context propagation headers (only 64bit trace id) 51 | 52 | 0.4.2: 53 | * Make example executables not buildable by default. Use `cabal v2-build -f examples` or `stack build --flag lightstep-haskell:examples` to opt in 54 | 55 | 0.4.1: 56 | * Add `lightstep.tracer_version` to global tags 57 | 58 | 0.4.0: 59 | * Support GHC-8.8 60 | 61 | 0.3.0: 62 | * Introduce Network.Wai.Middleware.LightStep 63 | * Implement SpanContext (de)serialization into `ot-tracer-{trace,span}id` headers 64 | * Move examples under examples/ directory now that there is more than one 65 | 66 | 0.2.0: 67 | * Automatic reconnects 68 | 69 | 0.1.7: 70 | * Introduce timeouts to individual grpc requests 71 | 72 | 0.1.6: 73 | * Internal refactoring 74 | 75 | 0.1.5: 76 | * [Highlevel.IO] Fixed a deadlock in reporting when the backend is unavailable 77 | 78 | 0.1.4: 79 | * [Highlevel.IO] Fixed a deadlock in shutdown sequence 80 | 81 | 0.1.3: 82 | * [Highlevel.IO] withSpan now works in transformer stacks instead of only IO 83 | 84 | 0.1.2: 85 | * [Highlevel.IO] Automatically set error=true tag if exception is thrown from within withSpan 86 | 87 | 0.1.1: 88 | * Graceful shutdown 89 | 90 | 0.1.0: 91 | * Initial public release 92 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019-present Dmitry Ivanov 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 4 | 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | README.md: README.template.md examples/readme/Main.hs 3 | # robust webscale enterprise ready templating system 4 | cat README.template.md > README.md 5 | echo '```haskell' >> README.md 6 | cat examples/readme/Main.hs >> README.md 7 | echo '```' >> README.md 8 | 9 | .PHONY: proto 10 | proto: 11 | which proto-lens-protoc || stack install proto-lens-protoc 12 | mkdir -p gen 13 | protoc "--plugin=protoc-gen-haskell-protolens=$$(which proto-lens-protoc)" \ 14 | --haskell-protolens_out=./gen \ 15 | -I proto \ 16 | collector.proto \ 17 | google/api/annotations.proto \ 18 | google/api/http.proto \ 19 | google/protobuf/timestamp.proto 20 | 21 | .PHONY: cabal-build 22 | cabal-build: 23 | cabal v2-build 24 | 25 | .PHONY: stack-build 26 | stack-build: 27 | stack build 28 | 29 | .PHONY: weeder 30 | weeder: 31 | weeder . --build 32 | 33 | .PHONY: format 34 | format: 35 | find src -name '*.hs' -exec echo "Formatting '{}'" \; -exec ormolu --mode=inplace --ghc-opt -XBangPatterns '{}' \; 36 | find cli -name '*.hs' -exec echo "Formatting '{}'" \; -exec ormolu --mode=inplace --ghc-opt -XBangPatterns '{}' \; 37 | 38 | .PHONY: watch 39 | watch: 40 | ghcid 41 | 42 | .PHONY: release 43 | release: stack-build README.md 44 | stack sdist 45 | stack upload . 46 | 47 | .PHONY: vim 48 | vim: 49 | echo ":e lightstep-haskell.cabal\n:vsplit\n:e examples/readme/Main.hs\n:vsplit\n:term" | nvim -s - 50 | 51 | deps.png: lightstep-haskell.cabal stack.yaml 52 | stack dot lightstep-haskell \ 53 | --external \ 54 | --no-include-base \ 55 | --prune base,lens,array,bytestring,containers,deepseq,directory,filepath,mtl,parsec,pretty,process,stm,template-haskell,text,time,transformers,unix \ 56 | | dot -Tpng -o $@ 57 | 58 | deps-tree.txt: lightstep-haskell.cabal stack.yaml 59 | stack ls dependencies tree lightstep-haskell \ 60 | --no-include-base \ 61 | --prune base,lens,array,bytestring,containers,deepseq,directory,filepath,ghc-prim,mtl,parsec,pretty,process,rts,stm,template-haskell,text,time,transformers,unix,http2,http2-grpc-proto-lens,http2-grpc-types,http2-client-grpc,http2-client,proto-lens-runtime,proto-lens-setup,proto-lens,proto-lens-protobuf-types \ 62 | | tee $@ 63 | 64 | .PHONY: stress 65 | stress: stack-build 66 | env GHCRTS="-T -s" stack exec lightstep-haskell-stress-test 67 | 68 | .PHONY: alligator-stress 69 | alligator-stress: stack-build 70 | env GHCRTS="-T -s --nonmoving-gc" stack exec lightstep-haskell-stress-test 71 | 72 | .PHONY: profiled-stress 73 | profiled-stress: 74 | stack install --profile 75 | env GHCRTS="-T -s -P" lightstep-haskell-stress-test 76 | stackcollapse-ghc lightstep-haskell-stress-test.prof | flamegraph.pl > p.svg 77 | stackcollapse-ghc lightstep-haskell-stress-test.prof | flamegraph.pl --reverse > pr.svg 78 | stackcollapse-ghc --alloc lightstep-haskell-stress-test.prof | flamegraph.pl > a.svg 79 | stackcollapse-ghc --alloc lightstep-haskell-stress-test.prof | flamegraph.pl --reverse > ar.svg 80 | 81 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![CI Status](https://github.com/ethercrow/lightstep-haskell/workflows/ci/badge.svg)](https://github.com/ethercrow/lightstep-haskell/actions) 3 | ![Hackage](https://img.shields.io/hackage/v/lightstep-haskell) 4 | [![lightstep-haskell on Stackage Nightly](http://stackage.org/package/lightstep-haskell/badge/nightly)](http://stackage.org/nightly/package/lightstep-haskell) 5 | 6 | # What is it? 7 | 8 | A library for instrumenting your code and sending traces to [LightStep](https://lightstep.com/). 9 | 10 | 11 | # How to use it? 12 | 13 | Example usage: 14 | 15 | ```haskell 16 | {-# LANGUAGE OverloadedStrings #-} 17 | 18 | import Control.Concurrent 19 | import Control.Concurrent.Async 20 | import LightStep.HighLevel.IO (LogEntryKey (..), addLog, currentSpanContext, getEnvConfig, setParentSpanContext, setTag, withSingletonLightStep, withSpan) 21 | 22 | seriousBusinessMain :: IO () 23 | seriousBusinessMain = concurrently_ frontend backend >> threadDelay 1000000 24 | where 25 | frontend = 26 | withSpan "RESTful API" $ do 27 | threadDelay 10000 28 | setTag "foo" "bar" 29 | withSpan "Kafka" $ do 30 | threadDelay 20000 31 | setTag "foo" "baz" 32 | threadDelay 30000 33 | withSpan "GraphQL" $ do 34 | threadDelay 40000 35 | setTag "foo" "quux" 36 | addLog Event "monkey-job" 37 | addLog (Custom "foo") "bar" 38 | withSpan "Mongodb" $ do 39 | threadDelay 50000 40 | setTag "lorem" "ipsum" 41 | threadDelay 60000 42 | withSpan "data->json" $ pure () 43 | withSpan "json->yaml" $ pure () 44 | withSpan "yaml->xml" $ pure () 45 | withSpan "xml->protobuf" $ pure () 46 | withSpan "protobuf->thrift" $ pure () 47 | withSpan "thrift->base64" $ pure () 48 | threadDelay 70000 49 | backend = 50 | withSpan "Background Data Science" $ do 51 | threadDelay 10000 52 | withSpan "Tensorflow" $ do 53 | threadDelay 100000 54 | setTag "learning" "deep" 55 | withSpan "Torch" $ do 56 | threadDelay 100000 57 | setTag "learning" "very_deep" 58 | withSpan "Hadoop" $ do 59 | threadDelay 100000 60 | setTag "learning" "super_deep" 61 | withSpan "Parallel map reduce" $ do 62 | result <- withSpan "Reduce" $ do 63 | Just ctx <- currentSpanContext 64 | (a, b) <- do 65 | threadDelay 100000 66 | concurrently 67 | ( withSpan "Calculate a" $ do 68 | setParentSpanContext ctx 69 | threadDelay 100000 70 | return "Lorem " 71 | ) 72 | ( withSpan "Calculate b" $ do 73 | setParentSpanContext ctx 74 | threadDelay 100000 75 | return "ipsum" 76 | ) 77 | threadDelay 100000 78 | pure (a <> b) 79 | setTag "result" result 80 | 81 | main :: IO () 82 | main = do 83 | -- Construct a config from env variables 84 | -- - LIGHTSTEP_ACCESS_TOKEN 85 | -- - LIGHTSTEP_HOST (optional) 86 | -- - LIGHTSTEP_PORT (optional) 87 | -- - LIGHTSTEP_SERVICE (optional) 88 | Just lsConfig <- getEnvConfig 89 | withSingletonLightStep lsConfig seriousBusinessMain 90 | putStrLn "All done" 91 | ``` 92 | -------------------------------------------------------------------------------- /README.template.md: -------------------------------------------------------------------------------- 1 | 2 | [![CI Status](https://github.com/ethercrow/lightstep-haskell/workflows/ci/badge.svg)](https://github.com/ethercrow/lightstep-haskell/actions) 3 | ![Hackage](https://img.shields.io/hackage/v/lightstep-haskell) 4 | [![lightstep-haskell on Stackage Nightly](http://stackage.org/package/lightstep-haskell/badge/nightly)](http://stackage.org/nightly/package/lightstep-haskell) 5 | 6 | # What is it? 7 | 8 | A library for instrumenting your code and sending traces to [LightStep](https://lightstep.com/). 9 | 10 | 11 | # How to use it? 12 | 13 | Example usage: 14 | 15 | -------------------------------------------------------------------------------- /cabal.project: -------------------------------------------------------------------------------- 1 | packages: . 2 | 3 | source-repository-package 4 | type: git 5 | location: https://github.com/haskell-grpc-native/http2-grpc-haskell 6 | tag: d7da6d63a16a1e9d16f20f5c50a29a1c42c3d354 7 | subdir: http2-client-grpc 8 | 9 | source-repository-package 10 | type: git 11 | location: https://github.com/haskell-grpc-native/http2-grpc-haskell 12 | tag: d7da6d63a16a1e9d16f20f5c50a29a1c42c3d354 13 | subdir: http2-grpc-proto-lens 14 | 15 | source-repository-package 16 | type: git 17 | location: https://github.com/haskell-grpc-native/http2-grpc-haskell 18 | tag: d7da6d63a16a1e9d16f20f5c50a29a1c42c3d354 19 | subdir: http2-grpc-types 20 | -------------------------------------------------------------------------------- /examples/readme/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | import Control.Concurrent 4 | import Control.Concurrent.Async 5 | import LightStep.HighLevel.IO (LogEntryKey (..), addLog, currentSpanContext, getEnvConfig, setParentSpanContext, setTag, withSingletonLightStep, withSpan) 6 | 7 | seriousBusinessMain :: IO () 8 | seriousBusinessMain = concurrently_ frontend backend >> threadDelay 1000000 9 | where 10 | frontend = 11 | withSpan "RESTful API" $ do 12 | threadDelay 10000 13 | setTag "foo" "bar" 14 | withSpan "Kafka" $ do 15 | threadDelay 20000 16 | setTag "foo" "baz" 17 | threadDelay 30000 18 | withSpan "GraphQL" $ do 19 | threadDelay 40000 20 | setTag "foo" "quux" 21 | addLog Event "monkey-job" 22 | addLog (Custom "foo") "bar" 23 | withSpan "Mongodb" $ do 24 | threadDelay 50000 25 | setTag "lorem" "ipsum" 26 | threadDelay 60000 27 | withSpan "data->json" $ pure () 28 | withSpan "json->yaml" $ pure () 29 | withSpan "yaml->xml" $ pure () 30 | withSpan "xml->protobuf" $ pure () 31 | withSpan "protobuf->thrift" $ pure () 32 | withSpan "thrift->base64" $ pure () 33 | threadDelay 70000 34 | backend = 35 | withSpan "Background Data Science" $ do 36 | threadDelay 10000 37 | withSpan "Tensorflow" $ do 38 | threadDelay 100000 39 | setTag "learning" "deep" 40 | withSpan "Torch" $ do 41 | threadDelay 100000 42 | setTag "learning" "very_deep" 43 | withSpan "Hadoop" $ do 44 | threadDelay 100000 45 | setTag "learning" "super_deep" 46 | withSpan "Parallel map reduce" $ do 47 | result <- withSpan "Reduce" $ do 48 | Just ctx <- currentSpanContext 49 | (a, b) <- do 50 | threadDelay 100000 51 | concurrently 52 | ( withSpan "Calculate a" $ do 53 | setParentSpanContext ctx 54 | threadDelay 100000 55 | return "Lorem " 56 | ) 57 | ( withSpan "Calculate b" $ do 58 | setParentSpanContext ctx 59 | threadDelay 100000 60 | return "ipsum" 61 | ) 62 | threadDelay 100000 63 | pure (a <> b) 64 | setTag "result" result 65 | 66 | main :: IO () 67 | main = do 68 | -- Construct a config from env variables 69 | -- - LIGHTSTEP_ACCESS_TOKEN 70 | -- - LIGHTSTEP_HOST (optional) 71 | -- - LIGHTSTEP_PORT (optional) 72 | -- - LIGHTSTEP_SERVICE (optional) 73 | Just lsConfig <- getEnvConfig 74 | withSingletonLightStep lsConfig seriousBusinessMain 75 | putStrLn "All done" 76 | -------------------------------------------------------------------------------- /examples/req/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | import Control.Concurrent 4 | import Data.CaseInsensitive (original) 5 | import LightStep.HighLevel.IO 6 | import LightStep.Propagation (b3Propagator, inject) 7 | import Network.HTTP.Req 8 | 9 | clientMain :: IO () 10 | clientMain = do 11 | withSpan "req-example" $ do 12 | setTag "span.kind" "client" 13 | setTag "component" "http" 14 | Just ctx <- currentSpanContext 15 | let opts = port 8736 <> foldMap (\(k, v) -> header (original k) v) (inject b3Propagator ctx) 16 | url = http "127.0.0.1" /: "test" 17 | _ <- runReq defaultHttpConfig $ req GET url NoReqBody ignoreResponse opts 18 | pure () 19 | threadDelay 1_000_000 20 | 21 | main :: IO () 22 | main = do 23 | Just lsConfig <- getEnvConfig 24 | withSingletonLightStep lsConfig clientMain 25 | -------------------------------------------------------------------------------- /examples/wai/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | import qualified Data.ByteString.Lazy.Char8 as LBS 4 | import GHC.Stats 5 | import LightStep.Diagnostics 6 | import LightStep.HighLevel.IO (getEnvConfig, withSingletonLightStep, withSpan) 7 | import Network.HTTP.Types 8 | import Network.Wai 9 | import Network.Wai.Handler.Warp (run) 10 | import Network.Wai.Middleware.LightStep 11 | 12 | robustScalableProductionReadyMicroservice :: Application 13 | robustScalableProductionReadyMicroservice = \_req respond -> do 14 | rtsStats <- withSpan "getRTSStats" getRTSStats 15 | diagnostics <- getDiagnostics 16 | respond $ 17 | responseLBS 18 | status200 19 | [("Content-Type", "text/plain")] 20 | ( LBS.pack $ 21 | unlines 22 | [ "RAM usage: " <> show (max_live_bytes rtsStats `div` 1_000) <> " KB", 23 | "Reconnect count: " <> show (diagReconnectCount diagnostics), 24 | "Started span count: " <> show (diagStartedSpanCount diagnostics), 25 | "Finished span count: " <> show (diagFinishedSpanCount diagnostics), 26 | "Reported span count: " <> show (diagReportedSpanCount diagnostics), 27 | "Rejected span count: " <> show (diagRejectedSpanCount diagnostics), 28 | "Dropped span count: " <> show (diagDroppedSpanCount diagnostics) 29 | ] 30 | ) 31 | 32 | main :: IO () 33 | main = do 34 | Just lsConfig <- getEnvConfig 35 | let microserviceWithTracing = tracingMiddleware robustScalableProductionReadyMicroservice 36 | withSingletonLightStep lsConfig $ 37 | run 8736 microserviceWithTracing 38 | -------------------------------------------------------------------------------- /gen/Proto/Collector_Fields.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from collector.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Collector_Fields where 7 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 8 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 9 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 10 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 11 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 12 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 13 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 14 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 15 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 16 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 19 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 20 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 21 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 22 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 23 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 24 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 25 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 26 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 27 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 28 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 29 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 30 | import qualified Proto.Google.Api.Annotations 31 | import qualified Proto.Google.Protobuf.Timestamp 32 | accessToken :: 33 | forall f s a. 34 | (Prelude.Functor f, 35 | Data.ProtoLens.Field.HasField s "accessToken" a) => 36 | Lens.Family2.LensLike' f s a 37 | accessToken = Data.ProtoLens.Field.field @"accessToken" 38 | auth :: 39 | forall f s a. 40 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "auth" a) => 41 | Lens.Family2.LensLike' f s a 42 | auth = Data.ProtoLens.Field.field @"auth" 43 | baggage :: 44 | forall f s a. 45 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "baggage" a) => 46 | Lens.Family2.LensLike' f s a 47 | baggage = Data.ProtoLens.Field.field @"baggage" 48 | boolValue :: 49 | forall f s a. 50 | (Prelude.Functor f, 51 | Data.ProtoLens.Field.HasField s "boolValue" a) => 52 | Lens.Family2.LensLike' f s a 53 | boolValue = Data.ProtoLens.Field.field @"boolValue" 54 | commands :: 55 | forall f s a. 56 | (Prelude.Functor f, 57 | Data.ProtoLens.Field.HasField s "commands" a) => 58 | Lens.Family2.LensLike' f s a 59 | commands = Data.ProtoLens.Field.field @"commands" 60 | counts :: 61 | forall f s a. 62 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "counts" a) => 63 | Lens.Family2.LensLike' f s a 64 | counts = Data.ProtoLens.Field.field @"counts" 65 | devMode :: 66 | forall f s a. 67 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "devMode" a) => 68 | Lens.Family2.LensLike' f s a 69 | devMode = Data.ProtoLens.Field.field @"devMode" 70 | disable :: 71 | forall f s a. 72 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "disable" a) => 73 | Lens.Family2.LensLike' f s a 74 | disable = Data.ProtoLens.Field.field @"disable" 75 | doubleValue :: 76 | forall f s a. 77 | (Prelude.Functor f, 78 | Data.ProtoLens.Field.HasField s "doubleValue" a) => 79 | Lens.Family2.LensLike' f s a 80 | doubleValue = Data.ProtoLens.Field.field @"doubleValue" 81 | durationMicros :: 82 | forall f s a. 83 | (Prelude.Functor f, 84 | Data.ProtoLens.Field.HasField s "durationMicros" a) => 85 | Lens.Family2.LensLike' f s a 86 | durationMicros = Data.ProtoLens.Field.field @"durationMicros" 87 | errors :: 88 | forall f s a. 89 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "errors" a) => 90 | Lens.Family2.LensLike' f s a 91 | errors = Data.ProtoLens.Field.field @"errors" 92 | fields :: 93 | forall f s a. 94 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "fields" a) => 95 | Lens.Family2.LensLike' f s a 96 | fields = Data.ProtoLens.Field.field @"fields" 97 | gauges :: 98 | forall f s a. 99 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "gauges" a) => 100 | Lens.Family2.LensLike' f s a 101 | gauges = Data.ProtoLens.Field.field @"gauges" 102 | infos :: 103 | forall f s a. 104 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "infos" a) => 105 | Lens.Family2.LensLike' f s a 106 | infos = Data.ProtoLens.Field.field @"infos" 107 | intValue :: 108 | forall f s a. 109 | (Prelude.Functor f, 110 | Data.ProtoLens.Field.HasField s "intValue" a) => 111 | Lens.Family2.LensLike' f s a 112 | intValue = Data.ProtoLens.Field.field @"intValue" 113 | internalMetrics :: 114 | forall f s a. 115 | (Prelude.Functor f, 116 | Data.ProtoLens.Field.HasField s "internalMetrics" a) => 117 | Lens.Family2.LensLike' f s a 118 | internalMetrics = Data.ProtoLens.Field.field @"internalMetrics" 119 | jsonValue :: 120 | forall f s a. 121 | (Prelude.Functor f, 122 | Data.ProtoLens.Field.HasField s "jsonValue" a) => 123 | Lens.Family2.LensLike' f s a 124 | jsonValue = Data.ProtoLens.Field.field @"jsonValue" 125 | key :: 126 | forall f s a. 127 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "key" a) => 128 | Lens.Family2.LensLike' f s a 129 | key = Data.ProtoLens.Field.field @"key" 130 | logs :: 131 | forall f s a. 132 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "logs" a) => 133 | Lens.Family2.LensLike' f s a 134 | logs = Data.ProtoLens.Field.field @"logs" 135 | maybe'auth :: 136 | forall f s a. 137 | (Prelude.Functor f, 138 | Data.ProtoLens.Field.HasField s "maybe'auth" a) => 139 | Lens.Family2.LensLike' f s a 140 | maybe'auth = Data.ProtoLens.Field.field @"maybe'auth" 141 | maybe'boolValue :: 142 | forall f s a. 143 | (Prelude.Functor f, 144 | Data.ProtoLens.Field.HasField s "maybe'boolValue" a) => 145 | Lens.Family2.LensLike' f s a 146 | maybe'boolValue = Data.ProtoLens.Field.field @"maybe'boolValue" 147 | maybe'doubleValue :: 148 | forall f s a. 149 | (Prelude.Functor f, 150 | Data.ProtoLens.Field.HasField s "maybe'doubleValue" a) => 151 | Lens.Family2.LensLike' f s a 152 | maybe'doubleValue = Data.ProtoLens.Field.field @"maybe'doubleValue" 153 | maybe'intValue :: 154 | forall f s a. 155 | (Prelude.Functor f, 156 | Data.ProtoLens.Field.HasField s "maybe'intValue" a) => 157 | Lens.Family2.LensLike' f s a 158 | maybe'intValue = Data.ProtoLens.Field.field @"maybe'intValue" 159 | maybe'internalMetrics :: 160 | forall f s a. 161 | (Prelude.Functor f, 162 | Data.ProtoLens.Field.HasField s "maybe'internalMetrics" a) => 163 | Lens.Family2.LensLike' f s a 164 | maybe'internalMetrics 165 | = Data.ProtoLens.Field.field @"maybe'internalMetrics" 166 | maybe'jsonValue :: 167 | forall f s a. 168 | (Prelude.Functor f, 169 | Data.ProtoLens.Field.HasField s "maybe'jsonValue" a) => 170 | Lens.Family2.LensLike' f s a 171 | maybe'jsonValue = Data.ProtoLens.Field.field @"maybe'jsonValue" 172 | maybe'receiveTimestamp :: 173 | forall f s a. 174 | (Prelude.Functor f, 175 | Data.ProtoLens.Field.HasField s "maybe'receiveTimestamp" a) => 176 | Lens.Family2.LensLike' f s a 177 | maybe'receiveTimestamp 178 | = Data.ProtoLens.Field.field @"maybe'receiveTimestamp" 179 | maybe'reporter :: 180 | forall f s a. 181 | (Prelude.Functor f, 182 | Data.ProtoLens.Field.HasField s "maybe'reporter" a) => 183 | Lens.Family2.LensLike' f s a 184 | maybe'reporter = Data.ProtoLens.Field.field @"maybe'reporter" 185 | maybe'spanContext :: 186 | forall f s a. 187 | (Prelude.Functor f, 188 | Data.ProtoLens.Field.HasField s "maybe'spanContext" a) => 189 | Lens.Family2.LensLike' f s a 190 | maybe'spanContext = Data.ProtoLens.Field.field @"maybe'spanContext" 191 | maybe'startTimestamp :: 192 | forall f s a. 193 | (Prelude.Functor f, 194 | Data.ProtoLens.Field.HasField s "maybe'startTimestamp" a) => 195 | Lens.Family2.LensLike' f s a 196 | maybe'startTimestamp 197 | = Data.ProtoLens.Field.field @"maybe'startTimestamp" 198 | maybe'stringValue :: 199 | forall f s a. 200 | (Prelude.Functor f, 201 | Data.ProtoLens.Field.HasField s "maybe'stringValue" a) => 202 | Lens.Family2.LensLike' f s a 203 | maybe'stringValue = Data.ProtoLens.Field.field @"maybe'stringValue" 204 | maybe'timestamp :: 205 | forall f s a. 206 | (Prelude.Functor f, 207 | Data.ProtoLens.Field.HasField s "maybe'timestamp" a) => 208 | Lens.Family2.LensLike' f s a 209 | maybe'timestamp = Data.ProtoLens.Field.field @"maybe'timestamp" 210 | maybe'transmitTimestamp :: 211 | forall f s a. 212 | (Prelude.Functor f, 213 | Data.ProtoLens.Field.HasField s "maybe'transmitTimestamp" a) => 214 | Lens.Family2.LensLike' f s a 215 | maybe'transmitTimestamp 216 | = Data.ProtoLens.Field.field @"maybe'transmitTimestamp" 217 | maybe'value :: 218 | forall f s a. 219 | (Prelude.Functor f, 220 | Data.ProtoLens.Field.HasField s "maybe'value" a) => 221 | Lens.Family2.LensLike' f s a 222 | maybe'value = Data.ProtoLens.Field.field @"maybe'value" 223 | name :: 224 | forall f s a. 225 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "name" a) => 226 | Lens.Family2.LensLike' f s a 227 | name = Data.ProtoLens.Field.field @"name" 228 | operationName :: 229 | forall f s a. 230 | (Prelude.Functor f, 231 | Data.ProtoLens.Field.HasField s "operationName" a) => 232 | Lens.Family2.LensLike' f s a 233 | operationName = Data.ProtoLens.Field.field @"operationName" 234 | receiveTimestamp :: 235 | forall f s a. 236 | (Prelude.Functor f, 237 | Data.ProtoLens.Field.HasField s "receiveTimestamp" a) => 238 | Lens.Family2.LensLike' f s a 239 | receiveTimestamp = Data.ProtoLens.Field.field @"receiveTimestamp" 240 | references :: 241 | forall f s a. 242 | (Prelude.Functor f, 243 | Data.ProtoLens.Field.HasField s "references" a) => 244 | Lens.Family2.LensLike' f s a 245 | references = Data.ProtoLens.Field.field @"references" 246 | relationship :: 247 | forall f s a. 248 | (Prelude.Functor f, 249 | Data.ProtoLens.Field.HasField s "relationship" a) => 250 | Lens.Family2.LensLike' f s a 251 | relationship = Data.ProtoLens.Field.field @"relationship" 252 | reporter :: 253 | forall f s a. 254 | (Prelude.Functor f, 255 | Data.ProtoLens.Field.HasField s "reporter" a) => 256 | Lens.Family2.LensLike' f s a 257 | reporter = Data.ProtoLens.Field.field @"reporter" 258 | reporterId :: 259 | forall f s a. 260 | (Prelude.Functor f, 261 | Data.ProtoLens.Field.HasField s "reporterId" a) => 262 | Lens.Family2.LensLike' f s a 263 | reporterId = Data.ProtoLens.Field.field @"reporterId" 264 | spanContext :: 265 | forall f s a. 266 | (Prelude.Functor f, 267 | Data.ProtoLens.Field.HasField s "spanContext" a) => 268 | Lens.Family2.LensLike' f s a 269 | spanContext = Data.ProtoLens.Field.field @"spanContext" 270 | spanId :: 271 | forall f s a. 272 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "spanId" a) => 273 | Lens.Family2.LensLike' f s a 274 | spanId = Data.ProtoLens.Field.field @"spanId" 275 | spans :: 276 | forall f s a. 277 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "spans" a) => 278 | Lens.Family2.LensLike' f s a 279 | spans = Data.ProtoLens.Field.field @"spans" 280 | startTimestamp :: 281 | forall f s a. 282 | (Prelude.Functor f, 283 | Data.ProtoLens.Field.HasField s "startTimestamp" a) => 284 | Lens.Family2.LensLike' f s a 285 | startTimestamp = Data.ProtoLens.Field.field @"startTimestamp" 286 | stringValue :: 287 | forall f s a. 288 | (Prelude.Functor f, 289 | Data.ProtoLens.Field.HasField s "stringValue" a) => 290 | Lens.Family2.LensLike' f s a 291 | stringValue = Data.ProtoLens.Field.field @"stringValue" 292 | tags :: 293 | forall f s a. 294 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "tags" a) => 295 | Lens.Family2.LensLike' f s a 296 | tags = Data.ProtoLens.Field.field @"tags" 297 | timestamp :: 298 | forall f s a. 299 | (Prelude.Functor f, 300 | Data.ProtoLens.Field.HasField s "timestamp" a) => 301 | Lens.Family2.LensLike' f s a 302 | timestamp = Data.ProtoLens.Field.field @"timestamp" 303 | timestampOffsetMicros :: 304 | forall f s a. 305 | (Prelude.Functor f, 306 | Data.ProtoLens.Field.HasField s "timestampOffsetMicros" a) => 307 | Lens.Family2.LensLike' f s a 308 | timestampOffsetMicros 309 | = Data.ProtoLens.Field.field @"timestampOffsetMicros" 310 | traceId :: 311 | forall f s a. 312 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "traceId" a) => 313 | Lens.Family2.LensLike' f s a 314 | traceId = Data.ProtoLens.Field.field @"traceId" 315 | transmitTimestamp :: 316 | forall f s a. 317 | (Prelude.Functor f, 318 | Data.ProtoLens.Field.HasField s "transmitTimestamp" a) => 319 | Lens.Family2.LensLike' f s a 320 | transmitTimestamp = Data.ProtoLens.Field.field @"transmitTimestamp" 321 | value :: 322 | forall f s a. 323 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "value" a) => 324 | Lens.Family2.LensLike' f s a 325 | value = Data.ProtoLens.Field.field @"value" 326 | vec'commands :: 327 | forall f s a. 328 | (Prelude.Functor f, 329 | Data.ProtoLens.Field.HasField s "vec'commands" a) => 330 | Lens.Family2.LensLike' f s a 331 | vec'commands = Data.ProtoLens.Field.field @"vec'commands" 332 | vec'counts :: 333 | forall f s a. 334 | (Prelude.Functor f, 335 | Data.ProtoLens.Field.HasField s "vec'counts" a) => 336 | Lens.Family2.LensLike' f s a 337 | vec'counts = Data.ProtoLens.Field.field @"vec'counts" 338 | vec'errors :: 339 | forall f s a. 340 | (Prelude.Functor f, 341 | Data.ProtoLens.Field.HasField s "vec'errors" a) => 342 | Lens.Family2.LensLike' f s a 343 | vec'errors = Data.ProtoLens.Field.field @"vec'errors" 344 | vec'fields :: 345 | forall f s a. 346 | (Prelude.Functor f, 347 | Data.ProtoLens.Field.HasField s "vec'fields" a) => 348 | Lens.Family2.LensLike' f s a 349 | vec'fields = Data.ProtoLens.Field.field @"vec'fields" 350 | vec'gauges :: 351 | forall f s a. 352 | (Prelude.Functor f, 353 | Data.ProtoLens.Field.HasField s "vec'gauges" a) => 354 | Lens.Family2.LensLike' f s a 355 | vec'gauges = Data.ProtoLens.Field.field @"vec'gauges" 356 | vec'infos :: 357 | forall f s a. 358 | (Prelude.Functor f, 359 | Data.ProtoLens.Field.HasField s "vec'infos" a) => 360 | Lens.Family2.LensLike' f s a 361 | vec'infos = Data.ProtoLens.Field.field @"vec'infos" 362 | vec'logs :: 363 | forall f s a. 364 | (Prelude.Functor f, 365 | Data.ProtoLens.Field.HasField s "vec'logs" a) => 366 | Lens.Family2.LensLike' f s a 367 | vec'logs = Data.ProtoLens.Field.field @"vec'logs" 368 | vec'references :: 369 | forall f s a. 370 | (Prelude.Functor f, 371 | Data.ProtoLens.Field.HasField s "vec'references" a) => 372 | Lens.Family2.LensLike' f s a 373 | vec'references = Data.ProtoLens.Field.field @"vec'references" 374 | vec'spans :: 375 | forall f s a. 376 | (Prelude.Functor f, 377 | Data.ProtoLens.Field.HasField s "vec'spans" a) => 378 | Lens.Family2.LensLike' f s a 379 | vec'spans = Data.ProtoLens.Field.field @"vec'spans" 380 | vec'tags :: 381 | forall f s a. 382 | (Prelude.Functor f, 383 | Data.ProtoLens.Field.HasField s "vec'tags" a) => 384 | Lens.Family2.LensLike' f s a 385 | vec'tags = Data.ProtoLens.Field.field @"vec'tags" 386 | vec'warnings :: 387 | forall f s a. 388 | (Prelude.Functor f, 389 | Data.ProtoLens.Field.HasField s "vec'warnings" a) => 390 | Lens.Family2.LensLike' f s a 391 | vec'warnings = Data.ProtoLens.Field.field @"vec'warnings" 392 | warnings :: 393 | forall f s a. 394 | (Prelude.Functor f, 395 | Data.ProtoLens.Field.HasField s "warnings" a) => 396 | Lens.Family2.LensLike' f s a 397 | warnings = Data.ProtoLens.Field.field @"warnings" -------------------------------------------------------------------------------- /gen/Proto/Google/Api/Annotations.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from google/api/annotations.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Google.Api.Annotations ( 7 | ) where 8 | import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq 9 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism 10 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 11 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 12 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 13 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 14 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 15 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 16 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 19 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 20 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 21 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 22 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 23 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 24 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 25 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 26 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 27 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 28 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 29 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 30 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 31 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 32 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 33 | import qualified Proto.Google.Api.Http 34 | import qualified Proto.Google.Protobuf.Descriptor -------------------------------------------------------------------------------- /gen/Proto/Google/Api/Annotations_Fields.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from google/api/annotations.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Google.Api.Annotations_Fields where 7 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 8 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 9 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 10 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 11 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 12 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 13 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 14 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 15 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 16 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 19 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 20 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 21 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 22 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 23 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 24 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 25 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 26 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 27 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 28 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 29 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 30 | import qualified Proto.Google.Api.Http 31 | import qualified Proto.Google.Protobuf.Descriptor -------------------------------------------------------------------------------- /gen/Proto/Google/Api/Http.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from google/api/http.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Google.Api.Http ( 7 | CustomHttpPattern(), Http(), HttpRule(), HttpRule'Pattern(..), 8 | _HttpRule'Get, _HttpRule'Put, _HttpRule'Post, _HttpRule'Delete, 9 | _HttpRule'Patch, _HttpRule'Custom 10 | ) where 11 | import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq 12 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism 13 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 14 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 15 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 16 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 19 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 20 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 21 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 22 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 23 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 24 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 25 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 26 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 27 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 28 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 29 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 30 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 31 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 32 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 33 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 34 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 35 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 36 | {- | Fields : 37 | 38 | * 'Proto.Google.Api.Http_Fields.kind' @:: Lens' CustomHttpPattern Data.Text.Text@ 39 | * 'Proto.Google.Api.Http_Fields.path' @:: Lens' CustomHttpPattern Data.Text.Text@ -} 40 | data CustomHttpPattern 41 | = CustomHttpPattern'_constructor {_CustomHttpPattern'kind :: !Data.Text.Text, 42 | _CustomHttpPattern'path :: !Data.Text.Text, 43 | _CustomHttpPattern'_unknownFields :: !Data.ProtoLens.FieldSet} 44 | deriving stock (Prelude.Eq, Prelude.Ord) 45 | instance Prelude.Show CustomHttpPattern where 46 | showsPrec _ __x __s 47 | = Prelude.showChar 48 | '{' 49 | (Prelude.showString 50 | (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s)) 51 | instance Data.ProtoLens.Field.HasField CustomHttpPattern "kind" Data.Text.Text where 52 | fieldOf _ 53 | = (Prelude..) 54 | (Lens.Family2.Unchecked.lens 55 | _CustomHttpPattern'kind 56 | (\ x__ y__ -> x__ {_CustomHttpPattern'kind = y__})) 57 | Prelude.id 58 | instance Data.ProtoLens.Field.HasField CustomHttpPattern "path" Data.Text.Text where 59 | fieldOf _ 60 | = (Prelude..) 61 | (Lens.Family2.Unchecked.lens 62 | _CustomHttpPattern'path 63 | (\ x__ y__ -> x__ {_CustomHttpPattern'path = y__})) 64 | Prelude.id 65 | instance Data.ProtoLens.Message CustomHttpPattern where 66 | messageName _ = Data.Text.pack "google.api.CustomHttpPattern" 67 | packedMessageDescriptor _ 68 | = "\n\ 69 | \\DC1CustomHttpPattern\DC2\DC2\n\ 70 | \\EOTkind\CAN\SOH \SOH(\tR\EOTkind\DC2\DC2\n\ 71 | \\EOTpath\CAN\STX \SOH(\tR\EOTpath" 72 | packedFileDescriptor _ = packedFileDescriptor 73 | fieldsByTag 74 | = let 75 | kind__field_descriptor 76 | = Data.ProtoLens.FieldDescriptor 77 | "kind" 78 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 79 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 80 | (Data.ProtoLens.PlainField 81 | Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"kind")) :: 82 | Data.ProtoLens.FieldDescriptor CustomHttpPattern 83 | path__field_descriptor 84 | = Data.ProtoLens.FieldDescriptor 85 | "path" 86 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 87 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 88 | (Data.ProtoLens.PlainField 89 | Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"path")) :: 90 | Data.ProtoLens.FieldDescriptor CustomHttpPattern 91 | in 92 | Data.Map.fromList 93 | [(Data.ProtoLens.Tag 1, kind__field_descriptor), 94 | (Data.ProtoLens.Tag 2, path__field_descriptor)] 95 | unknownFields 96 | = Lens.Family2.Unchecked.lens 97 | _CustomHttpPattern'_unknownFields 98 | (\ x__ y__ -> x__ {_CustomHttpPattern'_unknownFields = y__}) 99 | defMessage 100 | = CustomHttpPattern'_constructor 101 | {_CustomHttpPattern'kind = Data.ProtoLens.fieldDefault, 102 | _CustomHttpPattern'path = Data.ProtoLens.fieldDefault, 103 | _CustomHttpPattern'_unknownFields = []} 104 | parseMessage 105 | = let 106 | loop :: 107 | CustomHttpPattern 108 | -> Data.ProtoLens.Encoding.Bytes.Parser CustomHttpPattern 109 | loop x 110 | = do end <- Data.ProtoLens.Encoding.Bytes.atEnd 111 | if end then 112 | do (let missing = [] 113 | in 114 | if Prelude.null missing then 115 | Prelude.return () 116 | else 117 | Prelude.fail 118 | ((Prelude.++) 119 | "Missing required fields: " 120 | (Prelude.show (missing :: [Prelude.String])))) 121 | Prelude.return 122 | (Lens.Family2.over 123 | Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x) 124 | else 125 | do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt 126 | case tag of 127 | 10 128 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 129 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 130 | Data.ProtoLens.Encoding.Bytes.getBytes 131 | (Prelude.fromIntegral len) 132 | Data.ProtoLens.Encoding.Bytes.runEither 133 | (case Data.Text.Encoding.decodeUtf8' value of 134 | (Prelude.Left err) 135 | -> Prelude.Left (Prelude.show err) 136 | (Prelude.Right r) -> Prelude.Right r)) 137 | "kind" 138 | loop (Lens.Family2.set (Data.ProtoLens.Field.field @"kind") y x) 139 | 18 140 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 141 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 142 | Data.ProtoLens.Encoding.Bytes.getBytes 143 | (Prelude.fromIntegral len) 144 | Data.ProtoLens.Encoding.Bytes.runEither 145 | (case Data.Text.Encoding.decodeUtf8' value of 146 | (Prelude.Left err) 147 | -> Prelude.Left (Prelude.show err) 148 | (Prelude.Right r) -> Prelude.Right r)) 149 | "path" 150 | loop (Lens.Family2.set (Data.ProtoLens.Field.field @"path") y x) 151 | wire 152 | -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire 153 | wire 154 | loop 155 | (Lens.Family2.over 156 | Data.ProtoLens.unknownFields (\ !t -> (:) y t) x) 157 | in 158 | (Data.ProtoLens.Encoding.Bytes.) 159 | (do loop Data.ProtoLens.defMessage) "CustomHttpPattern" 160 | buildMessage 161 | = \ _x 162 | -> (Data.Monoid.<>) 163 | (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"kind") _x 164 | in 165 | if (Prelude.==) _v Data.ProtoLens.fieldDefault then 166 | Data.Monoid.mempty 167 | else 168 | (Data.Monoid.<>) 169 | (Data.ProtoLens.Encoding.Bytes.putVarInt 10) 170 | ((Prelude..) 171 | (\ bs 172 | -> (Data.Monoid.<>) 173 | (Data.ProtoLens.Encoding.Bytes.putVarInt 174 | (Prelude.fromIntegral (Data.ByteString.length bs))) 175 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 176 | Data.Text.Encoding.encodeUtf8 _v)) 177 | ((Data.Monoid.<>) 178 | (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"path") _x 179 | in 180 | if (Prelude.==) _v Data.ProtoLens.fieldDefault then 181 | Data.Monoid.mempty 182 | else 183 | (Data.Monoid.<>) 184 | (Data.ProtoLens.Encoding.Bytes.putVarInt 18) 185 | ((Prelude..) 186 | (\ bs 187 | -> (Data.Monoid.<>) 188 | (Data.ProtoLens.Encoding.Bytes.putVarInt 189 | (Prelude.fromIntegral (Data.ByteString.length bs))) 190 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 191 | Data.Text.Encoding.encodeUtf8 _v)) 192 | (Data.ProtoLens.Encoding.Wire.buildFieldSet 193 | (Lens.Family2.view Data.ProtoLens.unknownFields _x))) 194 | instance Control.DeepSeq.NFData CustomHttpPattern where 195 | rnf 196 | = \ x__ 197 | -> Control.DeepSeq.deepseq 198 | (_CustomHttpPattern'_unknownFields x__) 199 | (Control.DeepSeq.deepseq 200 | (_CustomHttpPattern'kind x__) 201 | (Control.DeepSeq.deepseq (_CustomHttpPattern'path x__) ())) 202 | {- | Fields : 203 | 204 | * 'Proto.Google.Api.Http_Fields.rules' @:: Lens' Http [HttpRule]@ 205 | * 'Proto.Google.Api.Http_Fields.vec'rules' @:: Lens' Http (Data.Vector.Vector HttpRule)@ -} 206 | data Http 207 | = Http'_constructor {_Http'rules :: !(Data.Vector.Vector HttpRule), 208 | _Http'_unknownFields :: !Data.ProtoLens.FieldSet} 209 | deriving stock (Prelude.Eq, Prelude.Ord) 210 | instance Prelude.Show Http where 211 | showsPrec _ __x __s 212 | = Prelude.showChar 213 | '{' 214 | (Prelude.showString 215 | (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s)) 216 | instance Data.ProtoLens.Field.HasField Http "rules" [HttpRule] where 217 | fieldOf _ 218 | = (Prelude..) 219 | (Lens.Family2.Unchecked.lens 220 | _Http'rules (\ x__ y__ -> x__ {_Http'rules = y__})) 221 | (Lens.Family2.Unchecked.lens 222 | Data.Vector.Generic.toList 223 | (\ _ y__ -> Data.Vector.Generic.fromList y__)) 224 | instance Data.ProtoLens.Field.HasField Http "vec'rules" (Data.Vector.Vector HttpRule) where 225 | fieldOf _ 226 | = (Prelude..) 227 | (Lens.Family2.Unchecked.lens 228 | _Http'rules (\ x__ y__ -> x__ {_Http'rules = y__})) 229 | Prelude.id 230 | instance Data.ProtoLens.Message Http where 231 | messageName _ = Data.Text.pack "google.api.Http" 232 | packedMessageDescriptor _ 233 | = "\n\ 234 | \\EOTHttp\DC2*\n\ 235 | \\ENQrules\CAN\SOH \ETX(\v2\DC4.google.api.HttpRuleR\ENQrules" 236 | packedFileDescriptor _ = packedFileDescriptor 237 | fieldsByTag 238 | = let 239 | rules__field_descriptor 240 | = Data.ProtoLens.FieldDescriptor 241 | "rules" 242 | (Data.ProtoLens.MessageField Data.ProtoLens.MessageType :: 243 | Data.ProtoLens.FieldTypeDescriptor HttpRule) 244 | (Data.ProtoLens.RepeatedField 245 | Data.ProtoLens.Unpacked (Data.ProtoLens.Field.field @"rules")) :: 246 | Data.ProtoLens.FieldDescriptor Http 247 | in 248 | Data.Map.fromList [(Data.ProtoLens.Tag 1, rules__field_descriptor)] 249 | unknownFields 250 | = Lens.Family2.Unchecked.lens 251 | _Http'_unknownFields 252 | (\ x__ y__ -> x__ {_Http'_unknownFields = y__}) 253 | defMessage 254 | = Http'_constructor 255 | {_Http'rules = Data.Vector.Generic.empty, 256 | _Http'_unknownFields = []} 257 | parseMessage 258 | = let 259 | loop :: 260 | Http 261 | -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld HttpRule 262 | -> Data.ProtoLens.Encoding.Bytes.Parser Http 263 | loop x mutable'rules 264 | = do end <- Data.ProtoLens.Encoding.Bytes.atEnd 265 | if end then 266 | do frozen'rules <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO 267 | (Data.ProtoLens.Encoding.Growing.unsafeFreeze mutable'rules) 268 | (let missing = [] 269 | in 270 | if Prelude.null missing then 271 | Prelude.return () 272 | else 273 | Prelude.fail 274 | ((Prelude.++) 275 | "Missing required fields: " 276 | (Prelude.show (missing :: [Prelude.String])))) 277 | Prelude.return 278 | (Lens.Family2.over 279 | Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) 280 | (Lens.Family2.set 281 | (Data.ProtoLens.Field.field @"vec'rules") frozen'rules x)) 282 | else 283 | do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt 284 | case tag of 285 | 10 286 | -> do !y <- (Data.ProtoLens.Encoding.Bytes.) 287 | (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 288 | Data.ProtoLens.Encoding.Bytes.isolate 289 | (Prelude.fromIntegral len) 290 | Data.ProtoLens.parseMessage) 291 | "rules" 292 | v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO 293 | (Data.ProtoLens.Encoding.Growing.append mutable'rules y) 294 | loop x v 295 | wire 296 | -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire 297 | wire 298 | loop 299 | (Lens.Family2.over 300 | Data.ProtoLens.unknownFields (\ !t -> (:) y t) x) 301 | mutable'rules 302 | in 303 | (Data.ProtoLens.Encoding.Bytes.) 304 | (do mutable'rules <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO 305 | Data.ProtoLens.Encoding.Growing.new 306 | loop Data.ProtoLens.defMessage mutable'rules) 307 | "Http" 308 | buildMessage 309 | = \ _x 310 | -> (Data.Monoid.<>) 311 | (Data.ProtoLens.Encoding.Bytes.foldMapBuilder 312 | (\ _v 313 | -> (Data.Monoid.<>) 314 | (Data.ProtoLens.Encoding.Bytes.putVarInt 10) 315 | ((Prelude..) 316 | (\ bs 317 | -> (Data.Monoid.<>) 318 | (Data.ProtoLens.Encoding.Bytes.putVarInt 319 | (Prelude.fromIntegral (Data.ByteString.length bs))) 320 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 321 | Data.ProtoLens.encodeMessage _v)) 322 | (Lens.Family2.view (Data.ProtoLens.Field.field @"vec'rules") _x)) 323 | (Data.ProtoLens.Encoding.Wire.buildFieldSet 324 | (Lens.Family2.view Data.ProtoLens.unknownFields _x)) 325 | instance Control.DeepSeq.NFData Http where 326 | rnf 327 | = \ x__ 328 | -> Control.DeepSeq.deepseq 329 | (_Http'_unknownFields x__) 330 | (Control.DeepSeq.deepseq (_Http'rules x__) ()) 331 | {- | Fields : 332 | 333 | * 'Proto.Google.Api.Http_Fields.selector' @:: Lens' HttpRule Data.Text.Text@ 334 | * 'Proto.Google.Api.Http_Fields.body' @:: Lens' HttpRule Data.Text.Text@ 335 | * 'Proto.Google.Api.Http_Fields.additionalBindings' @:: Lens' HttpRule [HttpRule]@ 336 | * 'Proto.Google.Api.Http_Fields.vec'additionalBindings' @:: Lens' HttpRule (Data.Vector.Vector HttpRule)@ 337 | * 'Proto.Google.Api.Http_Fields.maybe'pattern'' @:: Lens' HttpRule (Prelude.Maybe HttpRule'Pattern)@ 338 | * 'Proto.Google.Api.Http_Fields.maybe'get' @:: Lens' HttpRule (Prelude.Maybe Data.Text.Text)@ 339 | * 'Proto.Google.Api.Http_Fields.get' @:: Lens' HttpRule Data.Text.Text@ 340 | * 'Proto.Google.Api.Http_Fields.maybe'put' @:: Lens' HttpRule (Prelude.Maybe Data.Text.Text)@ 341 | * 'Proto.Google.Api.Http_Fields.put' @:: Lens' HttpRule Data.Text.Text@ 342 | * 'Proto.Google.Api.Http_Fields.maybe'post' @:: Lens' HttpRule (Prelude.Maybe Data.Text.Text)@ 343 | * 'Proto.Google.Api.Http_Fields.post' @:: Lens' HttpRule Data.Text.Text@ 344 | * 'Proto.Google.Api.Http_Fields.maybe'delete' @:: Lens' HttpRule (Prelude.Maybe Data.Text.Text)@ 345 | * 'Proto.Google.Api.Http_Fields.delete' @:: Lens' HttpRule Data.Text.Text@ 346 | * 'Proto.Google.Api.Http_Fields.maybe'patch' @:: Lens' HttpRule (Prelude.Maybe Data.Text.Text)@ 347 | * 'Proto.Google.Api.Http_Fields.patch' @:: Lens' HttpRule Data.Text.Text@ 348 | * 'Proto.Google.Api.Http_Fields.maybe'custom' @:: Lens' HttpRule (Prelude.Maybe CustomHttpPattern)@ 349 | * 'Proto.Google.Api.Http_Fields.custom' @:: Lens' HttpRule CustomHttpPattern@ -} 350 | data HttpRule 351 | = HttpRule'_constructor {_HttpRule'selector :: !Data.Text.Text, 352 | _HttpRule'body :: !Data.Text.Text, 353 | _HttpRule'additionalBindings :: !(Data.Vector.Vector HttpRule), 354 | _HttpRule'pattern' :: !(Prelude.Maybe HttpRule'Pattern), 355 | _HttpRule'_unknownFields :: !Data.ProtoLens.FieldSet} 356 | deriving stock (Prelude.Eq, Prelude.Ord) 357 | instance Prelude.Show HttpRule where 358 | showsPrec _ __x __s 359 | = Prelude.showChar 360 | '{' 361 | (Prelude.showString 362 | (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s)) 363 | data HttpRule'Pattern 364 | = HttpRule'Get !Data.Text.Text | 365 | HttpRule'Put !Data.Text.Text | 366 | HttpRule'Post !Data.Text.Text | 367 | HttpRule'Delete !Data.Text.Text | 368 | HttpRule'Patch !Data.Text.Text | 369 | HttpRule'Custom !CustomHttpPattern 370 | deriving stock (Prelude.Show, Prelude.Eq, Prelude.Ord) 371 | instance Data.ProtoLens.Field.HasField HttpRule "selector" Data.Text.Text where 372 | fieldOf _ 373 | = (Prelude..) 374 | (Lens.Family2.Unchecked.lens 375 | _HttpRule'selector (\ x__ y__ -> x__ {_HttpRule'selector = y__})) 376 | Prelude.id 377 | instance Data.ProtoLens.Field.HasField HttpRule "body" Data.Text.Text where 378 | fieldOf _ 379 | = (Prelude..) 380 | (Lens.Family2.Unchecked.lens 381 | _HttpRule'body (\ x__ y__ -> x__ {_HttpRule'body = y__})) 382 | Prelude.id 383 | instance Data.ProtoLens.Field.HasField HttpRule "additionalBindings" [HttpRule] where 384 | fieldOf _ 385 | = (Prelude..) 386 | (Lens.Family2.Unchecked.lens 387 | _HttpRule'additionalBindings 388 | (\ x__ y__ -> x__ {_HttpRule'additionalBindings = y__})) 389 | (Lens.Family2.Unchecked.lens 390 | Data.Vector.Generic.toList 391 | (\ _ y__ -> Data.Vector.Generic.fromList y__)) 392 | instance Data.ProtoLens.Field.HasField HttpRule "vec'additionalBindings" (Data.Vector.Vector HttpRule) where 393 | fieldOf _ 394 | = (Prelude..) 395 | (Lens.Family2.Unchecked.lens 396 | _HttpRule'additionalBindings 397 | (\ x__ y__ -> x__ {_HttpRule'additionalBindings = y__})) 398 | Prelude.id 399 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'pattern'" (Prelude.Maybe HttpRule'Pattern) where 400 | fieldOf _ 401 | = (Prelude..) 402 | (Lens.Family2.Unchecked.lens 403 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 404 | Prelude.id 405 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'get" (Prelude.Maybe Data.Text.Text) where 406 | fieldOf _ 407 | = (Prelude..) 408 | (Lens.Family2.Unchecked.lens 409 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 410 | (Lens.Family2.Unchecked.lens 411 | (\ x__ 412 | -> case x__ of 413 | (Prelude.Just (HttpRule'Get x__val)) -> Prelude.Just x__val 414 | _otherwise -> Prelude.Nothing) 415 | (\ _ y__ -> Prelude.fmap HttpRule'Get y__)) 416 | instance Data.ProtoLens.Field.HasField HttpRule "get" Data.Text.Text where 417 | fieldOf _ 418 | = (Prelude..) 419 | (Lens.Family2.Unchecked.lens 420 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 421 | ((Prelude..) 422 | (Lens.Family2.Unchecked.lens 423 | (\ x__ 424 | -> case x__ of 425 | (Prelude.Just (HttpRule'Get x__val)) -> Prelude.Just x__val 426 | _otherwise -> Prelude.Nothing) 427 | (\ _ y__ -> Prelude.fmap HttpRule'Get y__)) 428 | (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault)) 429 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'put" (Prelude.Maybe Data.Text.Text) where 430 | fieldOf _ 431 | = (Prelude..) 432 | (Lens.Family2.Unchecked.lens 433 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 434 | (Lens.Family2.Unchecked.lens 435 | (\ x__ 436 | -> case x__ of 437 | (Prelude.Just (HttpRule'Put x__val)) -> Prelude.Just x__val 438 | _otherwise -> Prelude.Nothing) 439 | (\ _ y__ -> Prelude.fmap HttpRule'Put y__)) 440 | instance Data.ProtoLens.Field.HasField HttpRule "put" Data.Text.Text where 441 | fieldOf _ 442 | = (Prelude..) 443 | (Lens.Family2.Unchecked.lens 444 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 445 | ((Prelude..) 446 | (Lens.Family2.Unchecked.lens 447 | (\ x__ 448 | -> case x__ of 449 | (Prelude.Just (HttpRule'Put x__val)) -> Prelude.Just x__val 450 | _otherwise -> Prelude.Nothing) 451 | (\ _ y__ -> Prelude.fmap HttpRule'Put y__)) 452 | (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault)) 453 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'post" (Prelude.Maybe Data.Text.Text) where 454 | fieldOf _ 455 | = (Prelude..) 456 | (Lens.Family2.Unchecked.lens 457 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 458 | (Lens.Family2.Unchecked.lens 459 | (\ x__ 460 | -> case x__ of 461 | (Prelude.Just (HttpRule'Post x__val)) -> Prelude.Just x__val 462 | _otherwise -> Prelude.Nothing) 463 | (\ _ y__ -> Prelude.fmap HttpRule'Post y__)) 464 | instance Data.ProtoLens.Field.HasField HttpRule "post" Data.Text.Text where 465 | fieldOf _ 466 | = (Prelude..) 467 | (Lens.Family2.Unchecked.lens 468 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 469 | ((Prelude..) 470 | (Lens.Family2.Unchecked.lens 471 | (\ x__ 472 | -> case x__ of 473 | (Prelude.Just (HttpRule'Post x__val)) -> Prelude.Just x__val 474 | _otherwise -> Prelude.Nothing) 475 | (\ _ y__ -> Prelude.fmap HttpRule'Post y__)) 476 | (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault)) 477 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'delete" (Prelude.Maybe Data.Text.Text) where 478 | fieldOf _ 479 | = (Prelude..) 480 | (Lens.Family2.Unchecked.lens 481 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 482 | (Lens.Family2.Unchecked.lens 483 | (\ x__ 484 | -> case x__ of 485 | (Prelude.Just (HttpRule'Delete x__val)) -> Prelude.Just x__val 486 | _otherwise -> Prelude.Nothing) 487 | (\ _ y__ -> Prelude.fmap HttpRule'Delete y__)) 488 | instance Data.ProtoLens.Field.HasField HttpRule "delete" Data.Text.Text where 489 | fieldOf _ 490 | = (Prelude..) 491 | (Lens.Family2.Unchecked.lens 492 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 493 | ((Prelude..) 494 | (Lens.Family2.Unchecked.lens 495 | (\ x__ 496 | -> case x__ of 497 | (Prelude.Just (HttpRule'Delete x__val)) -> Prelude.Just x__val 498 | _otherwise -> Prelude.Nothing) 499 | (\ _ y__ -> Prelude.fmap HttpRule'Delete y__)) 500 | (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault)) 501 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'patch" (Prelude.Maybe Data.Text.Text) where 502 | fieldOf _ 503 | = (Prelude..) 504 | (Lens.Family2.Unchecked.lens 505 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 506 | (Lens.Family2.Unchecked.lens 507 | (\ x__ 508 | -> case x__ of 509 | (Prelude.Just (HttpRule'Patch x__val)) -> Prelude.Just x__val 510 | _otherwise -> Prelude.Nothing) 511 | (\ _ y__ -> Prelude.fmap HttpRule'Patch y__)) 512 | instance Data.ProtoLens.Field.HasField HttpRule "patch" Data.Text.Text where 513 | fieldOf _ 514 | = (Prelude..) 515 | (Lens.Family2.Unchecked.lens 516 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 517 | ((Prelude..) 518 | (Lens.Family2.Unchecked.lens 519 | (\ x__ 520 | -> case x__ of 521 | (Prelude.Just (HttpRule'Patch x__val)) -> Prelude.Just x__val 522 | _otherwise -> Prelude.Nothing) 523 | (\ _ y__ -> Prelude.fmap HttpRule'Patch y__)) 524 | (Data.ProtoLens.maybeLens Data.ProtoLens.fieldDefault)) 525 | instance Data.ProtoLens.Field.HasField HttpRule "maybe'custom" (Prelude.Maybe CustomHttpPattern) where 526 | fieldOf _ 527 | = (Prelude..) 528 | (Lens.Family2.Unchecked.lens 529 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 530 | (Lens.Family2.Unchecked.lens 531 | (\ x__ 532 | -> case x__ of 533 | (Prelude.Just (HttpRule'Custom x__val)) -> Prelude.Just x__val 534 | _otherwise -> Prelude.Nothing) 535 | (\ _ y__ -> Prelude.fmap HttpRule'Custom y__)) 536 | instance Data.ProtoLens.Field.HasField HttpRule "custom" CustomHttpPattern where 537 | fieldOf _ 538 | = (Prelude..) 539 | (Lens.Family2.Unchecked.lens 540 | _HttpRule'pattern' (\ x__ y__ -> x__ {_HttpRule'pattern' = y__})) 541 | ((Prelude..) 542 | (Lens.Family2.Unchecked.lens 543 | (\ x__ 544 | -> case x__ of 545 | (Prelude.Just (HttpRule'Custom x__val)) -> Prelude.Just x__val 546 | _otherwise -> Prelude.Nothing) 547 | (\ _ y__ -> Prelude.fmap HttpRule'Custom y__)) 548 | (Data.ProtoLens.maybeLens Data.ProtoLens.defMessage)) 549 | instance Data.ProtoLens.Message HttpRule where 550 | messageName _ = Data.Text.pack "google.api.HttpRule" 551 | packedMessageDescriptor _ 552 | = "\n\ 553 | \\bHttpRule\DC2\SUB\n\ 554 | \\bselector\CAN\SOH \SOH(\tR\bselector\DC2\DC2\n\ 555 | \\ETXget\CAN\STX \SOH(\tH\NULR\ETXget\DC2\DC2\n\ 556 | \\ETXput\CAN\ETX \SOH(\tH\NULR\ETXput\DC2\DC4\n\ 557 | \\EOTpost\CAN\EOT \SOH(\tH\NULR\EOTpost\DC2\CAN\n\ 558 | \\ACKdelete\CAN\ENQ \SOH(\tH\NULR\ACKdelete\DC2\SYN\n\ 559 | \\ENQpatch\CAN\ACK \SOH(\tH\NULR\ENQpatch\DC27\n\ 560 | \\ACKcustom\CAN\b \SOH(\v2\GS.google.api.CustomHttpPatternH\NULR\ACKcustom\DC2\DC2\n\ 561 | \\EOTbody\CAN\a \SOH(\tR\EOTbody\DC2E\n\ 562 | \\DC3additional_bindings\CAN\v \ETX(\v2\DC4.google.api.HttpRuleR\DC2additionalBindingsB\t\n\ 563 | \\apattern" 564 | packedFileDescriptor _ = packedFileDescriptor 565 | fieldsByTag 566 | = let 567 | selector__field_descriptor 568 | = Data.ProtoLens.FieldDescriptor 569 | "selector" 570 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 571 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 572 | (Data.ProtoLens.PlainField 573 | Data.ProtoLens.Optional 574 | (Data.ProtoLens.Field.field @"selector")) :: 575 | Data.ProtoLens.FieldDescriptor HttpRule 576 | body__field_descriptor 577 | = Data.ProtoLens.FieldDescriptor 578 | "body" 579 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 580 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 581 | (Data.ProtoLens.PlainField 582 | Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"body")) :: 583 | Data.ProtoLens.FieldDescriptor HttpRule 584 | additionalBindings__field_descriptor 585 | = Data.ProtoLens.FieldDescriptor 586 | "additional_bindings" 587 | (Data.ProtoLens.MessageField Data.ProtoLens.MessageType :: 588 | Data.ProtoLens.FieldTypeDescriptor HttpRule) 589 | (Data.ProtoLens.RepeatedField 590 | Data.ProtoLens.Unpacked 591 | (Data.ProtoLens.Field.field @"additionalBindings")) :: 592 | Data.ProtoLens.FieldDescriptor HttpRule 593 | get__field_descriptor 594 | = Data.ProtoLens.FieldDescriptor 595 | "get" 596 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 597 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 598 | (Data.ProtoLens.OptionalField 599 | (Data.ProtoLens.Field.field @"maybe'get")) :: 600 | Data.ProtoLens.FieldDescriptor HttpRule 601 | put__field_descriptor 602 | = Data.ProtoLens.FieldDescriptor 603 | "put" 604 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 605 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 606 | (Data.ProtoLens.OptionalField 607 | (Data.ProtoLens.Field.field @"maybe'put")) :: 608 | Data.ProtoLens.FieldDescriptor HttpRule 609 | post__field_descriptor 610 | = Data.ProtoLens.FieldDescriptor 611 | "post" 612 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 613 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 614 | (Data.ProtoLens.OptionalField 615 | (Data.ProtoLens.Field.field @"maybe'post")) :: 616 | Data.ProtoLens.FieldDescriptor HttpRule 617 | delete__field_descriptor 618 | = Data.ProtoLens.FieldDescriptor 619 | "delete" 620 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 621 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 622 | (Data.ProtoLens.OptionalField 623 | (Data.ProtoLens.Field.field @"maybe'delete")) :: 624 | Data.ProtoLens.FieldDescriptor HttpRule 625 | patch__field_descriptor 626 | = Data.ProtoLens.FieldDescriptor 627 | "patch" 628 | (Data.ProtoLens.ScalarField Data.ProtoLens.StringField :: 629 | Data.ProtoLens.FieldTypeDescriptor Data.Text.Text) 630 | (Data.ProtoLens.OptionalField 631 | (Data.ProtoLens.Field.field @"maybe'patch")) :: 632 | Data.ProtoLens.FieldDescriptor HttpRule 633 | custom__field_descriptor 634 | = Data.ProtoLens.FieldDescriptor 635 | "custom" 636 | (Data.ProtoLens.MessageField Data.ProtoLens.MessageType :: 637 | Data.ProtoLens.FieldTypeDescriptor CustomHttpPattern) 638 | (Data.ProtoLens.OptionalField 639 | (Data.ProtoLens.Field.field @"maybe'custom")) :: 640 | Data.ProtoLens.FieldDescriptor HttpRule 641 | in 642 | Data.Map.fromList 643 | [(Data.ProtoLens.Tag 1, selector__field_descriptor), 644 | (Data.ProtoLens.Tag 7, body__field_descriptor), 645 | (Data.ProtoLens.Tag 11, additionalBindings__field_descriptor), 646 | (Data.ProtoLens.Tag 2, get__field_descriptor), 647 | (Data.ProtoLens.Tag 3, put__field_descriptor), 648 | (Data.ProtoLens.Tag 4, post__field_descriptor), 649 | (Data.ProtoLens.Tag 5, delete__field_descriptor), 650 | (Data.ProtoLens.Tag 6, patch__field_descriptor), 651 | (Data.ProtoLens.Tag 8, custom__field_descriptor)] 652 | unknownFields 653 | = Lens.Family2.Unchecked.lens 654 | _HttpRule'_unknownFields 655 | (\ x__ y__ -> x__ {_HttpRule'_unknownFields = y__}) 656 | defMessage 657 | = HttpRule'_constructor 658 | {_HttpRule'selector = Data.ProtoLens.fieldDefault, 659 | _HttpRule'body = Data.ProtoLens.fieldDefault, 660 | _HttpRule'additionalBindings = Data.Vector.Generic.empty, 661 | _HttpRule'pattern' = Prelude.Nothing, 662 | _HttpRule'_unknownFields = []} 663 | parseMessage 664 | = let 665 | loop :: 666 | HttpRule 667 | -> Data.ProtoLens.Encoding.Growing.Growing Data.Vector.Vector Data.ProtoLens.Encoding.Growing.RealWorld HttpRule 668 | -> Data.ProtoLens.Encoding.Bytes.Parser HttpRule 669 | loop x mutable'additionalBindings 670 | = do end <- Data.ProtoLens.Encoding.Bytes.atEnd 671 | if end then 672 | do frozen'additionalBindings <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO 673 | (Data.ProtoLens.Encoding.Growing.unsafeFreeze 674 | mutable'additionalBindings) 675 | (let missing = [] 676 | in 677 | if Prelude.null missing then 678 | Prelude.return () 679 | else 680 | Prelude.fail 681 | ((Prelude.++) 682 | "Missing required fields: " 683 | (Prelude.show (missing :: [Prelude.String])))) 684 | Prelude.return 685 | (Lens.Family2.over 686 | Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) 687 | (Lens.Family2.set 688 | (Data.ProtoLens.Field.field @"vec'additionalBindings") 689 | frozen'additionalBindings x)) 690 | else 691 | do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt 692 | case tag of 693 | 10 694 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 695 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 696 | Data.ProtoLens.Encoding.Bytes.getBytes 697 | (Prelude.fromIntegral len) 698 | Data.ProtoLens.Encoding.Bytes.runEither 699 | (case Data.Text.Encoding.decodeUtf8' value of 700 | (Prelude.Left err) 701 | -> Prelude.Left (Prelude.show err) 702 | (Prelude.Right r) -> Prelude.Right r)) 703 | "selector" 704 | loop 705 | (Lens.Family2.set (Data.ProtoLens.Field.field @"selector") y x) 706 | mutable'additionalBindings 707 | 58 708 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 709 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 710 | Data.ProtoLens.Encoding.Bytes.getBytes 711 | (Prelude.fromIntegral len) 712 | Data.ProtoLens.Encoding.Bytes.runEither 713 | (case Data.Text.Encoding.decodeUtf8' value of 714 | (Prelude.Left err) 715 | -> Prelude.Left (Prelude.show err) 716 | (Prelude.Right r) -> Prelude.Right r)) 717 | "body" 718 | loop 719 | (Lens.Family2.set (Data.ProtoLens.Field.field @"body") y x) 720 | mutable'additionalBindings 721 | 90 722 | -> do !y <- (Data.ProtoLens.Encoding.Bytes.) 723 | (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 724 | Data.ProtoLens.Encoding.Bytes.isolate 725 | (Prelude.fromIntegral len) 726 | Data.ProtoLens.parseMessage) 727 | "additional_bindings" 728 | v <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO 729 | (Data.ProtoLens.Encoding.Growing.append 730 | mutable'additionalBindings y) 731 | loop x v 732 | 18 733 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 734 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 735 | Data.ProtoLens.Encoding.Bytes.getBytes 736 | (Prelude.fromIntegral len) 737 | Data.ProtoLens.Encoding.Bytes.runEither 738 | (case Data.Text.Encoding.decodeUtf8' value of 739 | (Prelude.Left err) 740 | -> Prelude.Left (Prelude.show err) 741 | (Prelude.Right r) -> Prelude.Right r)) 742 | "get" 743 | loop 744 | (Lens.Family2.set (Data.ProtoLens.Field.field @"get") y x) 745 | mutable'additionalBindings 746 | 26 747 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 748 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 749 | Data.ProtoLens.Encoding.Bytes.getBytes 750 | (Prelude.fromIntegral len) 751 | Data.ProtoLens.Encoding.Bytes.runEither 752 | (case Data.Text.Encoding.decodeUtf8' value of 753 | (Prelude.Left err) 754 | -> Prelude.Left (Prelude.show err) 755 | (Prelude.Right r) -> Prelude.Right r)) 756 | "put" 757 | loop 758 | (Lens.Family2.set (Data.ProtoLens.Field.field @"put") y x) 759 | mutable'additionalBindings 760 | 34 761 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 762 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 763 | Data.ProtoLens.Encoding.Bytes.getBytes 764 | (Prelude.fromIntegral len) 765 | Data.ProtoLens.Encoding.Bytes.runEither 766 | (case Data.Text.Encoding.decodeUtf8' value of 767 | (Prelude.Left err) 768 | -> Prelude.Left (Prelude.show err) 769 | (Prelude.Right r) -> Prelude.Right r)) 770 | "post" 771 | loop 772 | (Lens.Family2.set (Data.ProtoLens.Field.field @"post") y x) 773 | mutable'additionalBindings 774 | 42 775 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 776 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 777 | Data.ProtoLens.Encoding.Bytes.getBytes 778 | (Prelude.fromIntegral len) 779 | Data.ProtoLens.Encoding.Bytes.runEither 780 | (case Data.Text.Encoding.decodeUtf8' value of 781 | (Prelude.Left err) 782 | -> Prelude.Left (Prelude.show err) 783 | (Prelude.Right r) -> Prelude.Right r)) 784 | "delete" 785 | loop 786 | (Lens.Family2.set (Data.ProtoLens.Field.field @"delete") y x) 787 | mutable'additionalBindings 788 | 50 789 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 790 | (do value <- do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 791 | Data.ProtoLens.Encoding.Bytes.getBytes 792 | (Prelude.fromIntegral len) 793 | Data.ProtoLens.Encoding.Bytes.runEither 794 | (case Data.Text.Encoding.decodeUtf8' value of 795 | (Prelude.Left err) 796 | -> Prelude.Left (Prelude.show err) 797 | (Prelude.Right r) -> Prelude.Right r)) 798 | "patch" 799 | loop 800 | (Lens.Family2.set (Data.ProtoLens.Field.field @"patch") y x) 801 | mutable'additionalBindings 802 | 66 803 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 804 | (do len <- Data.ProtoLens.Encoding.Bytes.getVarInt 805 | Data.ProtoLens.Encoding.Bytes.isolate 806 | (Prelude.fromIntegral len) Data.ProtoLens.parseMessage) 807 | "custom" 808 | loop 809 | (Lens.Family2.set (Data.ProtoLens.Field.field @"custom") y x) 810 | mutable'additionalBindings 811 | wire 812 | -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire 813 | wire 814 | loop 815 | (Lens.Family2.over 816 | Data.ProtoLens.unknownFields (\ !t -> (:) y t) x) 817 | mutable'additionalBindings 818 | in 819 | (Data.ProtoLens.Encoding.Bytes.) 820 | (do mutable'additionalBindings <- Data.ProtoLens.Encoding.Parser.Unsafe.unsafeLiftIO 821 | Data.ProtoLens.Encoding.Growing.new 822 | loop Data.ProtoLens.defMessage mutable'additionalBindings) 823 | "HttpRule" 824 | buildMessage 825 | = \ _x 826 | -> (Data.Monoid.<>) 827 | (let 828 | _v = Lens.Family2.view (Data.ProtoLens.Field.field @"selector") _x 829 | in 830 | if (Prelude.==) _v Data.ProtoLens.fieldDefault then 831 | Data.Monoid.mempty 832 | else 833 | (Data.Monoid.<>) 834 | (Data.ProtoLens.Encoding.Bytes.putVarInt 10) 835 | ((Prelude..) 836 | (\ bs 837 | -> (Data.Monoid.<>) 838 | (Data.ProtoLens.Encoding.Bytes.putVarInt 839 | (Prelude.fromIntegral (Data.ByteString.length bs))) 840 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 841 | Data.Text.Encoding.encodeUtf8 _v)) 842 | ((Data.Monoid.<>) 843 | (let _v = Lens.Family2.view (Data.ProtoLens.Field.field @"body") _x 844 | in 845 | if (Prelude.==) _v Data.ProtoLens.fieldDefault then 846 | Data.Monoid.mempty 847 | else 848 | (Data.Monoid.<>) 849 | (Data.ProtoLens.Encoding.Bytes.putVarInt 58) 850 | ((Prelude..) 851 | (\ bs 852 | -> (Data.Monoid.<>) 853 | (Data.ProtoLens.Encoding.Bytes.putVarInt 854 | (Prelude.fromIntegral (Data.ByteString.length bs))) 855 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 856 | Data.Text.Encoding.encodeUtf8 _v)) 857 | ((Data.Monoid.<>) 858 | (Data.ProtoLens.Encoding.Bytes.foldMapBuilder 859 | (\ _v 860 | -> (Data.Monoid.<>) 861 | (Data.ProtoLens.Encoding.Bytes.putVarInt 90) 862 | ((Prelude..) 863 | (\ bs 864 | -> (Data.Monoid.<>) 865 | (Data.ProtoLens.Encoding.Bytes.putVarInt 866 | (Prelude.fromIntegral (Data.ByteString.length bs))) 867 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 868 | Data.ProtoLens.encodeMessage _v)) 869 | (Lens.Family2.view 870 | (Data.ProtoLens.Field.field @"vec'additionalBindings") _x)) 871 | ((Data.Monoid.<>) 872 | (case 873 | Lens.Family2.view (Data.ProtoLens.Field.field @"maybe'pattern'") _x 874 | of 875 | Prelude.Nothing -> Data.Monoid.mempty 876 | (Prelude.Just (HttpRule'Get v)) 877 | -> (Data.Monoid.<>) 878 | (Data.ProtoLens.Encoding.Bytes.putVarInt 18) 879 | ((Prelude..) 880 | (\ bs 881 | -> (Data.Monoid.<>) 882 | (Data.ProtoLens.Encoding.Bytes.putVarInt 883 | (Prelude.fromIntegral (Data.ByteString.length bs))) 884 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 885 | Data.Text.Encoding.encodeUtf8 v) 886 | (Prelude.Just (HttpRule'Put v)) 887 | -> (Data.Monoid.<>) 888 | (Data.ProtoLens.Encoding.Bytes.putVarInt 26) 889 | ((Prelude..) 890 | (\ bs 891 | -> (Data.Monoid.<>) 892 | (Data.ProtoLens.Encoding.Bytes.putVarInt 893 | (Prelude.fromIntegral (Data.ByteString.length bs))) 894 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 895 | Data.Text.Encoding.encodeUtf8 v) 896 | (Prelude.Just (HttpRule'Post v)) 897 | -> (Data.Monoid.<>) 898 | (Data.ProtoLens.Encoding.Bytes.putVarInt 34) 899 | ((Prelude..) 900 | (\ bs 901 | -> (Data.Monoid.<>) 902 | (Data.ProtoLens.Encoding.Bytes.putVarInt 903 | (Prelude.fromIntegral (Data.ByteString.length bs))) 904 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 905 | Data.Text.Encoding.encodeUtf8 v) 906 | (Prelude.Just (HttpRule'Delete v)) 907 | -> (Data.Monoid.<>) 908 | (Data.ProtoLens.Encoding.Bytes.putVarInt 42) 909 | ((Prelude..) 910 | (\ bs 911 | -> (Data.Monoid.<>) 912 | (Data.ProtoLens.Encoding.Bytes.putVarInt 913 | (Prelude.fromIntegral (Data.ByteString.length bs))) 914 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 915 | Data.Text.Encoding.encodeUtf8 v) 916 | (Prelude.Just (HttpRule'Patch v)) 917 | -> (Data.Monoid.<>) 918 | (Data.ProtoLens.Encoding.Bytes.putVarInt 50) 919 | ((Prelude..) 920 | (\ bs 921 | -> (Data.Monoid.<>) 922 | (Data.ProtoLens.Encoding.Bytes.putVarInt 923 | (Prelude.fromIntegral (Data.ByteString.length bs))) 924 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 925 | Data.Text.Encoding.encodeUtf8 v) 926 | (Prelude.Just (HttpRule'Custom v)) 927 | -> (Data.Monoid.<>) 928 | (Data.ProtoLens.Encoding.Bytes.putVarInt 66) 929 | ((Prelude..) 930 | (\ bs 931 | -> (Data.Monoid.<>) 932 | (Data.ProtoLens.Encoding.Bytes.putVarInt 933 | (Prelude.fromIntegral (Data.ByteString.length bs))) 934 | (Data.ProtoLens.Encoding.Bytes.putBytes bs)) 935 | Data.ProtoLens.encodeMessage v)) 936 | (Data.ProtoLens.Encoding.Wire.buildFieldSet 937 | (Lens.Family2.view Data.ProtoLens.unknownFields _x))))) 938 | instance Control.DeepSeq.NFData HttpRule where 939 | rnf 940 | = \ x__ 941 | -> Control.DeepSeq.deepseq 942 | (_HttpRule'_unknownFields x__) 943 | (Control.DeepSeq.deepseq 944 | (_HttpRule'selector x__) 945 | (Control.DeepSeq.deepseq 946 | (_HttpRule'body x__) 947 | (Control.DeepSeq.deepseq 948 | (_HttpRule'additionalBindings x__) 949 | (Control.DeepSeq.deepseq (_HttpRule'pattern' x__) ())))) 950 | instance Control.DeepSeq.NFData HttpRule'Pattern where 951 | rnf (HttpRule'Get x__) = Control.DeepSeq.rnf x__ 952 | rnf (HttpRule'Put x__) = Control.DeepSeq.rnf x__ 953 | rnf (HttpRule'Post x__) = Control.DeepSeq.rnf x__ 954 | rnf (HttpRule'Delete x__) = Control.DeepSeq.rnf x__ 955 | rnf (HttpRule'Patch x__) = Control.DeepSeq.rnf x__ 956 | rnf (HttpRule'Custom x__) = Control.DeepSeq.rnf x__ 957 | _HttpRule'Get :: 958 | Data.ProtoLens.Prism.Prism' HttpRule'Pattern Data.Text.Text 959 | _HttpRule'Get 960 | = Data.ProtoLens.Prism.prism' 961 | HttpRule'Get 962 | (\ p__ 963 | -> case p__ of 964 | (HttpRule'Get p__val) -> Prelude.Just p__val 965 | _otherwise -> Prelude.Nothing) 966 | _HttpRule'Put :: 967 | Data.ProtoLens.Prism.Prism' HttpRule'Pattern Data.Text.Text 968 | _HttpRule'Put 969 | = Data.ProtoLens.Prism.prism' 970 | HttpRule'Put 971 | (\ p__ 972 | -> case p__ of 973 | (HttpRule'Put p__val) -> Prelude.Just p__val 974 | _otherwise -> Prelude.Nothing) 975 | _HttpRule'Post :: 976 | Data.ProtoLens.Prism.Prism' HttpRule'Pattern Data.Text.Text 977 | _HttpRule'Post 978 | = Data.ProtoLens.Prism.prism' 979 | HttpRule'Post 980 | (\ p__ 981 | -> case p__ of 982 | (HttpRule'Post p__val) -> Prelude.Just p__val 983 | _otherwise -> Prelude.Nothing) 984 | _HttpRule'Delete :: 985 | Data.ProtoLens.Prism.Prism' HttpRule'Pattern Data.Text.Text 986 | _HttpRule'Delete 987 | = Data.ProtoLens.Prism.prism' 988 | HttpRule'Delete 989 | (\ p__ 990 | -> case p__ of 991 | (HttpRule'Delete p__val) -> Prelude.Just p__val 992 | _otherwise -> Prelude.Nothing) 993 | _HttpRule'Patch :: 994 | Data.ProtoLens.Prism.Prism' HttpRule'Pattern Data.Text.Text 995 | _HttpRule'Patch 996 | = Data.ProtoLens.Prism.prism' 997 | HttpRule'Patch 998 | (\ p__ 999 | -> case p__ of 1000 | (HttpRule'Patch p__val) -> Prelude.Just p__val 1001 | _otherwise -> Prelude.Nothing) 1002 | _HttpRule'Custom :: 1003 | Data.ProtoLens.Prism.Prism' HttpRule'Pattern CustomHttpPattern 1004 | _HttpRule'Custom 1005 | = Data.ProtoLens.Prism.prism' 1006 | HttpRule'Custom 1007 | (\ p__ 1008 | -> case p__ of 1009 | (HttpRule'Custom p__val) -> Prelude.Just p__val 1010 | _otherwise -> Prelude.Nothing) 1011 | packedFileDescriptor :: Data.ByteString.ByteString 1012 | packedFileDescriptor 1013 | = "\n\ 1014 | \\NAKgoogle/api/http.proto\DC2\n\ 1015 | \google.api\"2\n\ 1016 | \\EOTHttp\DC2*\n\ 1017 | \\ENQrules\CAN\SOH \ETX(\v2\DC4.google.api.HttpRuleR\ENQrules\"\181\STX\n\ 1018 | \\bHttpRule\DC2\SUB\n\ 1019 | \\bselector\CAN\SOH \SOH(\tR\bselector\DC2\DC2\n\ 1020 | \\ETXget\CAN\STX \SOH(\tH\NULR\ETXget\DC2\DC2\n\ 1021 | \\ETXput\CAN\ETX \SOH(\tH\NULR\ETXput\DC2\DC4\n\ 1022 | \\EOTpost\CAN\EOT \SOH(\tH\NULR\EOTpost\DC2\CAN\n\ 1023 | \\ACKdelete\CAN\ENQ \SOH(\tH\NULR\ACKdelete\DC2\SYN\n\ 1024 | \\ENQpatch\CAN\ACK \SOH(\tH\NULR\ENQpatch\DC27\n\ 1025 | \\ACKcustom\CAN\b \SOH(\v2\GS.google.api.CustomHttpPatternH\NULR\ACKcustom\DC2\DC2\n\ 1026 | \\EOTbody\CAN\a \SOH(\tR\EOTbody\DC2E\n\ 1027 | \\DC3additional_bindings\CAN\v \ETX(\v2\DC4.google.api.HttpRuleR\DC2additionalBindingsB\t\n\ 1028 | \\apattern\";\n\ 1029 | \\DC1CustomHttpPattern\DC2\DC2\n\ 1030 | \\EOTkind\CAN\SOH \SOH(\tR\EOTkind\DC2\DC2\n\ 1031 | \\EOTpath\CAN\STX \SOH(\tR\EOTpathBj\n\ 1032 | \\SOcom.google.apiB\tHttpProtoP\SOHZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\248\SOH\SOH\162\STX\EOTGAPIJ\205Q\n\ 1033 | \\a\DC2\ENQ\SO\NUL\162\STX\SOH\n\ 1034 | \\189\EOT\n\ 1035 | \\SOH\f\DC2\ETX\SO\NUL\DC22\178\EOT Copyright 2016 Google Inc.\n\ 1036 | \\n\ 1037 | \ Licensed under the Apache License, Version 2.0 (the \"License\");\n\ 1038 | \ you may not use this file except in compliance with the License.\n\ 1039 | \ You may obtain a copy of the License at\n\ 1040 | \\n\ 1041 | \ http://www.apache.org/licenses/LICENSE-2.0\n\ 1042 | \\n\ 1043 | \ Unless required by applicable law or agreed to in writing, software\n\ 1044 | \ distributed under the License is distributed on an \"AS IS\" BASIS,\n\ 1045 | \ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\ 1046 | \ See the License for the specific language governing permissions and\n\ 1047 | \ limitations under the License.\n\ 1048 | \\n\ 1049 | \\b\n\ 1050 | \\SOH\STX\DC2\ETX\DLE\NUL\DC3\n\ 1051 | \\b\n\ 1052 | \\SOH\b\DC2\ETX\DC2\NUL\US\n\ 1053 | \\t\n\ 1054 | \\STX\b\US\DC2\ETX\DC2\NUL\US\n\ 1055 | \\b\n\ 1056 | \\SOH\b\DC2\ETX\DC3\NULX\n\ 1057 | \\t\n\ 1058 | \\STX\b\v\DC2\ETX\DC3\NULX\n\ 1059 | \\b\n\ 1060 | \\SOH\b\DC2\ETX\DC4\NUL\"\n\ 1061 | \\t\n\ 1062 | \\STX\b\n\ 1063 | \\DC2\ETX\DC4\NUL\"\n\ 1064 | \\b\n\ 1065 | \\SOH\b\DC2\ETX\NAK\NUL*\n\ 1066 | \\t\n\ 1067 | \\STX\b\b\DC2\ETX\NAK\NUL*\n\ 1068 | \\b\n\ 1069 | \\SOH\b\DC2\ETX\SYN\NUL'\n\ 1070 | \\t\n\ 1071 | \\STX\b\SOH\DC2\ETX\SYN\NUL'\n\ 1072 | \\b\n\ 1073 | \\SOH\b\DC2\ETX\ETB\NUL\"\n\ 1074 | \\t\n\ 1075 | \\STX\b$\DC2\ETX\ETB\NUL\"\n\ 1076 | \\200\SOH\n\ 1077 | \\STX\EOT\NUL\DC2\EOT\GS\NUL\"\SOH\SUB\187\SOH Defines the HTTP configuration for a service. It contains a list of\n\ 1078 | \ [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method\n\ 1079 | \ to one or more HTTP REST API methods.\n\ 1080 | \\n\ 1081 | \\n\ 1082 | \\n\ 1083 | \\ETX\EOT\NUL\SOH\DC2\ETX\GS\b\f\n\ 1084 | \\162\SOH\n\ 1085 | \\EOT\EOT\NUL\STX\NUL\DC2\ETX!\STX\RS\SUB\148\SOH A list of HTTP configuration rules that apply to individual API methods.\n\ 1086 | \\n\ 1087 | \ **NOTE:** All service configuration rules follow \"last one wins\" order.\n\ 1088 | \\n\ 1089 | \\f\n\ 1090 | \\ENQ\EOT\NUL\STX\NUL\EOT\DC2\ETX!\STX\n\ 1091 | \\n\ 1092 | \\f\n\ 1093 | \\ENQ\EOT\NUL\STX\NUL\ACK\DC2\ETX!\v\DC3\n\ 1094 | \\f\n\ 1095 | \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\ETX!\DC4\EM\n\ 1096 | \\f\n\ 1097 | \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\ETX!\FS\GS\n\ 1098 | \\223\&9\n\ 1099 | \\STX\EOT\SOH\DC2\ACK\242\SOH\NUL\153\STX\SOH\SUB\208\&9 `HttpRule` defines the mapping of an RPC method to one or more HTTP\n\ 1100 | \ REST APIs. The mapping determines what portions of the request\n\ 1101 | \ message are populated from the path, query parameters, or body of\n\ 1102 | \ the HTTP request. The mapping is typically specified as an\n\ 1103 | \ `google.api.http` annotation, see \"google/api/annotations.proto\"\n\ 1104 | \ for details.\n\ 1105 | \\n\ 1106 | \ The mapping consists of a field specifying the path template and\n\ 1107 | \ method kind. The path template can refer to fields in the request\n\ 1108 | \ message, as in the example below which describes a REST GET\n\ 1109 | \ operation on a resource collection of messages:\n\ 1110 | \\n\ 1111 | \\n\ 1112 | \ service Messaging {\n\ 1113 | \ rpc GetMessage(GetMessageRequest) returns (Message) {\n\ 1114 | \ option (google.api.http).get = \"/v1/messages/{message_id}/{sub.subfield}\";\n\ 1115 | \ }\n\ 1116 | \ }\n\ 1117 | \ message GetMessageRequest {\n\ 1118 | \ message SubMessage {\n\ 1119 | \ string subfield = 1;\n\ 1120 | \ }\n\ 1121 | \ string message_id = 1; // mapped to the URL\n\ 1122 | \ SubMessage sub = 2; // `sub.subfield` is url-mapped\n\ 1123 | \ }\n\ 1124 | \ message Message {\n\ 1125 | \ string text = 1; // content of the resource\n\ 1126 | \ }\n\ 1127 | \\n\ 1128 | \ The same http annotation can alternatively be expressed inside the\n\ 1129 | \ `GRPC API Configuration` YAML file.\n\ 1130 | \\n\ 1131 | \ http:\n\ 1132 | \ rules:\n\ 1133 | \ - selector: .Messaging.GetMessage\n\ 1134 | \ get: /v1/messages/{message_id}/{sub.subfield}\n\ 1135 | \\n\ 1136 | \ This definition enables an automatic, bidrectional mapping of HTTP\n\ 1137 | \ JSON to RPC. Example:\n\ 1138 | \\n\ 1139 | \ HTTP | RPC\n\ 1140 | \ -----|-----\n\ 1141 | \ `GET /v1/messages/123456/foo` | `GetMessage(message_id: \"123456\" sub: SubMessage(subfield: \"foo\"))`\n\ 1142 | \\n\ 1143 | \ In general, not only fields but also field paths can be referenced\n\ 1144 | \ from a path pattern. Fields mapped to the path pattern cannot be\n\ 1145 | \ repeated and must have a primitive (non-message) type.\n\ 1146 | \\n\ 1147 | \ Any fields in the request message which are not bound by the path\n\ 1148 | \ pattern automatically become (optional) HTTP query\n\ 1149 | \ parameters. Assume the following definition of the request message:\n\ 1150 | \\n\ 1151 | \\n\ 1152 | \ message GetMessageRequest {\n\ 1153 | \ message SubMessage {\n\ 1154 | \ string subfield = 1;\n\ 1155 | \ }\n\ 1156 | \ string message_id = 1; // mapped to the URL\n\ 1157 | \ int64 revision = 2; // becomes a parameter\n\ 1158 | \ SubMessage sub = 3; // `sub.subfield` becomes a parameter\n\ 1159 | \ }\n\ 1160 | \\n\ 1161 | \\n\ 1162 | \ This enables a HTTP JSON to RPC mapping as below:\n\ 1163 | \\n\ 1164 | \ HTTP | RPC\n\ 1165 | \ -----|-----\n\ 1166 | \ `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: \"123456\" revision: 2 sub: SubMessage(subfield: \"foo\"))`\n\ 1167 | \\n\ 1168 | \ Note that fields which are mapped to HTTP parameters must have a\n\ 1169 | \ primitive type or a repeated primitive type. Message types are not\n\ 1170 | \ allowed. In the case of a repeated type, the parameter can be\n\ 1171 | \ repeated in the URL, as in `...?param=A¶m=B`.\n\ 1172 | \\n\ 1173 | \ For HTTP method kinds which allow a request body, the `body` field\n\ 1174 | \ specifies the mapping. Consider a REST update method on the\n\ 1175 | \ message resource collection:\n\ 1176 | \\n\ 1177 | \\n\ 1178 | \ service Messaging {\n\ 1179 | \ rpc UpdateMessage(UpdateMessageRequest) returns (Message) {\n\ 1180 | \ option (google.api.http) = {\n\ 1181 | \ put: \"/v1/messages/{message_id}\"\n\ 1182 | \ body: \"message\"\n\ 1183 | \ };\n\ 1184 | \ }\n\ 1185 | \ }\n\ 1186 | \ message UpdateMessageRequest {\n\ 1187 | \ string message_id = 1; // mapped to the URL\n\ 1188 | \ Message message = 2; // mapped to the body\n\ 1189 | \ }\n\ 1190 | \\n\ 1191 | \\n\ 1192 | \ The following HTTP JSON to RPC mapping is enabled, where the\n\ 1193 | \ representation of the JSON in the request body is determined by\n\ 1194 | \ protos JSON encoding:\n\ 1195 | \\n\ 1196 | \ HTTP | RPC\n\ 1197 | \ -----|-----\n\ 1198 | \ `PUT /v1/messages/123456 { \"text\": \"Hi!\" }` | `UpdateMessage(message_id: \"123456\" message { text: \"Hi!\" })`\n\ 1199 | \\n\ 1200 | \ The special name `*` can be used in the body mapping to define that\n\ 1201 | \ every field not bound by the path template should be mapped to the\n\ 1202 | \ request body. This enables the following alternative definition of\n\ 1203 | \ the update method:\n\ 1204 | \\n\ 1205 | \ service Messaging {\n\ 1206 | \ rpc UpdateMessage(Message) returns (Message) {\n\ 1207 | \ option (google.api.http) = {\n\ 1208 | \ put: \"/v1/messages/{message_id}\"\n\ 1209 | \ body: \"*\"\n\ 1210 | \ };\n\ 1211 | \ }\n\ 1212 | \ }\n\ 1213 | \ message Message {\n\ 1214 | \ string message_id = 1;\n\ 1215 | \ string text = 2;\n\ 1216 | \ }\n\ 1217 | \\n\ 1218 | \\n\ 1219 | \ The following HTTP JSON to RPC mapping is enabled:\n\ 1220 | \\n\ 1221 | \ HTTP | RPC\n\ 1222 | \ -----|-----\n\ 1223 | \ `PUT /v1/messages/123456 { \"text\": \"Hi!\" }` | `UpdateMessage(message_id: \"123456\" text: \"Hi!\")`\n\ 1224 | \\n\ 1225 | \ Note that when using `*` in the body mapping, it is not possible to\n\ 1226 | \ have HTTP parameters, as all fields not bound by the path end in\n\ 1227 | \ the body. This makes this option more rarely used in practice of\n\ 1228 | \ defining REST APIs. The common usage of `*` is in custom methods\n\ 1229 | \ which don't use the URL at all for transferring data.\n\ 1230 | \\n\ 1231 | \ It is possible to define multiple HTTP methods for one RPC by using\n\ 1232 | \ the `additional_bindings` option. Example:\n\ 1233 | \\n\ 1234 | \ service Messaging {\n\ 1235 | \ rpc GetMessage(GetMessageRequest) returns (Message) {\n\ 1236 | \ option (google.api.http) = {\n\ 1237 | \ get: \"/v1/messages/{message_id}\"\n\ 1238 | \ additional_bindings {\n\ 1239 | \ get: \"/v1/users/{user_id}/messages/{message_id}\"\n\ 1240 | \ }\n\ 1241 | \ };\n\ 1242 | \ }\n\ 1243 | \ }\n\ 1244 | \ message GetMessageRequest {\n\ 1245 | \ string message_id = 1;\n\ 1246 | \ string user_id = 2;\n\ 1247 | \ }\n\ 1248 | \\n\ 1249 | \\n\ 1250 | \ This enables the following two alternative HTTP JSON to RPC\n\ 1251 | \ mappings:\n\ 1252 | \\n\ 1253 | \ HTTP | RPC\n\ 1254 | \ -----|-----\n\ 1255 | \ `GET /v1/messages/123456` | `GetMessage(message_id: \"123456\")`\n\ 1256 | \ `GET /v1/users/me/messages/123456` | `GetMessage(user_id: \"me\" message_id: \"123456\")`\n\ 1257 | \\n\ 1258 | \ # Rules for HTTP mapping\n\ 1259 | \\n\ 1260 | \ The rules for mapping HTTP path, query parameters, and body fields\n\ 1261 | \ to the request message are as follows:\n\ 1262 | \\n\ 1263 | \ 1. The `body` field specifies either `*` or a field path, or is\n\ 1264 | \ omitted. If omitted, it assumes there is no HTTP body.\n\ 1265 | \ 2. Leaf fields (recursive expansion of nested messages in the\n\ 1266 | \ request) can be classified into three types:\n\ 1267 | \ (a) Matched in the URL template.\n\ 1268 | \ (b) Covered by body (if body is `*`, everything except (a) fields;\n\ 1269 | \ else everything under the body field)\n\ 1270 | \ (c) All other fields.\n\ 1271 | \ 3. URL query parameters found in the HTTP request are mapped to (c) fields.\n\ 1272 | \ 4. Any body sent with an HTTP request can contain only (b) fields.\n\ 1273 | \\n\ 1274 | \ The syntax of the path template is as follows:\n\ 1275 | \\n\ 1276 | \ Template = \"/\" Segments [ Verb ] ;\n\ 1277 | \ Segments = Segment { \"/\" Segment } ;\n\ 1278 | \ Segment = \"*\" | \"**\" | LITERAL | Variable ;\n\ 1279 | \ Variable = \"{\" FieldPath [ \"=\" Segments ] \"}\" ;\n\ 1280 | \ FieldPath = IDENT { \".\" IDENT } ;\n\ 1281 | \ Verb = \":\" LITERAL ;\n\ 1282 | \\n\ 1283 | \ The syntax `*` matches a single path segment. It follows the semantics of\n\ 1284 | \ [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String\n\ 1285 | \ Expansion.\n\ 1286 | \\n\ 1287 | \ The syntax `**` matches zero or more path segments. It follows the semantics\n\ 1288 | \ of [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.3 Reserved\n\ 1289 | \ Expansion. NOTE: it must be the last segment in the path except the Verb.\n\ 1290 | \\n\ 1291 | \ The syntax `LITERAL` matches literal text in the URL path.\n\ 1292 | \\n\ 1293 | \ The syntax `Variable` matches the entire path as specified by its template;\n\ 1294 | \ this nested template must not contain further variables. If a variable\n\ 1295 | \ matches a single path segment, its template may be omitted, e.g. `{var}`\n\ 1296 | \ is equivalent to `{var=*}`.\n\ 1297 | \\n\ 1298 | \ NOTE: the field paths in variables and in the `body` must not refer to\n\ 1299 | \ repeated fields or map fields.\n\ 1300 | \\n\ 1301 | \ Use CustomHttpPattern to specify any HTTP method that is not included in the\n\ 1302 | \ `pattern` field, such as HEAD, or \"*\" to leave the HTTP method unspecified for\n\ 1303 | \ a given URL path rule. The wild-card rule is useful for services that provide\n\ 1304 | \ content to Web (HTML) clients.\n\ 1305 | \\n\ 1306 | \\v\n\ 1307 | \\ETX\EOT\SOH\SOH\DC2\EOT\242\SOH\b\DLE\n\ 1308 | \\140\SOH\n\ 1309 | \\EOT\EOT\SOH\STX\NUL\DC2\EOT\246\SOH\STX\SYN\SUB~ Selects methods to which this rule applies.\n\ 1310 | \\n\ 1311 | \ Refer to [selector][google.api.DocumentationRule.selector] for syntax details.\n\ 1312 | \\n\ 1313 | \\r\n\ 1314 | \\ENQ\EOT\SOH\STX\NUL\ENQ\DC2\EOT\246\SOH\STX\b\n\ 1315 | \\r\n\ 1316 | \\ENQ\EOT\SOH\STX\NUL\SOH\DC2\EOT\246\SOH\t\DC1\n\ 1317 | \\r\n\ 1318 | \\ENQ\EOT\SOH\STX\NUL\ETX\DC2\EOT\246\SOH\DC4\NAK\n\ 1319 | \\208\SOH\n\ 1320 | \\EOT\EOT\SOH\b\NUL\DC2\ACK\251\SOH\STX\141\STX\ETX\SUB\191\SOH Determines the URL pattern is matched by this rules. This pattern can be\n\ 1321 | \ used with any of the {get|put|post|delete|patch} methods. A custom method\n\ 1322 | \ can be defined using the 'custom' field.\n\ 1323 | \\n\ 1324 | \\r\n\ 1325 | \\ENQ\EOT\SOH\b\NUL\SOH\DC2\EOT\251\SOH\b\SI\n\ 1326 | \I\n\ 1327 | \\EOT\EOT\SOH\STX\SOH\DC2\EOT\253\SOH\EOT\DC3\SUB; Used for listing and getting information about resources.\n\ 1328 | \\n\ 1329 | \\r\n\ 1330 | \\ENQ\EOT\SOH\STX\SOH\ENQ\DC2\EOT\253\SOH\EOT\n\ 1331 | \\n\ 1332 | \\r\n\ 1333 | \\ENQ\EOT\SOH\STX\SOH\SOH\DC2\EOT\253\SOH\v\SO\n\ 1334 | \\r\n\ 1335 | \\ENQ\EOT\SOH\STX\SOH\ETX\DC2\EOT\253\SOH\DC1\DC2\n\ 1336 | \-\n\ 1337 | \\EOT\EOT\SOH\STX\STX\DC2\EOT\128\STX\EOT\DC3\SUB\US Used for updating a resource.\n\ 1338 | \\n\ 1339 | \\r\n\ 1340 | \\ENQ\EOT\SOH\STX\STX\ENQ\DC2\EOT\128\STX\EOT\n\ 1341 | \\n\ 1342 | \\r\n\ 1343 | \\ENQ\EOT\SOH\STX\STX\SOH\DC2\EOT\128\STX\v\SO\n\ 1344 | \\r\n\ 1345 | \\ENQ\EOT\SOH\STX\STX\ETX\DC2\EOT\128\STX\DC1\DC2\n\ 1346 | \-\n\ 1347 | \\EOT\EOT\SOH\STX\ETX\DC2\EOT\131\STX\EOT\DC4\SUB\US Used for creating a resource.\n\ 1348 | \\n\ 1349 | \\r\n\ 1350 | \\ENQ\EOT\SOH\STX\ETX\ENQ\DC2\EOT\131\STX\EOT\n\ 1351 | \\n\ 1352 | \\r\n\ 1353 | \\ENQ\EOT\SOH\STX\ETX\SOH\DC2\EOT\131\STX\v\SI\n\ 1354 | \\r\n\ 1355 | \\ENQ\EOT\SOH\STX\ETX\ETX\DC2\EOT\131\STX\DC2\DC3\n\ 1356 | \-\n\ 1357 | \\EOT\EOT\SOH\STX\EOT\DC2\EOT\134\STX\EOT\SYN\SUB\US Used for deleting a resource.\n\ 1358 | \\n\ 1359 | \\r\n\ 1360 | \\ENQ\EOT\SOH\STX\EOT\ENQ\DC2\EOT\134\STX\EOT\n\ 1361 | \\n\ 1362 | \\r\n\ 1363 | \\ENQ\EOT\SOH\STX\EOT\SOH\DC2\EOT\134\STX\v\DC1\n\ 1364 | \\r\n\ 1365 | \\ENQ\EOT\SOH\STX\EOT\ETX\DC2\EOT\134\STX\DC4\NAK\n\ 1366 | \-\n\ 1367 | \\EOT\EOT\SOH\STX\ENQ\DC2\EOT\137\STX\EOT\NAK\SUB\US Used for updating a resource.\n\ 1368 | \\n\ 1369 | \\r\n\ 1370 | \\ENQ\EOT\SOH\STX\ENQ\ENQ\DC2\EOT\137\STX\EOT\n\ 1371 | \\n\ 1372 | \\r\n\ 1373 | \\ENQ\EOT\SOH\STX\ENQ\SOH\DC2\EOT\137\STX\v\DLE\n\ 1374 | \\r\n\ 1375 | \\ENQ\EOT\SOH\STX\ENQ\ETX\DC2\EOT\137\STX\DC3\DC4\n\ 1376 | \A\n\ 1377 | \\EOT\EOT\SOH\STX\ACK\DC2\EOT\140\STX\EOT!\SUB3 Custom pattern is used for defining custom verbs.\n\ 1378 | \\n\ 1379 | \\r\n\ 1380 | \\ENQ\EOT\SOH\STX\ACK\ACK\DC2\EOT\140\STX\EOT\NAK\n\ 1381 | \\r\n\ 1382 | \\ENQ\EOT\SOH\STX\ACK\SOH\DC2\EOT\140\STX\SYN\FS\n\ 1383 | \\r\n\ 1384 | \\ENQ\EOT\SOH\STX\ACK\ETX\DC2\EOT\140\STX\US \n\ 1385 | \\158\STX\n\ 1386 | \\EOT\EOT\SOH\STX\a\DC2\EOT\147\STX\STX\DC2\SUB\143\STX The name of the request field whose value is mapped to the HTTP body, or\n\ 1387 | \ `*` for mapping all fields not captured by the path pattern to the HTTP\n\ 1388 | \ body. NOTE: the referred field must not be a repeated field and must be\n\ 1389 | \ present at the top-level of request message type.\n\ 1390 | \\n\ 1391 | \\r\n\ 1392 | \\ENQ\EOT\SOH\STX\a\ENQ\DC2\EOT\147\STX\STX\b\n\ 1393 | \\r\n\ 1394 | \\ENQ\EOT\SOH\STX\a\SOH\DC2\EOT\147\STX\t\r\n\ 1395 | \\r\n\ 1396 | \\ENQ\EOT\SOH\STX\a\ETX\DC2\EOT\147\STX\DLE\DC1\n\ 1397 | \\187\SOH\n\ 1398 | \\EOT\EOT\SOH\STX\b\DC2\EOT\152\STX\STX-\SUB\172\SOH Additional HTTP bindings for the selector. Nested bindings must\n\ 1399 | \ not contain an `additional_bindings` field themselves (that is,\n\ 1400 | \ the nesting may only be one level deep).\n\ 1401 | \\n\ 1402 | \\r\n\ 1403 | \\ENQ\EOT\SOH\STX\b\EOT\DC2\EOT\152\STX\STX\n\ 1404 | \\n\ 1405 | \\r\n\ 1406 | \\ENQ\EOT\SOH\STX\b\ACK\DC2\EOT\152\STX\v\DC3\n\ 1407 | \\r\n\ 1408 | \\ENQ\EOT\SOH\STX\b\SOH\DC2\EOT\152\STX\DC4'\n\ 1409 | \\r\n\ 1410 | \\ENQ\EOT\SOH\STX\b\ETX\DC2\EOT\152\STX*,\n\ 1411 | \G\n\ 1412 | \\STX\EOT\STX\DC2\ACK\156\STX\NUL\162\STX\SOH\SUB9 A custom pattern is used for defining custom HTTP verb.\n\ 1413 | \\n\ 1414 | \\v\n\ 1415 | \\ETX\EOT\STX\SOH\DC2\EOT\156\STX\b\EM\n\ 1416 | \2\n\ 1417 | \\EOT\EOT\STX\STX\NUL\DC2\EOT\158\STX\STX\DC2\SUB$ The name of this custom HTTP verb.\n\ 1418 | \\n\ 1419 | \\r\n\ 1420 | \\ENQ\EOT\STX\STX\NUL\ENQ\DC2\EOT\158\STX\STX\b\n\ 1421 | \\r\n\ 1422 | \\ENQ\EOT\STX\STX\NUL\SOH\DC2\EOT\158\STX\t\r\n\ 1423 | \\r\n\ 1424 | \\ENQ\EOT\STX\STX\NUL\ETX\DC2\EOT\158\STX\DLE\DC1\n\ 1425 | \5\n\ 1426 | \\EOT\EOT\STX\STX\SOH\DC2\EOT\161\STX\STX\DC2\SUB' The path matched by this custom verb.\n\ 1427 | \\n\ 1428 | \\r\n\ 1429 | \\ENQ\EOT\STX\STX\SOH\ENQ\DC2\EOT\161\STX\STX\b\n\ 1430 | \\r\n\ 1431 | \\ENQ\EOT\STX\STX\SOH\SOH\DC2\EOT\161\STX\t\r\n\ 1432 | \\r\n\ 1433 | \\ENQ\EOT\STX\STX\SOH\ETX\DC2\EOT\161\STX\DLE\DC1b\ACKproto3" -------------------------------------------------------------------------------- /gen/Proto/Google/Api/Http_Fields.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from google/api/http.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Google.Api.Http_Fields where 7 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 8 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 9 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 10 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 11 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 12 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 13 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 14 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 15 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 16 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 19 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 20 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 21 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 22 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 23 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 24 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 25 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 26 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 27 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 28 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 29 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 30 | additionalBindings :: 31 | forall f s a. 32 | (Prelude.Functor f, 33 | Data.ProtoLens.Field.HasField s "additionalBindings" a) => 34 | Lens.Family2.LensLike' f s a 35 | additionalBindings 36 | = Data.ProtoLens.Field.field @"additionalBindings" 37 | body :: 38 | forall f s a. 39 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "body" a) => 40 | Lens.Family2.LensLike' f s a 41 | body = Data.ProtoLens.Field.field @"body" 42 | custom :: 43 | forall f s a. 44 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "custom" a) => 45 | Lens.Family2.LensLike' f s a 46 | custom = Data.ProtoLens.Field.field @"custom" 47 | delete :: 48 | forall f s a. 49 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "delete" a) => 50 | Lens.Family2.LensLike' f s a 51 | delete = Data.ProtoLens.Field.field @"delete" 52 | get :: 53 | forall f s a. 54 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "get" a) => 55 | Lens.Family2.LensLike' f s a 56 | get = Data.ProtoLens.Field.field @"get" 57 | kind :: 58 | forall f s a. 59 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "kind" a) => 60 | Lens.Family2.LensLike' f s a 61 | kind = Data.ProtoLens.Field.field @"kind" 62 | maybe'custom :: 63 | forall f s a. 64 | (Prelude.Functor f, 65 | Data.ProtoLens.Field.HasField s "maybe'custom" a) => 66 | Lens.Family2.LensLike' f s a 67 | maybe'custom = Data.ProtoLens.Field.field @"maybe'custom" 68 | maybe'delete :: 69 | forall f s a. 70 | (Prelude.Functor f, 71 | Data.ProtoLens.Field.HasField s "maybe'delete" a) => 72 | Lens.Family2.LensLike' f s a 73 | maybe'delete = Data.ProtoLens.Field.field @"maybe'delete" 74 | maybe'get :: 75 | forall f s a. 76 | (Prelude.Functor f, 77 | Data.ProtoLens.Field.HasField s "maybe'get" a) => 78 | Lens.Family2.LensLike' f s a 79 | maybe'get = Data.ProtoLens.Field.field @"maybe'get" 80 | maybe'patch :: 81 | forall f s a. 82 | (Prelude.Functor f, 83 | Data.ProtoLens.Field.HasField s "maybe'patch" a) => 84 | Lens.Family2.LensLike' f s a 85 | maybe'patch = Data.ProtoLens.Field.field @"maybe'patch" 86 | maybe'pattern' :: 87 | forall f s a. 88 | (Prelude.Functor f, 89 | Data.ProtoLens.Field.HasField s "maybe'pattern'" a) => 90 | Lens.Family2.LensLike' f s a 91 | maybe'pattern' = Data.ProtoLens.Field.field @"maybe'pattern'" 92 | maybe'post :: 93 | forall f s a. 94 | (Prelude.Functor f, 95 | Data.ProtoLens.Field.HasField s "maybe'post" a) => 96 | Lens.Family2.LensLike' f s a 97 | maybe'post = Data.ProtoLens.Field.field @"maybe'post" 98 | maybe'put :: 99 | forall f s a. 100 | (Prelude.Functor f, 101 | Data.ProtoLens.Field.HasField s "maybe'put" a) => 102 | Lens.Family2.LensLike' f s a 103 | maybe'put = Data.ProtoLens.Field.field @"maybe'put" 104 | patch :: 105 | forall f s a. 106 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "patch" a) => 107 | Lens.Family2.LensLike' f s a 108 | patch = Data.ProtoLens.Field.field @"patch" 109 | path :: 110 | forall f s a. 111 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "path" a) => 112 | Lens.Family2.LensLike' f s a 113 | path = Data.ProtoLens.Field.field @"path" 114 | post :: 115 | forall f s a. 116 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "post" a) => 117 | Lens.Family2.LensLike' f s a 118 | post = Data.ProtoLens.Field.field @"post" 119 | put :: 120 | forall f s a. 121 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "put" a) => 122 | Lens.Family2.LensLike' f s a 123 | put = Data.ProtoLens.Field.field @"put" 124 | rules :: 125 | forall f s a. 126 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "rules" a) => 127 | Lens.Family2.LensLike' f s a 128 | rules = Data.ProtoLens.Field.field @"rules" 129 | selector :: 130 | forall f s a. 131 | (Prelude.Functor f, 132 | Data.ProtoLens.Field.HasField s "selector" a) => 133 | Lens.Family2.LensLike' f s a 134 | selector = Data.ProtoLens.Field.field @"selector" 135 | vec'additionalBindings :: 136 | forall f s a. 137 | (Prelude.Functor f, 138 | Data.ProtoLens.Field.HasField s "vec'additionalBindings" a) => 139 | Lens.Family2.LensLike' f s a 140 | vec'additionalBindings 141 | = Data.ProtoLens.Field.field @"vec'additionalBindings" 142 | vec'rules :: 143 | forall f s a. 144 | (Prelude.Functor f, 145 | Data.ProtoLens.Field.HasField s "vec'rules" a) => 146 | Lens.Family2.LensLike' f s a 147 | vec'rules = Data.ProtoLens.Field.field @"vec'rules" -------------------------------------------------------------------------------- /gen/Proto/Google/Protobuf/Timestamp.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from google/protobuf/timestamp.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Google.Protobuf.Timestamp ( 7 | Timestamp() 8 | ) where 9 | import qualified Data.ProtoLens.Runtime.Control.DeepSeq as Control.DeepSeq 10 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Prism as Data.ProtoLens.Prism 11 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 12 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 13 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 14 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 15 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 16 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 19 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 20 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 21 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 22 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 23 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 24 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 25 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 26 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 27 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 28 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 29 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 30 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 31 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 32 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 33 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 34 | {- | Fields : 35 | 36 | * 'Proto.Google.Protobuf.Timestamp_Fields.seconds' @:: Lens' Timestamp Data.Int.Int64@ 37 | * 'Proto.Google.Protobuf.Timestamp_Fields.nanos' @:: Lens' Timestamp Data.Int.Int32@ -} 38 | data Timestamp 39 | = Timestamp'_constructor {_Timestamp'seconds :: !Data.Int.Int64, 40 | _Timestamp'nanos :: !Data.Int.Int32, 41 | _Timestamp'_unknownFields :: !Data.ProtoLens.FieldSet} 42 | deriving stock (Prelude.Eq, Prelude.Ord) 43 | instance Prelude.Show Timestamp where 44 | showsPrec _ __x __s 45 | = Prelude.showChar 46 | '{' 47 | (Prelude.showString 48 | (Data.ProtoLens.showMessageShort __x) (Prelude.showChar '}' __s)) 49 | instance Data.ProtoLens.Field.HasField Timestamp "seconds" Data.Int.Int64 where 50 | fieldOf _ 51 | = (Prelude..) 52 | (Lens.Family2.Unchecked.lens 53 | _Timestamp'seconds (\ x__ y__ -> x__ {_Timestamp'seconds = y__})) 54 | Prelude.id 55 | instance Data.ProtoLens.Field.HasField Timestamp "nanos" Data.Int.Int32 where 56 | fieldOf _ 57 | = (Prelude..) 58 | (Lens.Family2.Unchecked.lens 59 | _Timestamp'nanos (\ x__ y__ -> x__ {_Timestamp'nanos = y__})) 60 | Prelude.id 61 | instance Data.ProtoLens.Message Timestamp where 62 | messageName _ = Data.Text.pack "google.protobuf.Timestamp" 63 | packedMessageDescriptor _ 64 | = "\n\ 65 | \\tTimestamp\DC2\CAN\n\ 66 | \\aseconds\CAN\SOH \SOH(\ETXR\aseconds\DC2\DC4\n\ 67 | \\ENQnanos\CAN\STX \SOH(\ENQR\ENQnanos" 68 | packedFileDescriptor _ = packedFileDescriptor 69 | fieldsByTag 70 | = let 71 | seconds__field_descriptor 72 | = Data.ProtoLens.FieldDescriptor 73 | "seconds" 74 | (Data.ProtoLens.ScalarField Data.ProtoLens.Int64Field :: 75 | Data.ProtoLens.FieldTypeDescriptor Data.Int.Int64) 76 | (Data.ProtoLens.PlainField 77 | Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"seconds")) :: 78 | Data.ProtoLens.FieldDescriptor Timestamp 79 | nanos__field_descriptor 80 | = Data.ProtoLens.FieldDescriptor 81 | "nanos" 82 | (Data.ProtoLens.ScalarField Data.ProtoLens.Int32Field :: 83 | Data.ProtoLens.FieldTypeDescriptor Data.Int.Int32) 84 | (Data.ProtoLens.PlainField 85 | Data.ProtoLens.Optional (Data.ProtoLens.Field.field @"nanos")) :: 86 | Data.ProtoLens.FieldDescriptor Timestamp 87 | in 88 | Data.Map.fromList 89 | [(Data.ProtoLens.Tag 1, seconds__field_descriptor), 90 | (Data.ProtoLens.Tag 2, nanos__field_descriptor)] 91 | unknownFields 92 | = Lens.Family2.Unchecked.lens 93 | _Timestamp'_unknownFields 94 | (\ x__ y__ -> x__ {_Timestamp'_unknownFields = y__}) 95 | defMessage 96 | = Timestamp'_constructor 97 | {_Timestamp'seconds = Data.ProtoLens.fieldDefault, 98 | _Timestamp'nanos = Data.ProtoLens.fieldDefault, 99 | _Timestamp'_unknownFields = []} 100 | parseMessage 101 | = let 102 | loop :: Timestamp -> Data.ProtoLens.Encoding.Bytes.Parser Timestamp 103 | loop x 104 | = do end <- Data.ProtoLens.Encoding.Bytes.atEnd 105 | if end then 106 | do (let missing = [] 107 | in 108 | if Prelude.null missing then 109 | Prelude.return () 110 | else 111 | Prelude.fail 112 | ((Prelude.++) 113 | "Missing required fields: " 114 | (Prelude.show (missing :: [Prelude.String])))) 115 | Prelude.return 116 | (Lens.Family2.over 117 | Data.ProtoLens.unknownFields (\ !t -> Prelude.reverse t) x) 118 | else 119 | do tag <- Data.ProtoLens.Encoding.Bytes.getVarInt 120 | case tag of 121 | 8 -> do y <- (Data.ProtoLens.Encoding.Bytes.) 122 | (Prelude.fmap 123 | Prelude.fromIntegral 124 | Data.ProtoLens.Encoding.Bytes.getVarInt) 125 | "seconds" 126 | loop (Lens.Family2.set (Data.ProtoLens.Field.field @"seconds") y x) 127 | 16 128 | -> do y <- (Data.ProtoLens.Encoding.Bytes.) 129 | (Prelude.fmap 130 | Prelude.fromIntegral 131 | Data.ProtoLens.Encoding.Bytes.getVarInt) 132 | "nanos" 133 | loop (Lens.Family2.set (Data.ProtoLens.Field.field @"nanos") y x) 134 | wire 135 | -> do !y <- Data.ProtoLens.Encoding.Wire.parseTaggedValueFromWire 136 | wire 137 | loop 138 | (Lens.Family2.over 139 | Data.ProtoLens.unknownFields (\ !t -> (:) y t) x) 140 | in 141 | (Data.ProtoLens.Encoding.Bytes.) 142 | (do loop Data.ProtoLens.defMessage) "Timestamp" 143 | buildMessage 144 | = \ _x 145 | -> (Data.Monoid.<>) 146 | (let 147 | _v = Lens.Family2.view (Data.ProtoLens.Field.field @"seconds") _x 148 | in 149 | if (Prelude.==) _v Data.ProtoLens.fieldDefault then 150 | Data.Monoid.mempty 151 | else 152 | (Data.Monoid.<>) 153 | (Data.ProtoLens.Encoding.Bytes.putVarInt 8) 154 | ((Prelude..) 155 | Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral _v)) 156 | ((Data.Monoid.<>) 157 | (let 158 | _v = Lens.Family2.view (Data.ProtoLens.Field.field @"nanos") _x 159 | in 160 | if (Prelude.==) _v Data.ProtoLens.fieldDefault then 161 | Data.Monoid.mempty 162 | else 163 | (Data.Monoid.<>) 164 | (Data.ProtoLens.Encoding.Bytes.putVarInt 16) 165 | ((Prelude..) 166 | Data.ProtoLens.Encoding.Bytes.putVarInt Prelude.fromIntegral _v)) 167 | (Data.ProtoLens.Encoding.Wire.buildFieldSet 168 | (Lens.Family2.view Data.ProtoLens.unknownFields _x))) 169 | instance Control.DeepSeq.NFData Timestamp where 170 | rnf 171 | = \ x__ 172 | -> Control.DeepSeq.deepseq 173 | (_Timestamp'_unknownFields x__) 174 | (Control.DeepSeq.deepseq 175 | (_Timestamp'seconds x__) 176 | (Control.DeepSeq.deepseq (_Timestamp'nanos x__) ())) 177 | packedFileDescriptor :: Data.ByteString.ByteString 178 | packedFileDescriptor 179 | = "\n\ 180 | \\USgoogle/protobuf/timestamp.proto\DC2\SIgoogle.protobuf\";\n\ 181 | \\tTimestamp\DC2\CAN\n\ 182 | \\aseconds\CAN\SOH \SOH(\ETXR\aseconds\DC2\DC4\n\ 183 | \\ENQnanos\CAN\STX \SOH(\ENQR\ENQnanosB~\n\ 184 | \\DC3com.google.protobufB\SOTimestampProtoP\SOHZ+github.com/golang/protobuf/ptypes/timestamp\248\SOH\SOH\162\STX\ETXGPB\170\STX\RSGoogle.Protobuf.WellKnownTypesJ\217-\n\ 185 | \\a\DC2\ENQ\RS\NUL\137\SOH\SOH\n\ 186 | \\204\f\n\ 187 | \\SOH\f\DC2\ETX\RS\NUL\DC22\193\f Protocol Buffers - Google's data interchange format\n\ 188 | \ Copyright 2008 Google Inc. All rights reserved.\n\ 189 | \ https://developers.google.com/protocol-buffers/\n\ 190 | \\n\ 191 | \ Redistribution and use in source and binary forms, with or without\n\ 192 | \ modification, are permitted provided that the following conditions are\n\ 193 | \ met:\n\ 194 | \\n\ 195 | \ * Redistributions of source code must retain the above copyright\n\ 196 | \ notice, this list of conditions and the following disclaimer.\n\ 197 | \ * Redistributions in binary form must reproduce the above\n\ 198 | \ copyright notice, this list of conditions and the following disclaimer\n\ 199 | \ in the documentation and/or other materials provided with the\n\ 200 | \ distribution.\n\ 201 | \ * Neither the name of Google Inc. nor the names of its\n\ 202 | \ contributors may be used to endorse or promote products derived from\n\ 203 | \ this software without specific prior written permission.\n\ 204 | \\n\ 205 | \ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\ 206 | \ \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n\ 207 | \ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\ 208 | \ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n\ 209 | \ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n\ 210 | \ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n\ 211 | \ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\ 212 | \ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n\ 213 | \ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\ 214 | \ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\ 215 | \ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\ 216 | \\n\ 217 | \\b\n\ 218 | \\SOH\STX\DC2\ETX \NUL\CAN\n\ 219 | \\b\n\ 220 | \\SOH\b\DC2\ETX\"\NUL;\n\ 221 | \\t\n\ 222 | \\STX\b%\DC2\ETX\"\NUL;\n\ 223 | \\b\n\ 224 | \\SOH\b\DC2\ETX#\NUL\US\n\ 225 | \\t\n\ 226 | \\STX\b\US\DC2\ETX#\NUL\US\n\ 227 | \\b\n\ 228 | \\SOH\b\DC2\ETX$\NULB\n\ 229 | \\t\n\ 230 | \\STX\b\v\DC2\ETX$\NULB\n\ 231 | \\b\n\ 232 | \\SOH\b\DC2\ETX%\NUL,\n\ 233 | \\t\n\ 234 | \\STX\b\SOH\DC2\ETX%\NUL,\n\ 235 | \\b\n\ 236 | \\SOH\b\DC2\ETX&\NUL/\n\ 237 | \\t\n\ 238 | \\STX\b\b\DC2\ETX&\NUL/\n\ 239 | \\b\n\ 240 | \\SOH\b\DC2\ETX'\NUL\"\n\ 241 | \\t\n\ 242 | \\STX\b\n\ 243 | \\DC2\ETX'\NUL\"\n\ 244 | \\b\n\ 245 | \\SOH\b\DC2\ETX(\NUL!\n\ 246 | \\t\n\ 247 | \\STX\b$\DC2\ETX(\NUL!\n\ 248 | \\243\ESC\n\ 249 | \\STX\EOT\NUL\DC2\ENQ~\NUL\137\SOH\SOH\SUB\229\ESC A Timestamp represents a point in time independent of any time zone or local\n\ 250 | \ calendar, encoded as a count of seconds and fractions of seconds at\n\ 251 | \ nanosecond resolution. The count is relative to an epoch at UTC midnight on\n\ 252 | \ January 1, 1970, in the proleptic Gregorian calendar which extends the\n\ 253 | \ Gregorian calendar backwards to year one.\n\ 254 | \\n\ 255 | \ All minutes are 60 seconds long. Leap seconds are \"smeared\" so that no leap\n\ 256 | \ second table is needed for interpretation, using a [24-hour linear\n\ 257 | \ smear](https://developers.google.com/time/smear).\n\ 258 | \\n\ 259 | \ The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n\ 260 | \ restricting to that range, we ensure that we can convert to and from [RFC\n\ 261 | \ 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\ 262 | \\n\ 263 | \ # Examples\n\ 264 | \\n\ 265 | \ Example 1: Compute Timestamp from POSIX `time()`.\n\ 266 | \\n\ 267 | \ Timestamp timestamp;\n\ 268 | \ timestamp.set_seconds(time(NULL));\n\ 269 | \ timestamp.set_nanos(0);\n\ 270 | \\n\ 271 | \ Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\ 272 | \\n\ 273 | \ struct timeval tv;\n\ 274 | \ gettimeofday(&tv, NULL);\n\ 275 | \\n\ 276 | \ Timestamp timestamp;\n\ 277 | \ timestamp.set_seconds(tv.tv_sec);\n\ 278 | \ timestamp.set_nanos(tv.tv_usec * 1000);\n\ 279 | \\n\ 280 | \ Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\ 281 | \\n\ 282 | \ FILETIME ft;\n\ 283 | \ GetSystemTimeAsFileTime(&ft);\n\ 284 | \ UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\ 285 | \\n\ 286 | \ // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n\ 287 | \ // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n\ 288 | \ Timestamp timestamp;\n\ 289 | \ timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n\ 290 | \ timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\ 291 | \\n\ 292 | \ Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\ 293 | \\n\ 294 | \ long millis = System.currentTimeMillis();\n\ 295 | \\n\ 296 | \ Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n\ 297 | \ .setNanos((int) ((millis % 1000) * 1000000)).build();\n\ 298 | \\n\ 299 | \\n\ 300 | \ Example 5: Compute Timestamp from current time in Python.\n\ 301 | \\n\ 302 | \ timestamp = Timestamp()\n\ 303 | \ timestamp.GetCurrentTime()\n\ 304 | \\n\ 305 | \ # JSON Mapping\n\ 306 | \\n\ 307 | \ In JSON format, the Timestamp type is encoded as a string in the\n\ 308 | \ [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n\ 309 | \ format is \"{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z\"\n\ 310 | \ where {year} is always expressed using four digits while {month}, {day},\n\ 311 | \ {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n\ 312 | \ seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n\ 313 | \ are optional. The \"Z\" suffix indicates the timezone (\"UTC\"); the timezone\n\ 314 | \ is required. A proto3 JSON serializer should always use UTC (as indicated by\n\ 315 | \ \"Z\") when printing the Timestamp type and a proto3 JSON parser should be\n\ 316 | \ able to accept both UTC and other timezones (as indicated by an offset).\n\ 317 | \\n\ 318 | \ For example, \"2017-01-15T01:30:15.01Z\" encodes 15.01 seconds past\n\ 319 | \ 01:30 UTC on January 15, 2017.\n\ 320 | \\n\ 321 | \ In JavaScript, one can convert a Date object to this format using the\n\ 322 | \ standard\n\ 323 | \ [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n\ 324 | \ method. In Python, a standard `datetime.datetime` object can be converted\n\ 325 | \ to this format using\n\ 326 | \ [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n\ 327 | \ the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use\n\ 328 | \ the Joda Time's [`ISODateTimeFormat.dateTime()`](\n\ 329 | \ http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n\ 330 | \ ) to obtain a formatter capable of generating timestamps in this format.\n\ 331 | \\n\ 332 | \\n\ 333 | \\n\ 334 | \\n\ 335 | \\n\ 336 | \\ETX\EOT\NUL\SOH\DC2\ETX~\b\DC1\n\ 337 | \\157\SOH\n\ 338 | \\EOT\EOT\NUL\STX\NUL\DC2\EOT\130\SOH\STX\DC4\SUB\142\SOH Represents seconds of UTC time since Unix epoch\n\ 339 | \ 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n\ 340 | \ 9999-12-31T23:59:59Z inclusive.\n\ 341 | \\n\ 342 | \\r\n\ 343 | \\ENQ\EOT\NUL\STX\NUL\ENQ\DC2\EOT\130\SOH\STX\a\n\ 344 | \\r\n\ 345 | \\ENQ\EOT\NUL\STX\NUL\SOH\DC2\EOT\130\SOH\b\SI\n\ 346 | \\r\n\ 347 | \\ENQ\EOT\NUL\STX\NUL\ETX\DC2\EOT\130\SOH\DC2\DC3\n\ 348 | \\229\SOH\n\ 349 | \\EOT\EOT\NUL\STX\SOH\DC2\EOT\136\SOH\STX\DC2\SUB\214\SOH Non-negative fractions of a second at nanosecond resolution. Negative\n\ 350 | \ second values with fractions must still have non-negative nanos values\n\ 351 | \ that count forward in time. Must be from 0 to 999,999,999\n\ 352 | \ inclusive.\n\ 353 | \\n\ 354 | \\r\n\ 355 | \\ENQ\EOT\NUL\STX\SOH\ENQ\DC2\EOT\136\SOH\STX\a\n\ 356 | \\r\n\ 357 | \\ENQ\EOT\NUL\STX\SOH\SOH\DC2\EOT\136\SOH\b\r\n\ 358 | \\r\n\ 359 | \\ENQ\EOT\NUL\STX\SOH\ETX\DC2\EOT\136\SOH\DLE\DC1b\ACKproto3" -------------------------------------------------------------------------------- /gen/Proto/Google/Protobuf/Timestamp_Fields.hs: -------------------------------------------------------------------------------- 1 | {- This file was auto-generated from google/protobuf/timestamp.proto by the proto-lens-protoc program. -} 2 | {-# LANGUAGE ScopedTypeVariables, DataKinds, TypeFamilies, UndecidableInstances, GeneralizedNewtypeDeriving, MultiParamTypeClasses, FlexibleContexts, FlexibleInstances, PatternSynonyms, MagicHash, NoImplicitPrelude, DataKinds, BangPatterns, TypeApplications, OverloadedStrings, DerivingStrategies#-} 3 | {-# OPTIONS_GHC -Wno-unused-imports#-} 4 | {-# OPTIONS_GHC -Wno-duplicate-exports#-} 5 | {-# OPTIONS_GHC -Wno-dodgy-exports#-} 6 | module Proto.Google.Protobuf.Timestamp_Fields where 7 | import qualified Data.ProtoLens.Runtime.Prelude as Prelude 8 | import qualified Data.ProtoLens.Runtime.Data.Int as Data.Int 9 | import qualified Data.ProtoLens.Runtime.Data.Monoid as Data.Monoid 10 | import qualified Data.ProtoLens.Runtime.Data.Word as Data.Word 11 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens as Data.ProtoLens 12 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Bytes as Data.ProtoLens.Encoding.Bytes 13 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Growing as Data.ProtoLens.Encoding.Growing 14 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Parser.Unsafe as Data.ProtoLens.Encoding.Parser.Unsafe 15 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Encoding.Wire as Data.ProtoLens.Encoding.Wire 16 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Field as Data.ProtoLens.Field 17 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Message.Enum as Data.ProtoLens.Message.Enum 18 | import qualified Data.ProtoLens.Runtime.Data.ProtoLens.Service.Types as Data.ProtoLens.Service.Types 19 | import qualified Data.ProtoLens.Runtime.Lens.Family2 as Lens.Family2 20 | import qualified Data.ProtoLens.Runtime.Lens.Family2.Unchecked as Lens.Family2.Unchecked 21 | import qualified Data.ProtoLens.Runtime.Data.Text as Data.Text 22 | import qualified Data.ProtoLens.Runtime.Data.Map as Data.Map 23 | import qualified Data.ProtoLens.Runtime.Data.ByteString as Data.ByteString 24 | import qualified Data.ProtoLens.Runtime.Data.ByteString.Char8 as Data.ByteString.Char8 25 | import qualified Data.ProtoLens.Runtime.Data.Text.Encoding as Data.Text.Encoding 26 | import qualified Data.ProtoLens.Runtime.Data.Vector as Data.Vector 27 | import qualified Data.ProtoLens.Runtime.Data.Vector.Generic as Data.Vector.Generic 28 | import qualified Data.ProtoLens.Runtime.Data.Vector.Unboxed as Data.Vector.Unboxed 29 | import qualified Data.ProtoLens.Runtime.Text.Read as Text.Read 30 | nanos :: 31 | forall f s a. 32 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "nanos" a) => 33 | Lens.Family2.LensLike' f s a 34 | nanos = Data.ProtoLens.Field.field @"nanos" 35 | seconds :: 36 | forall f s a. 37 | (Prelude.Functor f, Data.ProtoLens.Field.HasField s "seconds" a) => 38 | Lens.Family2.LensLike' f s a 39 | seconds = Data.ProtoLens.Field.field @"seconds" -------------------------------------------------------------------------------- /lightstep-haskell.cabal: -------------------------------------------------------------------------------- 1 | cabal-version: 2.4 2 | 3 | name: lightstep-haskell 4 | version: 0.10.4 5 | synopsis: LightStep OpenTracing client library 6 | description: LightStep OpenTracing client library. Uses GRPC transport via proto-lens. 7 | category: Tools 8 | homepage: https://github.com/ethercrow/lightstep-haskell#readme 9 | bug-reports: https://github.com/ethercrow/lightstep-haskell/issues 10 | maintainer: Dmitry Ivanov 11 | license: Apache-2.0 12 | license-file: LICENSE 13 | build-type: Simple 14 | 15 | source-repository head 16 | type: git 17 | location: https://github.com/ethercrow/lightstep-haskell 18 | 19 | common options 20 | default-extensions: 21 | BangPatterns 22 | BlockArguments 23 | DataKinds 24 | FlexibleInstances 25 | LambdaCase 26 | MultiParamTypeClasses 27 | MultiWayIf 28 | NamedFieldPuns 29 | NumericUnderscores 30 | RecordWildCards 31 | ScopedTypeVariables 32 | TupleSections 33 | TypeApplications 34 | ViewPatterns 35 | ghc-options: 36 | -Wall 37 | -Wcompat 38 | -Widentities 39 | -Wincomplete-record-updates 40 | -Wincomplete-uni-patterns 41 | -Wpartial-fields 42 | -Wredundant-constraints 43 | -fhide-source-paths 44 | -ferror-spans 45 | -freverse-errors 46 | default-language: Haskell2010 47 | 48 | library 49 | import: options 50 | exposed-modules: 51 | LightStep.Config 52 | LightStep.HighLevel.IO 53 | LightStep.Internal.Debug 54 | LightStep.LowLevel 55 | LightStep.Diagnostics 56 | LightStep.Propagation 57 | Network.Wai.Middleware.LightStep 58 | other-modules: 59 | Paths_lightstep_haskell 60 | Proto.Collector 61 | Proto.Collector_Fields 62 | Proto.Google.Api.Annotations 63 | Proto.Google.Api.Http 64 | Proto.Google.Protobuf.Timestamp 65 | Proto.Google.Protobuf.Timestamp_Fields 66 | autogen-modules: 67 | Paths_lightstep_haskell 68 | hs-source-dirs: 69 | src 70 | gen 71 | build-depends: 72 | base >=4.12 && <5 73 | , async 74 | , bytestring 75 | , chronos 76 | , containers 77 | , hashable 78 | , http-types 79 | , http2-client >= 0.9.0.0 80 | , http2-client-grpc >= 0.8.0.0 81 | , http2-grpc-proto-lens >= 0.1.0.0 82 | , lens 83 | , mtl 84 | , proto-lens >= 0.5.1.0 85 | , proto-lens-protobuf-types >= 0.5.0.0 86 | , proto-lens-runtime >= 0.5.0.0 87 | , random >= 1.2 88 | , exceptions 89 | , stm 90 | , text 91 | , text-show 92 | , transformers 93 | , unordered-containers 94 | , wai 95 | 96 | flag examples 97 | description: Build example executables 98 | default: False 99 | 100 | common example 101 | if flag(examples) 102 | buildable: True 103 | else 104 | buildable: False 105 | 106 | executable lightstep-haskell-example 107 | import: options, example 108 | ghc-options: 109 | -threaded 110 | -rtsopts 111 | -with-rtsopts=-N 112 | main-is: Main.hs 113 | hs-source-dirs: 114 | examples/readme 115 | build-depends: 116 | base >=4.9 && <5 117 | , async 118 | , http2-client 119 | , lightstep-haskell 120 | , text 121 | 122 | executable lightstep-haskell-wai-example 123 | import: options, example 124 | ghc-options: 125 | -threaded 126 | -rtsopts 127 | "-with-rtsopts=-N -T -s" 128 | main-is: Main.hs 129 | hs-source-dirs: 130 | examples/wai 131 | build-depends: 132 | base >=4.9 && <5 133 | , lightstep-haskell 134 | , http-types 135 | , text 136 | , wai 137 | , warp 138 | , bytestring 139 | 140 | executable lightstep-haskell-req-example 141 | import: options, example 142 | ghc-options: 143 | -threaded 144 | -rtsopts 145 | -with-rtsopts=-N 146 | main-is: Main.hs 147 | hs-source-dirs: 148 | examples/req 149 | build-depends: 150 | base >=4.9 && <5 151 | , lightstep-haskell 152 | , case-insensitive 153 | , http-types 154 | , text 155 | , req >= 3.0.0 156 | , unordered-containers 157 | 158 | executable lightstep-haskell-stress-test 159 | import: options 160 | ghc-options: 161 | -threaded 162 | -rtsopts 163 | "-with-rtsopts=-N -T -s" 164 | main-is: Main.hs 165 | hs-source-dirs: 166 | stress-test 167 | build-depends: 168 | base >=4.9 && <5 169 | , lightstep-haskell 170 | , text 171 | , async 172 | 173 | test-suite unit 174 | import: options 175 | type: exitcode-stdio-1.0 176 | main-is: Main.hs 177 | other-modules: 178 | TestPropagation 179 | hs-source-dirs: 180 | unit-test 181 | build-depends: 182 | base, 183 | deepseq, 184 | lens, 185 | tasty, 186 | tasty-quickcheck, 187 | tasty-hunit, 188 | tasty-discover, 189 | lightstep-haskell, 190 | proto-lens >= 0.5.1.0, 191 | proto-lens-protobuf-types >= 0.5.0.0, 192 | proto-lens-runtime >= 0.5.0.0 193 | -------------------------------------------------------------------------------- /propagation-test/go.mod: -------------------------------------------------------------------------------- 1 | module tracing_go_client 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/lightstep/lightstep-tracer-go v0.18.1 7 | github.com/opentracing/opentracing-go v1.0.2 8 | ) 9 | -------------------------------------------------------------------------------- /propagation-test/okhttp_client.sc: -------------------------------------------------------------------------------- 1 | // A tracer example using lightstep-tracer-jre and okhttp client 2 | // 3 | // See https://ammonite.io/ on how to install the ammonite repl 4 | // 5 | // $ LIGHTSTEP_TOKEN= amm okhttp_client.sc 6 | 7 | 8 | import $ivy.`com.lightstep.tracer:lightstep-tracer-jre:0.18.0` 9 | import $ivy.`com.lightstep.tracer:tracer-grpc:0.19.0` 10 | import $ivy.`io.grpc:grpc-netty-shaded:1.23.0` 11 | import $ivy.`com.squareup.okhttp3:okhttp:4.3.1` 12 | import $ivy.`io.opentracing.contrib:opentracing-okhttp3:3.0.0` 13 | 14 | import scala.util.{Try, Success, Failure} 15 | 16 | import com.lightstep.tracer.jre.JRETracer 17 | import com.lightstep.tracer.shared.Options.OptionsBuilder 18 | 19 | import okhttp3.OkHttpClient 20 | import okhttp3.Request 21 | 22 | import io.opentracing.Span; 23 | import io.opentracing.Tracer; 24 | import io.opentracing.propagation.Format 25 | import io.opentracing.propagation.TextMap 26 | import io.opentracing.contrib.okhttp3.TracingCallFactory 27 | 28 | 29 | val lightstepToken = sys.env.get("LIGHTSTEP_TOKEN") 30 | .getOrElse { 31 | println("LIGHTSTEP_TOKEN not found") 32 | sys.exit(1) 33 | } 34 | 35 | val tracer = new JRETracer( 36 | new OptionsBuilder() 37 | .withAccessToken(lightstepToken) 38 | .withComponentName("hello-java-client") 39 | .build() 40 | ) 41 | 42 | val url = "http://localhost:8736/foo" 43 | 44 | val span = tracer.buildSpan("TestSpan").start() 45 | 46 | val okHttpClient = new OkHttpClient() 47 | val client = new TracingCallFactory(okHttpClient, tracer) 48 | 49 | val request = new Request.Builder().url(url).build(); 50 | 51 | Try(client.newCall(request).execute()) match { 52 | case Success(response) => 53 | println(response.code) 54 | println(response.body.string) 55 | case Failure(e) => println(e) 56 | } 57 | 58 | span.finish() 59 | tracer.flush(1000) 60 | -------------------------------------------------------------------------------- /propagation-test/propagation_client.go: -------------------------------------------------------------------------------- 1 | // A trivial LightStep Go tracer example. 2 | // 3 | // $ go build -o lightstep_trivial github.com/lightstep/lightstep-tracer-go/examples/trivial 4 | // $ ./lightstep_trivial --access_token=YOUR_ACCESS_TOKEN 5 | 6 | package main 7 | 8 | import ( 9 | "context" 10 | "fmt" 11 | logger "log" 12 | "net/http" 13 | "os" 14 | "time" 15 | 16 | "github.com/lightstep/lightstep-tracer-go" 17 | "github.com/opentracing/opentracing-go" 18 | "github.com/opentracing/opentracing-go/log" 19 | ) 20 | 21 | var accessToken = os.Getenv("LIGHTSTEP_TOKEN") 22 | 23 | func subRoutine(ctx context.Context) { 24 | trivialSpan, _ := opentracing.StartSpanFromContext(ctx, "test span") 25 | defer trivialSpan.Finish() 26 | trivialSpan.LogEvent("logged something") 27 | trivialSpan.LogFields(log.String("string_key", "some string value"), log.Object("trivialSpan", trivialSpan)) 28 | 29 | subSpan := opentracing.StartSpan( 30 | "child span", opentracing.ChildOf(trivialSpan.Context())) 31 | trivialSpan.LogFields(log.Int("int_key", 42), log.Object("subSpan", subSpan), 32 | log.String("time.eager", fmt.Sprint(time.Now())), 33 | log.Lazy(func(fv log.Encoder) { 34 | fv.EmitString("time.lazy", fmt.Sprint(time.Now())) 35 | })) 36 | defer subSpan.Finish() 37 | 38 | client := &http.Client{} 39 | 40 | req, err := http.NewRequest("GET", "http://localhost:8736", nil) 41 | 42 | carrier := opentracing.HTTPHeadersCarrier(req.Header) 43 | err = subSpan.Tracer().Inject( 44 | subSpan.Context(), opentracing.HTTPHeaders, carrier) 45 | 46 | if err != nil { 47 | print("failed to inject") 48 | } 49 | 50 | resp, err := client.Do(req) 51 | print(err) 52 | print(resp) 53 | } 54 | 55 | type LoggingRecorder struct { 56 | r lightstep.SpanRecorder 57 | } 58 | 59 | func (r *LoggingRecorder) RecordSpan(span lightstep.RawSpan) { 60 | logger.Printf("span traceID: %v spanID: %v parentID: %v Operation: %v \n", span.Context.TraceID, span.Context.SpanID, span.ParentSpanID, span.Operation) 61 | } 62 | 63 | func main() { 64 | loggableRecorder := &LoggingRecorder{} 65 | 66 | // Use LightStep as the global OpenTracing Tracer. 67 | opentracing.InitGlobalTracer(lightstep.NewTracer(lightstep.Options{ 68 | AccessToken: accessToken, 69 | Recorder: loggableRecorder, 70 | })) 71 | 72 | // Do something that's traced. 73 | subRoutine(context.Background()) 74 | 75 | // Force a flush before exit. 76 | lightstep.Flush(context.Background(), opentracing.GlobalTracer()) 77 | } 78 | -------------------------------------------------------------------------------- /propagation-test/python_client.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import urllib 4 | import opentracing 5 | import lightstep 6 | import os 7 | 8 | def before_sending_request(request): 9 | """Context manager creates Span and encodes the span's SpanContext into request. 10 | """ 11 | span = opentracing.tracer.start_span('Sending request') 12 | span.set_tag('server.http.url', request.get_full_url()) 13 | try: 14 | # Python 2 15 | host = request.get_host() 16 | except: 17 | # Python 3 18 | host = request.host 19 | 20 | if host: 21 | span.set_tag(opentracing.ext.tags.PEER_HOST_IPV4, host) 22 | 23 | carrier_dict = {} 24 | print("Injecting context\n trace id: ", span.context.trace_id) 25 | print(" span id: ", span.context.span_id) 26 | span.tracer.inject(span.context, opentracing.Format.HTTP_HEADERS, carrier_dict) 27 | for k, v in carrier_dict.items(): 28 | print(k, v) 29 | request.add_header(k, v) 30 | return span 31 | 32 | if __name__ == "__main__": 33 | opentracing.tracer = lightstep.Tracer( 34 | component_name='hello-python-client', 35 | access_token=os.environ['LIGHTSTEP_TOKEN']) 36 | 37 | with opentracing.tracer.start_active_span('TestSpan') as scope: 38 | scope.span.log_event('test message', payload={'life': 42}) 39 | 40 | url = 'http://localhost:8736/predictions' 41 | request = urllib.request.Request(url) 42 | client_span = before_sending_request(request) 43 | with opentracing.tracer.scope_manager.activate(client_span, True): 44 | response = urllib.request.urlopen(request) 45 | print(response.status) 46 | print(response.read().decode('utf8')) 47 | 48 | opentracing.tracer.flush() 49 | -------------------------------------------------------------------------------- /propagation-test/python_server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """Demonstrates a Trace distributed across multiple machines. 3 | 4 | A SpanContext's text representation is stored in the headers of an HTTP request. 5 | 6 | Runs two threads, starts a Trace in the client and passes the SpanContext to the server. 7 | """ 8 | 9 | import os 10 | import argparse 11 | import errno 12 | import socket 13 | import sys 14 | import threading 15 | 16 | from http.server import BaseHTTPRequestHandler, HTTPServer 17 | 18 | import opentracing 19 | import opentracing.ext.tags 20 | import lightstep 21 | from opentracing import Format 22 | from lightstep.b3_propagator import B3Propagator 23 | 24 | 25 | class RemoteHandler(BaseHTTPRequestHandler): 26 | """This handler receives the request from the client. 27 | """ 28 | 29 | def do_GET(self): 30 | server_span = before_answering_request(self, opentracing.tracer) 31 | with opentracing.tracer.scope_manager.activate(server_span, True): 32 | server_span.log_event('request received', self.path) 33 | 34 | self.send_response(200) 35 | self.send_header('Content-type', 'text/html') 36 | self.end_headers() 37 | self.wfile.write("Hello World!".encode("utf-8")) 38 | 39 | server_span.log_event('prepared response', self.path) 40 | 41 | 42 | def before_answering_request(handler, tracer): 43 | """Context manager creates a Span, using SpanContext encoded in handler if possible. 44 | """ 45 | operation = 'handle_request:' + handler.path 46 | carrier_dict = {} 47 | for k, v in handler.headers.items(): 48 | print('Incoming HEADER', k, v) 49 | carrier_dict[k] = v 50 | extracted_context = tracer.extract(opentracing.Format.HTTP_HEADERS, carrier_dict) 51 | 52 | span = None 53 | if extracted_context: 54 | span = tracer.start_span( 55 | operation_name=operation, 56 | child_of=extracted_context) 57 | else: 58 | print('ERROR: Context missing, starting new trace') 59 | global _exit_code 60 | _exit_code = errno.ENOMSG 61 | span = tracer.start_span(operation_name=operation) 62 | headers = ', '.join({k + '=' + v for k, v in handler.headers.items()}) 63 | span.log_event('extract_failed', headers) 64 | print('Could not extract context from http headers: ' + headers) 65 | 66 | host, port = handler.client_address 67 | if host: 68 | span.set_tag(opentracing.ext.tags.PEER_HOST_IPV4, host) 69 | if port: 70 | span.set_tag(opentracing.ext.tags.PEER_PORT, str(port)) 71 | 72 | return span 73 | 74 | 75 | def lightstep_tracer_from_args(): 76 | """Initializes lightstep from the commandline args. 77 | """ 78 | parser = argparse.ArgumentParser() 79 | parser.add_argument('--token', help='Your LightStep access token.', 80 | default='{your_access_token}') 81 | parser.add_argument('--host', help='The LightStep reporting service host to contact.', 82 | default='collector.lightstep.com') 83 | parser.add_argument('--port', help='The LightStep reporting service port.', 84 | type=int, default=443) 85 | parser.add_argument('--no_tls', help='Disable TLS for reporting', 86 | dest="no_tls", action='store_true') 87 | parser.add_argument('--component_name', help='The LightStep component name', 88 | default='TrivialExample') 89 | args = parser.parse_args() 90 | 91 | collector_encryption = 'tls' 92 | 93 | return lightstep.Tracer( 94 | component_name=args.component_name, 95 | access_token=os.environ['LIGHTSTEP_TOKEN'], 96 | collector_host=args.host, 97 | collector_port=args.port, 98 | collector_encryption=collector_encryption, 99 | ) 100 | 101 | 102 | if __name__ == '__main__': 103 | with lightstep_tracer_from_args() as tracer: 104 | opentracing.tracer = tracer 105 | 106 | opentracing.tracer.register_propagator(Format.TEXT_MAP, B3Propagator()) 107 | opentracing.tracer.register_propagator( 108 | Format.HTTP_HEADERS, B3Propagator() 109 | ) 110 | 111 | global _exit_code 112 | _exit_code = 0 113 | 114 | # Create a web server and define the handler to manage the incoming request 115 | server = HTTPServer(('', 8736), RemoteHandler) 116 | 117 | server.serve_forever() 118 | -------------------------------------------------------------------------------- /proto/collector.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package lightstep.collector; 4 | 5 | option go_package = "collectorpb"; 6 | option objc_class_prefix = "LSPB"; 7 | option java_multiple_files = true; 8 | option java_package = "com.lightstep.tracer.grpc"; 9 | 10 | import "google/protobuf/timestamp.proto"; 11 | import "google/api/annotations.proto"; 12 | 13 | message SpanContext { 14 | uint64 trace_id = 1 [jstype=JS_STRING]; 15 | uint64 span_id = 2 [jstype=JS_STRING]; 16 | map baggage = 3; 17 | } 18 | 19 | // Represent both tags and log fields. 20 | message KeyValue { 21 | string key = 1; 22 | oneof value { 23 | // Holds arbitrary string data; well-formed JSON strings should go in 24 | // json_value. 25 | string string_value = 2; 26 | int64 int_value = 3 [jstype=JS_STRING]; 27 | double double_value = 4; 28 | bool bool_value = 5; 29 | // Must be a well-formed JSON value. Truncated JSON should go in 30 | // string_value. Should not be used for tags. 31 | string json_value = 6; 32 | } 33 | } 34 | 35 | message Log { 36 | google.protobuf.Timestamp timestamp = 1; 37 | repeated KeyValue fields = 2; 38 | } 39 | 40 | message Reference { 41 | enum Relationship { 42 | CHILD_OF = 0; 43 | FOLLOWS_FROM = 1; 44 | } 45 | Relationship relationship = 1; 46 | SpanContext span_context = 2; 47 | } 48 | 49 | message Span { 50 | SpanContext span_context = 1; 51 | string operation_name = 2; 52 | repeated Reference references = 3; 53 | google.protobuf.Timestamp start_timestamp = 4; 54 | uint64 duration_micros = 5 [jstype=JS_STRING]; 55 | repeated KeyValue tags = 6; 56 | repeated Log logs = 7; 57 | } 58 | 59 | message Reporter { 60 | uint64 reporter_id = 1 [jstype=JS_STRING]; 61 | repeated KeyValue tags = 4; 62 | } 63 | 64 | message MetricsSample { 65 | string name = 1; 66 | oneof value { 67 | int64 int_value = 2 [jstype=JS_STRING]; 68 | double double_value = 3; 69 | } 70 | } 71 | 72 | message InternalMetrics { 73 | google.protobuf.Timestamp start_timestamp = 1; 74 | uint64 duration_micros = 2 [jstype=JS_STRING]; 75 | repeated Log logs = 3; 76 | repeated MetricsSample counts = 4; 77 | repeated MetricsSample gauges = 5; 78 | } 79 | 80 | message Auth { 81 | string access_token = 1; 82 | } 83 | 84 | message ReportRequest { 85 | Reporter reporter = 1; 86 | Auth auth = 2; 87 | repeated Span spans = 3; 88 | int64 timestamp_offset_micros = 5 [jstype=JS_STRING]; 89 | InternalMetrics internal_metrics = 6; 90 | } 91 | 92 | message Command { 93 | bool disable = 1; 94 | bool dev_mode = 2; 95 | } 96 | 97 | message ReportResponse { 98 | repeated Command commands = 1; 99 | google.protobuf.Timestamp receive_timestamp = 2; 100 | google.protobuf.Timestamp transmit_timestamp = 3; 101 | repeated string errors = 4; 102 | repeated string warnings = 5; 103 | repeated string infos = 6; 104 | } 105 | 106 | service CollectorService { 107 | rpc Report(ReportRequest) returns (ReportResponse) { 108 | option (google.api.http) = { 109 | post: "/api/v2/reports" 110 | body: "*" 111 | additional_bindings { 112 | get: "/api/v2/reports" 113 | } 114 | }; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /proto/google/api/annotations.proto: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015, Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | import "google/api/http.proto"; 20 | import "google/protobuf/descriptor.proto"; 21 | 22 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 23 | option java_multiple_files = true; 24 | option java_outer_classname = "AnnotationsProto"; 25 | option java_package = "com.google.api"; 26 | option objc_class_prefix = "GAPI"; 27 | 28 | extend google.protobuf.MethodOptions { 29 | // See `HttpRule`. 30 | HttpRule http = 72295728; 31 | } 32 | -------------------------------------------------------------------------------- /proto/google/api/http.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Google Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.api; 18 | 19 | option cc_enable_arenas = true; 20 | option go_package = "google.golang.org/genproto/googleapis/api/annotations;annotations"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "HttpProto"; 23 | option java_package = "com.google.api"; 24 | option objc_class_prefix = "GAPI"; 25 | 26 | 27 | // Defines the HTTP configuration for a service. It contains a list of 28 | // [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method 29 | // to one or more HTTP REST API methods. 30 | message Http { 31 | // A list of HTTP configuration rules that apply to individual API methods. 32 | // 33 | // **NOTE:** All service configuration rules follow "last one wins" order. 34 | repeated HttpRule rules = 1; 35 | } 36 | 37 | // `HttpRule` defines the mapping of an RPC method to one or more HTTP 38 | // REST APIs. The mapping determines what portions of the request 39 | // message are populated from the path, query parameters, or body of 40 | // the HTTP request. The mapping is typically specified as an 41 | // `google.api.http` annotation, see "google/api/annotations.proto" 42 | // for details. 43 | // 44 | // The mapping consists of a field specifying the path template and 45 | // method kind. The path template can refer to fields in the request 46 | // message, as in the example below which describes a REST GET 47 | // operation on a resource collection of messages: 48 | // 49 | // 50 | // service Messaging { 51 | // rpc GetMessage(GetMessageRequest) returns (Message) { 52 | // option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; 53 | // } 54 | // } 55 | // message GetMessageRequest { 56 | // message SubMessage { 57 | // string subfield = 1; 58 | // } 59 | // string message_id = 1; // mapped to the URL 60 | // SubMessage sub = 2; // `sub.subfield` is url-mapped 61 | // } 62 | // message Message { 63 | // string text = 1; // content of the resource 64 | // } 65 | // 66 | // The same http annotation can alternatively be expressed inside the 67 | // `GRPC API Configuration` YAML file. 68 | // 69 | // http: 70 | // rules: 71 | // - selector: .Messaging.GetMessage 72 | // get: /v1/messages/{message_id}/{sub.subfield} 73 | // 74 | // This definition enables an automatic, bidrectional mapping of HTTP 75 | // JSON to RPC. Example: 76 | // 77 | // HTTP | RPC 78 | // -----|----- 79 | // `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` 80 | // 81 | // In general, not only fields but also field paths can be referenced 82 | // from a path pattern. Fields mapped to the path pattern cannot be 83 | // repeated and must have a primitive (non-message) type. 84 | // 85 | // Any fields in the request message which are not bound by the path 86 | // pattern automatically become (optional) HTTP query 87 | // parameters. Assume the following definition of the request message: 88 | // 89 | // 90 | // message GetMessageRequest { 91 | // message SubMessage { 92 | // string subfield = 1; 93 | // } 94 | // string message_id = 1; // mapped to the URL 95 | // int64 revision = 2; // becomes a parameter 96 | // SubMessage sub = 3; // `sub.subfield` becomes a parameter 97 | // } 98 | // 99 | // 100 | // This enables a HTTP JSON to RPC mapping as below: 101 | // 102 | // HTTP | RPC 103 | // -----|----- 104 | // `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` 105 | // 106 | // Note that fields which are mapped to HTTP parameters must have a 107 | // primitive type or a repeated primitive type. Message types are not 108 | // allowed. In the case of a repeated type, the parameter can be 109 | // repeated in the URL, as in `...?param=A¶m=B`. 110 | // 111 | // For HTTP method kinds which allow a request body, the `body` field 112 | // specifies the mapping. Consider a REST update method on the 113 | // message resource collection: 114 | // 115 | // 116 | // service Messaging { 117 | // rpc UpdateMessage(UpdateMessageRequest) returns (Message) { 118 | // option (google.api.http) = { 119 | // put: "/v1/messages/{message_id}" 120 | // body: "message" 121 | // }; 122 | // } 123 | // } 124 | // message UpdateMessageRequest { 125 | // string message_id = 1; // mapped to the URL 126 | // Message message = 2; // mapped to the body 127 | // } 128 | // 129 | // 130 | // The following HTTP JSON to RPC mapping is enabled, where the 131 | // representation of the JSON in the request body is determined by 132 | // protos JSON encoding: 133 | // 134 | // HTTP | RPC 135 | // -----|----- 136 | // `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` 137 | // 138 | // The special name `*` can be used in the body mapping to define that 139 | // every field not bound by the path template should be mapped to the 140 | // request body. This enables the following alternative definition of 141 | // the update method: 142 | // 143 | // service Messaging { 144 | // rpc UpdateMessage(Message) returns (Message) { 145 | // option (google.api.http) = { 146 | // put: "/v1/messages/{message_id}" 147 | // body: "*" 148 | // }; 149 | // } 150 | // } 151 | // message Message { 152 | // string message_id = 1; 153 | // string text = 2; 154 | // } 155 | // 156 | // 157 | // The following HTTP JSON to RPC mapping is enabled: 158 | // 159 | // HTTP | RPC 160 | // -----|----- 161 | // `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` 162 | // 163 | // Note that when using `*` in the body mapping, it is not possible to 164 | // have HTTP parameters, as all fields not bound by the path end in 165 | // the body. This makes this option more rarely used in practice of 166 | // defining REST APIs. The common usage of `*` is in custom methods 167 | // which don't use the URL at all for transferring data. 168 | // 169 | // It is possible to define multiple HTTP methods for one RPC by using 170 | // the `additional_bindings` option. Example: 171 | // 172 | // service Messaging { 173 | // rpc GetMessage(GetMessageRequest) returns (Message) { 174 | // option (google.api.http) = { 175 | // get: "/v1/messages/{message_id}" 176 | // additional_bindings { 177 | // get: "/v1/users/{user_id}/messages/{message_id}" 178 | // } 179 | // }; 180 | // } 181 | // } 182 | // message GetMessageRequest { 183 | // string message_id = 1; 184 | // string user_id = 2; 185 | // } 186 | // 187 | // 188 | // This enables the following two alternative HTTP JSON to RPC 189 | // mappings: 190 | // 191 | // HTTP | RPC 192 | // -----|----- 193 | // `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` 194 | // `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` 195 | // 196 | // # Rules for HTTP mapping 197 | // 198 | // The rules for mapping HTTP path, query parameters, and body fields 199 | // to the request message are as follows: 200 | // 201 | // 1. The `body` field specifies either `*` or a field path, or is 202 | // omitted. If omitted, it assumes there is no HTTP body. 203 | // 2. Leaf fields (recursive expansion of nested messages in the 204 | // request) can be classified into three types: 205 | // (a) Matched in the URL template. 206 | // (b) Covered by body (if body is `*`, everything except (a) fields; 207 | // else everything under the body field) 208 | // (c) All other fields. 209 | // 3. URL query parameters found in the HTTP request are mapped to (c) fields. 210 | // 4. Any body sent with an HTTP request can contain only (b) fields. 211 | // 212 | // The syntax of the path template is as follows: 213 | // 214 | // Template = "/" Segments [ Verb ] ; 215 | // Segments = Segment { "/" Segment } ; 216 | // Segment = "*" | "**" | LITERAL | Variable ; 217 | // Variable = "{" FieldPath [ "=" Segments ] "}" ; 218 | // FieldPath = IDENT { "." IDENT } ; 219 | // Verb = ":" LITERAL ; 220 | // 221 | // The syntax `*` matches a single path segment. It follows the semantics of 222 | // [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 Simple String 223 | // Expansion. 224 | // 225 | // The syntax `**` matches zero or more path segments. It follows the semantics 226 | // of [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.3 Reserved 227 | // Expansion. NOTE: it must be the last segment in the path except the Verb. 228 | // 229 | // The syntax `LITERAL` matches literal text in the URL path. 230 | // 231 | // The syntax `Variable` matches the entire path as specified by its template; 232 | // this nested template must not contain further variables. If a variable 233 | // matches a single path segment, its template may be omitted, e.g. `{var}` 234 | // is equivalent to `{var=*}`. 235 | // 236 | // NOTE: the field paths in variables and in the `body` must not refer to 237 | // repeated fields or map fields. 238 | // 239 | // Use CustomHttpPattern to specify any HTTP method that is not included in the 240 | // `pattern` field, such as HEAD, or "*" to leave the HTTP method unspecified for 241 | // a given URL path rule. The wild-card rule is useful for services that provide 242 | // content to Web (HTML) clients. 243 | message HttpRule { 244 | // Selects methods to which this rule applies. 245 | // 246 | // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. 247 | string selector = 1; 248 | 249 | // Determines the URL pattern is matched by this rules. This pattern can be 250 | // used with any of the {get|put|post|delete|patch} methods. A custom method 251 | // can be defined using the 'custom' field. 252 | oneof pattern { 253 | // Used for listing and getting information about resources. 254 | string get = 2; 255 | 256 | // Used for updating a resource. 257 | string put = 3; 258 | 259 | // Used for creating a resource. 260 | string post = 4; 261 | 262 | // Used for deleting a resource. 263 | string delete = 5; 264 | 265 | // Used for updating a resource. 266 | string patch = 6; 267 | 268 | // Custom pattern is used for defining custom verbs. 269 | CustomHttpPattern custom = 8; 270 | } 271 | 272 | // The name of the request field whose value is mapped to the HTTP body, or 273 | // `*` for mapping all fields not captured by the path pattern to the HTTP 274 | // body. NOTE: the referred field must not be a repeated field and must be 275 | // present at the top-level of request message type. 276 | string body = 7; 277 | 278 | // Additional HTTP bindings for the selector. Nested bindings must 279 | // not contain an `additional_bindings` field themselves (that is, 280 | // the nesting may only be one level deep). 281 | repeated HttpRule additional_bindings = 11; 282 | } 283 | 284 | // A custom pattern is used for defining custom HTTP verb. 285 | message CustomHttpPattern { 286 | // The name of this custom HTTP verb. 287 | string kind = 1; 288 | 289 | // The path matched by this custom verb. 290 | string path = 2; 291 | } 292 | -------------------------------------------------------------------------------- /proto/google/protobuf/timestamp.proto: -------------------------------------------------------------------------------- 1 | // Protocol Buffers - Google's data interchange format 2 | // Copyright 2008 Google Inc. All rights reserved. 3 | // https://developers.google.com/protocol-buffers/ 4 | // 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are 7 | // met: 8 | // 9 | // * Redistributions of source code must retain the above copyright 10 | // notice, this list of conditions and the following disclaimer. 11 | // * Redistributions in binary form must reproduce the above 12 | // copyright notice, this list of conditions and the following disclaimer 13 | // in the documentation and/or other materials provided with the 14 | // distribution. 15 | // * Neither the name of Google Inc. nor the names of its 16 | // contributors may be used to endorse or promote products derived from 17 | // this software without specific prior written permission. 18 | // 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | syntax = "proto3"; 32 | 33 | package google.protobuf; 34 | 35 | option csharp_namespace = "Google.Protobuf.WellKnownTypes"; 36 | option cc_enable_arenas = true; 37 | option go_package = "github.com/golang/protobuf/ptypes/timestamp"; 38 | option java_package = "com.google.protobuf"; 39 | option java_outer_classname = "TimestampProto"; 40 | option java_multiple_files = true; 41 | option objc_class_prefix = "GPB"; 42 | 43 | // A Timestamp represents a point in time independent of any time zone or local 44 | // calendar, encoded as a count of seconds and fractions of seconds at 45 | // nanosecond resolution. The count is relative to an epoch at UTC midnight on 46 | // January 1, 1970, in the proleptic Gregorian calendar which extends the 47 | // Gregorian calendar backwards to year one. 48 | // 49 | // All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap 50 | // second table is needed for interpretation, using a [24-hour linear 51 | // smear](https://developers.google.com/time/smear). 52 | // 53 | // The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By 54 | // restricting to that range, we ensure that we can convert to and from [RFC 55 | // 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. 56 | // 57 | // # Examples 58 | // 59 | // Example 1: Compute Timestamp from POSIX `time()`. 60 | // 61 | // Timestamp timestamp; 62 | // timestamp.set_seconds(time(NULL)); 63 | // timestamp.set_nanos(0); 64 | // 65 | // Example 2: Compute Timestamp from POSIX `gettimeofday()`. 66 | // 67 | // struct timeval tv; 68 | // gettimeofday(&tv, NULL); 69 | // 70 | // Timestamp timestamp; 71 | // timestamp.set_seconds(tv.tv_sec); 72 | // timestamp.set_nanos(tv.tv_usec * 1000); 73 | // 74 | // Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. 75 | // 76 | // FILETIME ft; 77 | // GetSystemTimeAsFileTime(&ft); 78 | // UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; 79 | // 80 | // // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z 81 | // // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. 82 | // Timestamp timestamp; 83 | // timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); 84 | // timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); 85 | // 86 | // Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. 87 | // 88 | // long millis = System.currentTimeMillis(); 89 | // 90 | // Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) 91 | // .setNanos((int) ((millis % 1000) * 1000000)).build(); 92 | // 93 | // 94 | // Example 5: Compute Timestamp from current time in Python. 95 | // 96 | // timestamp = Timestamp() 97 | // timestamp.GetCurrentTime() 98 | // 99 | // # JSON Mapping 100 | // 101 | // In JSON format, the Timestamp type is encoded as a string in the 102 | // [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the 103 | // format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" 104 | // where {year} is always expressed using four digits while {month}, {day}, 105 | // {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional 106 | // seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), 107 | // are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone 108 | // is required. A proto3 JSON serializer should always use UTC (as indicated by 109 | // "Z") when printing the Timestamp type and a proto3 JSON parser should be 110 | // able to accept both UTC and other timezones (as indicated by an offset). 111 | // 112 | // For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past 113 | // 01:30 UTC on January 15, 2017. 114 | // 115 | // In JavaScript, one can convert a Date object to this format using the 116 | // standard 117 | // [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) 118 | // method. In Python, a standard `datetime.datetime` object can be converted 119 | // to this format using 120 | // [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with 121 | // the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use 122 | // the Joda Time's [`ISODateTimeFormat.dateTime()`]( 123 | // http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D 124 | // ) to obtain a formatter capable of generating timestamps in this format. 125 | // 126 | // 127 | message Timestamp { 128 | // Represents seconds of UTC time since Unix epoch 129 | // 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 130 | // 9999-12-31T23:59:59Z inclusive. 131 | int64 seconds = 1; 132 | 133 | // Non-negative fractions of a second at nanosecond resolution. Negative 134 | // second values with fractions must still have non-negative nanos values 135 | // that count forward in time. Must be from 0 to 999,999,999 136 | // inclusive. 137 | int32 nanos = 2; 138 | } 139 | -------------------------------------------------------------------------------- /src/LightStep/Config.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module LightStep.Config where 4 | 5 | import Control.Monad.IO.Class 6 | import Data.Foldable 7 | import Data.Maybe 8 | import qualified Data.Text as T 9 | import Network.HTTP2.Client 10 | import System.Environment 11 | import System.IO 12 | 13 | data Compression = NoCompression | GzipCompression 14 | 15 | data LightStepConfig 16 | = LightStepConfig 17 | { lsHostName :: HostName, 18 | lsPort :: PortNumber, 19 | lsToken :: T.Text, 20 | lsServiceName :: T.Text, 21 | lsGlobalTags :: [(T.Text, T.Text)], 22 | lsGracefulShutdownTimeoutSeconds :: Int, 23 | lsMinimumBatchSize :: Int, 24 | lsCompression :: Compression 25 | } 26 | 27 | lookupOneOfEnvs :: [String] -> IO (Maybe String) 28 | lookupOneOfEnvs names = asum <$> traverse lookupEnv names 29 | 30 | getEnvTagsWithPrefix :: T.Text -> IO [(T.Text, T.Text)] 31 | getEnvTagsWithPrefix prefix = 32 | mapMaybe unprefix <$> getEnvironment 33 | where 34 | unprefix ((T.stripPrefix prefix . T.pack) -> Just k, v) = Just (k, T.pack v) 35 | unprefix _ = Nothing 36 | 37 | getEnvConfig :: MonadIO m => m (Maybe LightStepConfig) 38 | getEnvConfig = liftIO $ do 39 | maybe_token_from_env <- lookupOneOfEnvs ["LIGHTSTEP_TOKEN", "LIGHTSTEP_ACCESS_TOKEN", "OPENTRACING_LIGHTSTEP_ACCESS_TOKEN"] 40 | global_tags <- getEnvTagsWithPrefix "OPENTRACING_TAG_" 41 | case maybe_token_from_env of 42 | Just t -> do 43 | host <- fromMaybe "ingest.lightstep.com" <$> lookupOneOfEnvs ["LIGHTSTEP_HOST", "OPENTRACING_LIGHTSTEP_COLLECTOR_HOST"] 44 | port <- maybe 443 read <$> lookupOneOfEnvs ["LIGHTSTEP_PORT", "OPENTRACING_LIGHTSTEP_COLLECTOR_PORT"] 45 | service <- fromMaybe "example-haskell-service" <$> lookupOneOfEnvs ["LIGHTSTEP_SERVICE", "OPENTRACING_LIGHTSTEP_COMPONENT_NAME"] 46 | pure $ Just $ LightStepConfig host port (T.pack t) (T.pack service) global_tags 5 1 GzipCompression 47 | Nothing -> do 48 | hPutStrLn stderr "LIGHTSTEP_ACCESS_TOKEN environment variable not defined" 49 | pure Nothing 50 | -------------------------------------------------------------------------------- /src/LightStep/Diagnostics.hs: -------------------------------------------------------------------------------- 1 | module LightStep.Diagnostics where 2 | 3 | import Control.Concurrent.STM 4 | import System.IO.Unsafe 5 | 6 | inc :: Int -> TVar Int -> IO () 7 | inc n var = atomically $ do 8 | value <- readTVar var 9 | writeTVar var $! value + n 10 | 11 | reconnectCountVar :: TVar Int 12 | reconnectCountVar = unsafePerformIO $ newTVarIO 0 13 | {-# NOINLINE reconnectCountVar #-} 14 | 15 | startedSpanCountVar :: TVar Int 16 | startedSpanCountVar = unsafePerformIO $ newTVarIO 0 17 | {-# NOINLINE startedSpanCountVar #-} 18 | 19 | finishedSpanCountVar :: TVar Int 20 | finishedSpanCountVar = unsafePerformIO $ newTVarIO 0 21 | {-# NOINLINE finishedSpanCountVar #-} 22 | 23 | droppedSpanCountVar :: TVar Int 24 | droppedSpanCountVar = unsafePerformIO $ newTVarIO 0 25 | {-# NOINLINE droppedSpanCountVar #-} 26 | 27 | reportedSpanCountVar :: TVar Int 28 | reportedSpanCountVar = unsafePerformIO $ newTVarIO 0 29 | {-# NOINLINE reportedSpanCountVar #-} 30 | 31 | rejectedSpanCountVar :: TVar Int 32 | rejectedSpanCountVar = unsafePerformIO $ newTVarIO 0 33 | {-# NOINLINE rejectedSpanCountVar #-} 34 | 35 | sentBatchesCountVar :: TVar Int 36 | sentBatchesCountVar = unsafePerformIO $ newTVarIO 0 37 | {-# NOINLINE sentBatchesCountVar #-} 38 | 39 | data Diagnostics 40 | = Diagnostics 41 | { diagReconnectCount :: !Int, 42 | diagStartedSpanCount :: !Int, 43 | diagFinishedSpanCount :: !Int, 44 | diagDroppedSpanCount :: !Int, 45 | diagReportedSpanCount :: !Int, 46 | diagRejectedSpanCount :: !Int, 47 | diagSentBatchesCount :: !Int 48 | } 49 | deriving (Show) 50 | 51 | getDiagnostics :: IO Diagnostics 52 | getDiagnostics = 53 | atomically $ 54 | Diagnostics 55 | <$> readTVar reconnectCountVar 56 | <*> readTVar startedSpanCountVar 57 | <*> readTVar finishedSpanCountVar 58 | <*> readTVar droppedSpanCountVar 59 | <*> readTVar reportedSpanCountVar 60 | <*> readTVar rejectedSpanCountVar 61 | <*> readTVar sentBatchesCountVar 62 | -------------------------------------------------------------------------------- /src/LightStep/HighLevel/IO.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module LightStep.HighLevel.IO 4 | ( module LightStep.HighLevel.IO, 5 | module LightStep.LowLevel, 6 | module LightStep.Config, 7 | SpanContext, 8 | ) 9 | where 10 | 11 | import Control.Concurrent 12 | import Control.Concurrent.Async 13 | import Control.Concurrent.STM 14 | import Control.Monad.Catch 15 | import Control.Lens 16 | import Control.Monad.Except 17 | import qualified Data.HashMap.Strict as HM 18 | import Data.Maybe 19 | import Data.ProtoLens.Message (defMessage) 20 | import qualified Data.Text as T 21 | import GHC.Conc 22 | import LightStep.Config 23 | import LightStep.Diagnostics 24 | import LightStep.Internal.Debug 25 | import LightStep.LowLevel 26 | import Proto.Collector 27 | import Proto.Collector_Fields 28 | import System.IO.Unsafe 29 | import System.Timeout 30 | import TextShow 31 | 32 | {-# NOINLINE globalSharedMutableSpanStacks #-} 33 | globalSharedMutableSpanStacks :: MVar (HM.HashMap ThreadId [Span]) 34 | globalSharedMutableSpanStacks = unsafePerformIO (newMVar mempty) 35 | 36 | data LogEntryKey = ErrorKind | Event | Message | Stack | Custom T.Text 37 | 38 | showLogEntryKey :: LogEntryKey -> T.Text 39 | showLogEntryKey ErrorKind = T.pack "error.kind" 40 | showLogEntryKey Event = T.pack "event" 41 | showLogEntryKey Message = T.pack "message" 42 | showLogEntryKey Stack = T.pack "stack" 43 | showLogEntryKey (Custom x) = x 44 | 45 | withSpan :: forall m a. MonadIO m => MonadMask m => T.Text -> m a -> m a 46 | withSpan opName action = withSpanAndTags opName [] action 47 | 48 | withSpanAndTags :: forall m a. MonadIO m => MonadMask m => T.Text -> [(T.Text, T.Text)] -> m a -> m a 49 | withSpanAndTags opName initialTags action = do 50 | bytes_before <- liftIO getAllocationCounter 51 | fst <$> generalBracket 52 | (pushSpan opName initialTags) 53 | (\sp exitcase -> do 54 | bytes_after <- liftIO getAllocationCounter 55 | let alloc = showt $ bytes_before - bytes_after 56 | case exitcase of 57 | ExitCaseSuccess _ -> setTag "alloc" alloc 58 | ExitCaseException ex -> do 59 | setTags [ 60 | ("alloc", alloc), 61 | ("error", "true"), 62 | ("error.message", (T.pack $ displayException ex))] 63 | ExitCaseAbort -> do 64 | setTags [ 65 | ("alloc", alloc), 66 | ("error", "true"), 67 | ("error.message", "abort")] 68 | popSpan sp) 69 | (\_ -> action) 70 | 71 | pushSpan :: MonadIO m => T.Text -> [(T.Text, T.Text)] -> m () 72 | pushSpan opName initialTags = liftIO $ do 73 | sp <- startSpan opName 74 | tId <- myThreadId 75 | modifyMVar_ globalSharedMutableSpanStacks $ \stacks -> 76 | case fromMaybe [] (HM.lookup tId stacks) of 77 | [] -> do 78 | let !sp' = 79 | sp 80 | & tags .~ 81 | ( (defMessage & key .~ "thread" & stringValue .~ T.pack (show tId)) 82 | : [(defMessage & key .~ k & stringValue .~ v) | (k, v) <- initialTags] 83 | ) 84 | pure $! HM.insert tId [sp'] stacks 85 | (psp : _) -> 86 | let !sp' = 87 | sp 88 | & references .~ [defMessage & relationship .~ Reference'CHILD_OF & spanContext .~ (psp ^. spanContext)] 89 | & spanContext . traceId .~ (psp ^. spanContext . traceId) 90 | & tags .~ [(defMessage & key .~ k & stringValue .~ v) | (k, v) <- initialTags] 91 | in pure $! HM.update (Just . (sp' :)) tId stacks 92 | 93 | popSpan :: MonadIO m => () -> m () 94 | popSpan () = liftIO $ do 95 | tId <- myThreadId 96 | sp <- 97 | modifyMVar 98 | globalSharedMutableSpanStacks 99 | ( \stacks -> 100 | let (sp : sps) = stacks HM.! tId 101 | !stacks' = case sps of 102 | [] -> HM.delete tId stacks 103 | _ -> HM.insert tId sps stacks 104 | in pure (stacks', sp) 105 | ) 106 | sp' <- finishSpan sp 107 | submitSpan sp' 108 | 109 | modifyCurrentSpan :: MonadIO m => (Span -> Span) -> m () 110 | modifyCurrentSpan f = liftIO $ do 111 | tId <- myThreadId 112 | modifyMVar_ 113 | globalSharedMutableSpanStacks 114 | ( \stacks -> case HM.lookup tId stacks of 115 | Just (sp : sps) -> pure $! HM.insert tId (f sp : sps) stacks 116 | _ -> pure stacks 117 | ) 118 | 119 | currentSpanContext :: MonadIO m => m (Maybe SpanContext) 120 | currentSpanContext = liftIO $ do 121 | tId <- myThreadId 122 | stacks <- readMVar globalSharedMutableSpanStacks 123 | let ctx = 124 | case HM.lookup tId stacks of 125 | Just (sp : _) -> Just $ sp ^. spanContext 126 | _ -> Nothing 127 | pure ctx 128 | 129 | setTag :: MonadIO m => T.Text -> T.Text -> m () 130 | setTag k v = 131 | modifyCurrentSpan (tags %~ ((defMessage & key .~ k & stringValue .~ v) :)) 132 | 133 | setTags :: MonadIO m => [(T.Text, T.Text)] -> m () 134 | setTags kvs = 135 | modifyCurrentSpan (tags %~ ([defMessage & key .~ k & stringValue .~ v | (k, v) <- kvs] <>)) 136 | 137 | addLog :: MonadIO m => LogEntryKey -> T.Text -> m () 138 | addLog k v = 139 | modifyCurrentSpan (logs %~ (<> [defMessage & fields .~ [defMessage & key .~ showLogEntryKey k & stringValue .~ v]])) 140 | 141 | setParentSpanContext :: MonadIO m => SpanContext -> m () 142 | setParentSpanContext ctx = modifyCurrentSpan $ \sp -> 143 | sp 144 | & references .~ [defMessage & relationship .~ Reference'CHILD_OF & spanContext .~ ctx] 145 | & spanContext . traceId .~ (ctx ^. traceId) 146 | 147 | {-# NOINLINE globalSharedMutableSingletonState #-} 148 | globalSharedMutableSingletonState :: TBQueue Span 149 | globalSharedMutableSingletonState = unsafePerformIO $ newTBQueueIO 1000 150 | 151 | withSingletonLightStep :: LightStepConfig -> IO () -> IO () 152 | withSingletonLightStep cfg action = do 153 | clientOrError <- try (mkClient cfg) 154 | case clientOrError of 155 | Left (err :: IOError) -> do 156 | d_ $ "Not connected to LightStep " <> lsHostName cfg <> ":" <> show (lsPort cfg) 157 | d_ $ "Reason: " <> show err 158 | d_ $ "Continuing without tracing" 159 | action 160 | Right client -> do 161 | d_ $ "Connected to LightStep " <> lsHostName cfg <> ":" <> show (lsPort cfg) 162 | doneVar <- newEmptyMVar 163 | let work = do 164 | d_ "Getting more spans" 165 | sps <- atomically $ do 166 | some_spans <- replicateM (lsMinimumBatchSize cfg) $ readTBQueue globalSharedMutableSingletonState 167 | some_more_spans <- flushTBQueue globalSharedMutableSingletonState 168 | pure (some_spans <> some_more_spans) 169 | d_ $ "Got " <> show (length sps) <> " spans" 170 | inc 1 sentBatchesCountVar 171 | reportSpansRes <- try (reportSpans client sps) 172 | case reportSpansRes of 173 | Right () -> 174 | d_ $ "Reported " <> show (length sps) <> " spans" 175 | Left (err :: SomeException) -> 176 | d_ $ "Error while reporting spans: " <> show err 177 | shutdown = do 178 | d_ "Getting the last spans before shutdown" 179 | sps <- atomically $ flushTBQueue globalSharedMutableSingletonState 180 | when (not $ null sps) $ do 181 | d_ $ "Got " <> show (length sps) <> " spans" 182 | reportSpans client sps 183 | d_ $ "Reported " <> show (length sps) <> " spans" 184 | d_ "No more spans" 185 | closeClient client 186 | d_ "Client closed" 187 | putMVar doneVar () 188 | race_ action $ do 189 | tid <- myThreadId 190 | labelThread tid "LightStep reporter" 191 | fix $ \loop -> do 192 | work 193 | loop 194 | race_ 195 | shutdown 196 | (waitUntilDone (lsGracefulShutdownTimeoutSeconds cfg) doneVar) 197 | 198 | submitSpan :: Span -> IO () 199 | submitSpan sp = do 200 | written <- atomically $ tryWriteTBQueue globalSharedMutableSingletonState sp 201 | when (not written) $ do 202 | d_ "internal span queue is full, dropping the span" 203 | inc 1 droppedSpanCountVar 204 | 205 | tryWriteTBQueue :: TBQueue a -> a -> STM Bool 206 | tryWriteTBQueue q a = isFullTBQueue q >>= \case 207 | True -> pure False 208 | _ -> do 209 | writeTBQueue q a 210 | pure True 211 | 212 | submitSpans :: Foldable f => f Span -> IO () 213 | submitSpans = atomically . mapM_ (tryWriteTBQueue globalSharedMutableSingletonState) 214 | 215 | waitUntilDone :: Int -> MVar () -> IO () 216 | waitUntilDone timeoutSeconds doneVar = do 217 | d_ "waitUntilDone begin" 218 | timeout (1_000_000 * timeoutSeconds) $ do 219 | takeMVar doneVar 220 | d_ "waitUntilDone: done" 221 | -------------------------------------------------------------------------------- /src/LightStep/Internal/Debug.hs: -------------------------------------------------------------------------------- 1 | module LightStep.Internal.Debug where 2 | 3 | import Control.Concurrent 4 | import Control.Monad.IO.Class 5 | import System.Environment 6 | import System.IO 7 | import System.IO.Unsafe 8 | 9 | {-# NOINLINE d_ #-} 10 | d_ :: MonadIO m => String -> m () 11 | d_ = unsafePerformIO $ 12 | lookupEnv "LIGHTSTEP_DEBUG" >>= \case 13 | Nothing -> pure $ const (pure ()) 14 | Just "0" -> pure $ const (pure ()) 15 | Just "false" -> pure $ const (pure ()) 16 | _ -> pure $ \s -> liftIO $ do 17 | tid <- myThreadId 18 | hPutStrLn stderr (show tid <> ": " <> s) 19 | -------------------------------------------------------------------------------- /src/LightStep/LowLevel.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module LightStep.LowLevel 4 | ( module LightStep.LowLevel, 5 | Span, 6 | ) 7 | where 8 | 9 | import Chronos 10 | import Control.Concurrent 11 | import Control.Monad.Catch 12 | import Control.Lens hiding (op) 13 | import Data.ProtoLens.Message (defMessage) 14 | import qualified Data.Text as T 15 | import Data.Version (showVersion) 16 | import LightStep.Config 17 | import LightStep.Diagnostics 18 | import LightStep.Internal.Debug 19 | import Network.GRPC.Client 20 | import Network.GRPC.Client.Helpers 21 | import Network.GRPC.HTTP2.ProtoLens 22 | import Network.HTTP2.Client 23 | import Paths_lightstep_haskell (version) 24 | import Proto.Collector 25 | import Proto.Collector_Fields 26 | import Proto.Google.Protobuf.Timestamp_Fields 27 | import System.Random 28 | import System.Timeout 29 | 30 | data LightStepClient 31 | = LightStepClient 32 | { lscGrpcVar :: MVar GrpcClient, 33 | lscToken :: T.Text, 34 | lscReporter :: Reporter, 35 | lscConfig :: LightStepConfig 36 | } 37 | 38 | reportSpans :: LightStepClient -> [Span] -> IO () 39 | reportSpans client@LightStepClient {..} sps = do 40 | let tryOnce = do 41 | grpc <- readMVar lscGrpcVar 42 | let req = 43 | timeout 3_000_000 . runExceptT $ 44 | rawUnary 45 | (RPC :: RPC CollectorService "report") 46 | grpc 47 | ( defMessage 48 | & auth .~ (defMessage & accessToken .~ lscToken) 49 | & spans .~ sps 50 | & reporter .~ lscReporter 51 | ) 52 | req 53 | inc (length sps) reportedSpanCountVar 54 | ret <- tryOnce 55 | ret2 <- case ret of 56 | Nothing -> do 57 | d_ "GRPC client is stuck, trying to reconnect" 58 | reconnectClient client 59 | -- one retry after reconnect 60 | tryOnce 61 | _ -> pure ret 62 | case ret2 of 63 | Nothing -> 64 | inc (length sps) rejectedSpanCountVar 65 | _ -> pure () 66 | d_ $ show ret2 67 | pure () 68 | 69 | mkClient :: LightStepConfig -> IO LightStepClient 70 | mkClient cfg@LightStepConfig {..} = do 71 | reporter_id <- randomIO 72 | let rep = 73 | defMessage 74 | & reporterId .~ reporter_id 75 | & tags 76 | .~ ( [ defMessage & key .~ "lightstep.component_name" & stringValue .~ lsServiceName, 77 | defMessage & key .~ "lightstep.tracer_platform" & stringValue .~ "haskell", 78 | defMessage & key .~ "lightstep.tracer_version" & stringValue .~ (T.pack $ showVersion version) 79 | ] 80 | <> [ defMessage & key .~ k & stringValue .~ v 81 | | (k, v) <- lsGlobalTags 82 | ] 83 | ) 84 | grpcVar <- newEmptyMVar 85 | let client = LightStepClient grpcVar lsToken rep cfg 86 | grpc <- makeGrpcClient client 87 | putMVar grpcVar grpc 88 | pure client 89 | 90 | makeGrpcClient :: LightStepClient -> IO GrpcClient 91 | makeGrpcClient client = do 92 | let LightStepConfig {..} = lscConfig client 93 | compression = case lsCompression of 94 | NoCompression -> uncompressed 95 | GzipCompression -> gzip 96 | newGrpcOrError <- 97 | runExceptT $ 98 | setupGrpcClient 99 | ( (grpcClientConfigSimple lsHostName lsPort True) 100 | { _grpcClientConfigCompression = compression, 101 | _grpcClientConfigTimeout = Timeout 5, -- seconds 102 | _grpcClientConfigGoAwayHandler = \_ -> d_ "GoAway handler fired" 103 | } 104 | ) 105 | case newGrpcOrError of 106 | Right newGrpc -> pure newGrpc 107 | Left err -> throwM err 108 | 109 | reconnectClient :: LightStepClient -> IO () 110 | reconnectClient client@LightStepClient {lscGrpcVar} = do 111 | d_ "reconnectClient begin" 112 | inc 1 reconnectCountVar 113 | newClient <- makeGrpcClient client 114 | oldClient <- swapMVar lscGrpcVar newClient 115 | _ <- runExceptT $ close oldClient 116 | d_ "reconnectClient end" 117 | 118 | closeClient :: LightStepClient -> IO () 119 | closeClient LightStepClient {lscGrpcVar} = do 120 | grpc <- readMVar lscGrpcVar 121 | _ <- runExceptT $ close grpc 122 | pure () 123 | 124 | startSpan :: T.Text -> IO Span 125 | startSpan op = do 126 | inc 1 startedSpanCountVar 127 | nanosSinceEpoch <- getTime <$> now 128 | sid <- randomIO 129 | let tid = sid 130 | pure $ 131 | defMessage 132 | & operationName .~ op 133 | & startTimestamp 134 | .~ ( defMessage 135 | & seconds .~ (nanosSinceEpoch `div` 1_000_000_000) 136 | & nanos .~ fromIntegral (rem nanosSinceEpoch 1_000_000_000) 137 | ) 138 | & spanContext 139 | .~ (defMessage & traceId .~ tid & spanId .~ sid) 140 | 141 | finishSpan :: Span -> IO Span 142 | finishSpan sp = do 143 | inc 1 finishedSpanCountVar 144 | nanosSinceEpoch <- getTime <$> now 145 | let dur = 146 | (nanosSinceEpoch - (sp ^. startTimestamp . seconds) * 1_000_000_000 - fromIntegral (sp ^. startTimestamp . nanos)) 147 | & (`div` 1000) 148 | & fromIntegral 149 | pure $ 150 | sp 151 | & durationMicros .~ dur 152 | -------------------------------------------------------------------------------- /src/LightStep/Propagation.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module LightStep.Propagation 4 | ( module P, 5 | module LightStep.Propagation, 6 | ) 7 | where 8 | 9 | import Control.Lens 10 | import qualified Data.ByteString as BS 11 | import qualified Data.ByteString.Char8 as BS8 12 | import Data.ProtoLens.Message (defMessage) 13 | import Data.String 14 | import GHC.Word 15 | import Network.HTTP.Types.Header (HeaderName) 16 | import Network.Wai 17 | import Proto.Collector as P 18 | import Proto.Collector_Fields as P 19 | import Text.Printf 20 | 21 | type TextMap = [(BS.ByteString, BS.ByteString)] 22 | 23 | type HttpHeaders = [(HeaderName, BS.ByteString)] 24 | 25 | -- TODO: Binary format. Both go and python basictracers use TracerState 26 | -- protobuf https://github.com/opentracing/basictracer-go/blob/master/wire/wire.proto 27 | 28 | data Propagator a 29 | = Propagator 30 | { inject :: SpanContext -> a, 31 | extract :: a -> Maybe SpanContext 32 | } 33 | 34 | textPropagator :: Propagator TextMap 35 | textPropagator = 36 | let prefix = "Ot-Tracer-" 37 | in Propagator 38 | { inject = injectSpanContext prefix, 39 | extract = extractSpanContext prefix 40 | } 41 | 42 | httpHeadersPropagator :: Propagator HttpHeaders 43 | httpHeadersPropagator = 44 | let prefix = "Ot-Tracer-" 45 | in Propagator 46 | { inject = injectSpanContext prefix, 47 | extract = extractSpanContext prefix 48 | } 49 | 50 | b3Propagator :: Propagator HttpHeaders 51 | b3Propagator = 52 | let prefix = "X-B3-" 53 | in Propagator 54 | { inject = injectSpanContext prefix, 55 | extract = extractSpanContext prefix 56 | } 57 | 58 | injectSpanContext :: 59 | (IsString key, Semigroup key) => 60 | key -> 61 | SpanContext -> 62 | [(key, BS.ByteString)] 63 | injectSpanContext prefix ctx = 64 | [ (prefix <> "Traceid", encode_u64 $ ctx ^. traceId), 65 | (prefix <> "Spanid", encode_u64 $ ctx ^. spanId), 66 | (prefix <> "Sampled", "true") 67 | ] 68 | 69 | extractSpanContext :: 70 | (IsString key, Eq key, Semigroup key) => 71 | key -> 72 | [(key, BS.ByteString)] -> 73 | Maybe SpanContext 74 | extractSpanContext prefix format = 75 | (\(tid, sid) -> defMessage & traceId .~ tid & spanId .~ sid) 76 | <$> go format (Nothing, Nothing) 77 | where 78 | traceidKey = prefix <> "Traceid" 79 | spanidKey = prefix <> "Spanid" 80 | go _ (Just tid, Just sid) = Just (tid, sid) 81 | go [] _ = Nothing 82 | go ((k, v) : xs) (tid, sid) 83 | | k == traceidKey = go xs (decode_u64 v, sid) 84 | | k == spanidKey = go xs (tid, decode_u64 v) 85 | | otherwise = go xs (tid, sid) 86 | 87 | extractSpanContextFromRequest :: Request -> Maybe SpanContext 88 | extractSpanContextFromRequest = 89 | extract httpHeadersPropagator . requestHeaders 90 | 91 | -- parse128 :: BS.ByteString -> Maybe (Word64, Word64) 92 | -- parse128 _ = Nothing -- TODO 93 | 94 | encode_u64 :: Word64 -> BS.ByteString 95 | encode_u64 x = BS8.pack (printf "%016x" x) 96 | 97 | decode_u64 :: BS.ByteString -> Maybe Word64 98 | decode_u64 bytes | BS.length bytes > 16 = Nothing 99 | decode_u64 bytes = BS.foldl' go (Just 0) bytes 100 | where 101 | go Nothing _ = Nothing 102 | go (Just !result) d | d >= 48 && d < 58 = Just $ result * 16 + fromIntegral d - 48 103 | go (Just result) d | d >= 97 && d < 124 = Just $ result * 16 + fromIntegral d - 87 104 | go _ _ = Nothing 105 | -------------------------------------------------------------------------------- /src/Network/Wai/Middleware/LightStep.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module Network.Wai.Middleware.LightStep where 4 | 5 | import TextShow 6 | import qualified Data.Text.Encoding as T 7 | import LightStep.HighLevel.IO 8 | import LightStep.Internal.Debug 9 | import LightStep.Propagation 10 | import Network.HTTP.Types 11 | import Network.Wai 12 | 13 | -- Semantic conventions for HTTP spans: 14 | -- https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-http.md 15 | 16 | tracingMiddleware :: Application -> Application 17 | tracingMiddleware app = \req sendResp -> do 18 | withSpan "WAI handler" $ do 19 | case extractSpanContextFromRequest req of 20 | Just ctx -> do 21 | d_ $ "Extracted context: " <> show ctx 22 | setParentSpanContext ctx 23 | _ -> do 24 | d_ $ "Failed to extract context from headers " <> show (requestHeaders req) 25 | setTags 26 | [ ("span.kind", "server") 27 | , ("http.method", T.decodeUtf8 (requestMethod req)) 28 | , ("http.target", T.decodeUtf8 (rawPathInfo req)) 29 | , ("http.flavor", showt (httpMajor $ httpVersion req)) 30 | ] 31 | app req $ \resp -> do 32 | setTag "http.status_code" $ showt (statusCode $ responseStatus resp) 33 | sendResp resp 34 | 35 | -------------------------------------------------------------------------------- /stress-test/Main.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | import Control.Concurrent 4 | import Control.Concurrent.Async 5 | import Control.Monad 6 | import GHC.Stats 7 | import LightStep.Diagnostics 8 | import LightStep.HighLevel.IO 9 | import System.Exit 10 | import Text.Printf 11 | 12 | seriousBusinessMain :: IO () 13 | seriousBusinessMain = concurrently_ frontend backend 14 | where 15 | frontend = 16 | withSpanAndTags "RESTful API" [("foo", "bar")] $ do 17 | threadDelay 10000 18 | withSpanAndTags "Kafka" [("foo", "baz")] $ do 19 | threadDelay 20000 20 | threadDelay 30000 21 | withSpanAndTags "GraphQL" [("foo", "quux"), ("lorem", "ipsum")] $ do 22 | threadDelay 40000 23 | addLog Event "monkey-job" 24 | addLog (Custom "foo") "bar" 25 | withSpan "Mongodb" $ do 26 | threadDelay 50000 27 | threadDelay 60000 28 | withSpan "data->json" $ pure () 29 | withSpan "json->yaml" $ pure () 30 | withSpan "yaml->xml" $ pure () 31 | withSpan "xml->protobuf" $ pure () 32 | withSpan "protobuf->thrift" $ pure () 33 | withSpan "thrift->base64" $ pure () 34 | threadDelay 70000 35 | backend = 36 | withSpan "Background Data Science" $ do 37 | threadDelay 10000 38 | withSpanAndTags "Tensorflow" [("learning", "deep")] $ do 39 | threadDelay 100000 40 | setTag "learning" "deep" 41 | withSpanAndTags "Torch" [("learning", "very_deep")] $ do 42 | threadDelay 100000 43 | withSpanAndTags "Hadoop" [("learning", "super_deep")]$ do 44 | threadDelay 100000 45 | 46 | reportMemoryUsage :: IO () 47 | reportMemoryUsage = do 48 | RTSStats {..} <- getRTSStats 49 | let GCDetails {..} = gc 50 | printf "max_live_bytes %d\n" max_live_bytes 51 | printf "gcdetails_live_bytes %d\n" gcdetails_live_bytes 52 | when (max_live_bytes > 10_000_000) $ do 53 | putStrLn "Ate too much memory" 54 | exitFailure 55 | 56 | main :: IO () 57 | main = do 58 | Just lsConfig <- getEnvConfig 59 | withSingletonLightStep lsConfig $ do 60 | replicateM_ 10 $ do 61 | reportMemoryUsage 62 | replicateM_ 1000 $ do 63 | _ <- async seriousBusinessMain 64 | threadDelay 10000 65 | getDiagnostics >>= print 66 | putStrLn "All done" 67 | -------------------------------------------------------------------------------- /unit-test/Main.hs: -------------------------------------------------------------------------------- 1 | {-# OPTIONS_GHC -F -pgmF tasty-discover #-} 2 | -------------------------------------------------------------------------------- /unit-test/TestPropagation.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE OverloadedStrings #-} 2 | 3 | module TestPropagation where 4 | 5 | import Control.Lens 6 | import Data.Function 7 | import Data.ProtoLens.Message (defMessage) 8 | import Data.Word 9 | import LightStep.Propagation 10 | import Test.Tasty.HUnit 11 | import Text.Printf 12 | 13 | prop_u64_roundtrip :: Word64 -> Bool 14 | prop_u64_roundtrip x = 15 | Just x == decode_u64 (encode_u64 x) 16 | 17 | prop_text_propagator_roundtrip :: Word64 -> Word64 -> Bool 18 | prop_text_propagator_roundtrip tid sid = 19 | let c = 20 | defMessage 21 | & traceId .~ tid 22 | & spanId .~ sid 23 | p = textPropagator 24 | in Just c == extract p (inject p c) 25 | 26 | prop_b3_propagator_roundtrip :: Word64 -> Word64 -> Bool 27 | prop_b3_propagator_roundtrip tid sid = 28 | let c = 29 | defMessage 30 | & traceId .~ tid 31 | & spanId .~ sid 32 | p = b3Propagator 33 | in Just c == extract p (inject p c) 34 | --------------------------------------------------------------------------------