Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fthomas/status-page
A microlibrary for creating simple status pages
https://github.com/fthomas/status-page
cats functional-programming microlibrary scala status-page
Last synced: 3 months ago
JSON representation
A microlibrary for creating simple status pages
- Host: GitHub
- URL: https://github.com/fthomas/status-page
- Owner: fthomas
- License: apache-2.0
- Created: 2018-08-09T12:33:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-16T15:14:48.000Z (4 months ago)
- Last Synced: 2024-09-17T18:36:06.717Z (4 months ago)
- Topics: cats, functional-programming, microlibrary, scala, status-page
- Language: Scala
- Homepage:
- Size: 740 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# status-page
[![Continuous Integration](https://github.com/fthomas/status-page/actions/workflows/ci.yml/badge.svg)](https://github.com/fthomas/status-page/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/fthomas/status-page/branch/master/graph/badge.svg)](https://codecov.io/gh/fthomas/status-page)
[![Scaladex](https://index.scala-lang.org/fthomas/status-page/latest.svg?color=blue)](https://index.scala-lang.org/fthomas/status-page/status-page-core)
[![Scaladoc](https://www.javadoc.io/badge/eu.timepit/status-page-core_2.12.svg?color=blue&label=Scaladoc)](https://javadoc.io/doc/eu.timepit/status-page-core_2.12)**status-page** is a microlibrary for creating simple status pages.
It provides data structures and functions to organize, aggregate, and render
status information in a straightforward way.## Quick example
```scala
import cats.effect.IO
import eu.timepit.statuspage.cats.Make
import eu.timepit.statuspage.core.Result.{Ok, Warning}
import eu.timepit.statuspage.core.plaintext// We use `IO` values for status checks, but the library supports any
// type that is an `ApplicativeError`.
val uptime: IO[String] = IO("up 2 weeks, 3 days, 13 hours, 27 minutes")
val dbQuery: IO[Unit] = IO(())
val dbItems: IO[Int] = IO(38)
val sparkNode1: IO[Unit] = IO(())
val sparkNode2: IO[Unit] = IO.raiseError(new Exception("unreachable"))
```
```scala
val mk = new Make[IO, Throwable](_.getMessage)
// mk: eu.timepit.statuspage.cats.Make[cats.effect.IO,Throwable] = eu.timepit.statuspage.cats.Make@12af9bd3val root = mk.root(
mk.entryInfo("uptime", uptime),
mk.group(
"database",
mk.entryOk("query", dbQuery),
mk.entry("items", dbItems)(i => if (i > 50) Ok else Warning.withMsg(i.toString))
),
mk.group(
"spark_cluster",
mk.entryOk("node1", sparkNode1),
mk.entryOk("node2", sparkNode2)
)
)
// root: cats.effect.IO[eu.timepit.statuspage.core.Root] =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
```## Using status-page
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:
```sbt
libraryDependencies ++= Seq(
"eu.timepit" %% "status-page-core" % "",
"eu.timepit" %% "status-page-cats" % ""
)
```## License
**status-page** is licensed under the Apache License, Version 2.0, available at
http://www.apache.org/licenses/LICENSE-2.0 and also in the
[LICENSE](https://github.com/fthomas/status-page/blob/master/LICENSE) file.