mirror of
https://github.com/higherkindness/mu-haskell.git
synced 2024-09-11 14:36:01 +03:00
Add instrumentation to library example (#212)
This commit is contained in:
parent
2b5c147535
commit
afbe5d8ef1
@ -25,6 +25,7 @@ executable library
|
||||
, monad-logger >=0.3 && <0.4
|
||||
, mtl
|
||||
, mu-persistent >=0.3
|
||||
, mu-prometheus >=0.4
|
||||
, mu-graphql >=0.4
|
||||
, mu-rpc >=0.4
|
||||
, mu-schema >=0.3
|
||||
|
@ -20,6 +20,7 @@ import Database.Persist.Sqlite
|
||||
import Mu.Adapter.Persistent (runDb)
|
||||
import Mu.GraphQL.Quasi
|
||||
import Mu.GraphQL.Server
|
||||
import Mu.Instrumentation.Prometheus
|
||||
import Mu.Schema
|
||||
import Mu.Server
|
||||
import Network.Wai.Handler.Warp (run)
|
||||
@ -30,19 +31,24 @@ import Schema
|
||||
main :: IO ()
|
||||
main = do
|
||||
putStrLn "starting GraphQL server on port 8000"
|
||||
-- Setup CORS
|
||||
let hm = addHeaders [
|
||||
("Access-Control-Allow-Origin", "*")
|
||||
, ("Access-Control-Allow-Headers", "Content-Type")
|
||||
]
|
||||
-- Set up Prometheus
|
||||
p <- initPrometheus "library"
|
||||
-- Run the whole thing
|
||||
runStderrLoggingT $
|
||||
withSqliteConn @(LoggingT IO) ":memory:" $ \conn -> do
|
||||
runDb conn $ runMigration migrateAll
|
||||
liftIO $ run 8000 $ hm $
|
||||
graphQLApp (libraryServer conn)
|
||||
graphQLApp (prometheus p $ libraryServer conn)
|
||||
(Proxy @('Just "Query"))
|
||||
(Proxy @('Just "Mutation"))
|
||||
(Proxy @('Just "Subscription"))
|
||||
|
||||
|
||||
type ObjectMapping = '[
|
||||
"Book" ':-> Entity Book
|
||||
, "Author" ':-> Entity Author
|
||||
|
Loading…
Reference in New Issue
Block a user