-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added preliminary testing of WAL monitor
- Loading branch information
1 parent
601dca0
commit fd58862
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
monitor/src/main/scala/com/outr/arango/monitor/ArangoDBMonitor.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.outr.arango.monitor | ||
|
||
import cats.effect.{ExitCode, IO, IOApp} | ||
import com.outr.arango.Graph | ||
import com.outr.arango.core.ArangoDBConfig | ||
import fabric.Json | ||
import fabric.io.JsonFormatter | ||
import spice.http.client.HttpClient | ||
import spice.net._ | ||
|
||
// TODO: Work in progress | ||
case class ArangoDBMonitor(config: ArangoDBConfig = ArangoDBConfig()) { | ||
private lazy val client = HttpClient | ||
.url(URL( | ||
protocol = if (config.ssl) Protocol.Https else Protocol.Http, | ||
host = config.hosts.head.host, | ||
port = config.hosts.head.port | ||
)) | ||
// http://localhost:8529/_api/wal/tail?from=188771 | ||
// TODO: Handle user authentication | ||
def tail(db: Option[String] = None, | ||
from: Option[Int] = None, | ||
to: Option[Int] = None, | ||
syncerId: Option[String] = None): IO[Unit] = { | ||
val path = db match { | ||
case Some(dbName) => s"/_db/$dbName/_api/wal/tail" | ||
case None => "/_api/wal/tail" | ||
} | ||
client | ||
.path(URLPath.parse(path)) | ||
.call[Json] | ||
.map { json => | ||
scribe.info(s"Tail: ${JsonFormatter.Default(json)}") | ||
} | ||
} | ||
} | ||
|
||
object ArangoDBMonitor extends IOApp { | ||
override def run(args: List[String]): IO[ExitCode] = { | ||
val monitor = ArangoDBMonitor() | ||
monitor.tail().map(_ => ExitCode.Success) | ||
} | ||
} |