- Notifications
You must be signed in to change notification settings - Fork2
A microlibrary for creating simple status pages
License
NotificationsYou must be signed in to change notification settings
fthomas/status-page
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
status-page is a microlibrary for creating simple status pages.It provides data structures and functions to organize, aggregate, and renderstatus information in a straightforward way.
importcats.effect.IOimporteu.timepit.statuspage.cats.Makeimporteu.timepit.statuspage.core.Result.{Ok,Warning}importeu.timepit.statuspage.core.plaintext// We use `IO` values for status checks, but the library supports any// type that is an `ApplicativeError`.valuptime:IO[String]=IO("up 2 weeks, 3 days, 13 hours, 27 minutes")valdbQuery:IO[Unit]=IO(())valdbItems:IO[Int]=IO(38)valsparkNode1:IO[Unit]=IO(())valsparkNode2:IO[Unit]=IO.raiseError(newException("unreachable"))
valmk=newMake[IO,Throwable](_.getMessage)// mk: eu.timepit.statuspage.cats.Make[cats.effect.IO,Throwable] = eu.timepit.statuspage.cats.Make@12af9bd3valroot= mk.root( mk.entryInfo("uptime", uptime), mk.group("database", mk.entryOk("query", dbQuery), mk.entry("items", dbItems)(i=>if (i>50)OkelseWarning.withMsg(i.toString)) ), mk.group("spark_cluster", mk.entryOk("node1", sparkNode1), mk.entryOk("node2", sparkNode2) ))// root: cats.effect.IO[eu.timepit.statuspage.core.Root] = <function1>root.map(plaintext.renderRoot).unsafeRunSync()// res0: String =// status: ERROR// uptime: up 2 weeks, 3 days, 13 hours, 27 minutes// database_status: WARNING// database_query: OK// database_items: WARNING 38// spark_cluster_status: ERROR// spark_cluster_node1: OK// spark_cluster_node2: ERROR unreachable
The latest version of the library is available for Scala 2.12, 2.13, and 3.
If you're using sbt, add the following to your build:
libraryDependencies++=Seq("eu.timepit"%%"status-page-core"%"<latestVersion>","eu.timepit"%%"status-page-cats"%"<latestVersion>")
status-page is licensed under the Apache License, Version 2.0, available athttp://www.apache.org/licenses/LICENSE-2.0 and also in theLICENSE file.
About
A microlibrary for creating simple status pages
Topics
Resources
License
Code of conduct
Security policy
Stars
Watchers
Forks
Packages0
No packages published