You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@s2graph.apache.org by st...@apache.org on 2019/01/25 22:49:02 UTC
[10/20] incubator-s2graph git commit: add api document
add api document
Project: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/commit/7e4f6c81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/tree/7e4f6c81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s2graph/diff/7e4f6c81
Branch: refs/heads/master
Commit: 7e4f6c81f61f6c718a5e8bdb4b53cb534c21c1b5
Parents: 455e155
Author: daewon <da...@apache.org>
Authored: Wed Dec 26 19:19:35 2018 +0900
Committer: daewon <da...@apache.org>
Committed: Wed Dec 26 19:19:35 2018 +0900
----------------------------------------------------------------------
doc/source/conf.py | 2 ++
doc/source/index.rst | 1 +
.../src/main/scala/org/apache/s2graph/http/Server.scala | 10 ++++++++--
3 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7e4f6c81/doc/source/conf.py
----------------------------------------------------------------------
diff --git a/doc/source/conf.py b/doc/source/conf.py
index afa4c10..5736d04 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -46,6 +46,8 @@ extensions = [
'sphinx.ext.githubpages',
]
+html_style = 'css/s2graph_style.css'
+
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7e4f6c81/doc/source/index.rst
----------------------------------------------------------------------
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 83bf8d5..fd4e755 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -20,6 +20,7 @@ dev@s2graph.incubator.apache.org is for people who want to contribute to S2Graph
getting_started/index
getting_started/your_first_graph
+ api/index
..
Indices and tables
http://git-wip-us.apache.org/repos/asf/incubator-s2graph/blob/7e4f6c81/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
----------------------------------------------------------------------
diff --git a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
index 03802ed..e70a182 100644
--- a/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
+++ b/s2http/src/main/scala/org/apache/s2graph/http/Server.scala
@@ -19,6 +19,8 @@
package org.apache.s2graph.http
+import java.time.Instant
+
import scala.language.postfixOps
import scala.concurrent.{Await, ExecutionContext, Future}
import scala.concurrent.duration.Duration
@@ -51,9 +53,13 @@ object Server extends App
val port = sys.props.get("http.port").fold(8000)(_.toInt)
val interface = sys.props.get("http.interface").fold("0.0.0.0")(identity)
- val serverStatus = s""" { "port": ${port}, "interface": ${interface}, "started_at": ${System.currentTimeMillis()} }"""
+ val startAt = System.currentTimeMillis()
+
+ def uptime = System.currentTimeMillis() - startAt
+
+ def serverHealth = s"""{ "port": ${port}, "interface": "${interface}", "started_at": ${Instant.ofEpochMilli(startAt)}, "uptime": "${uptime} millis" """
- val health = HttpResponse(status = StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, serverStatus))
+ def health = HttpResponse(status = StatusCodes.OK, entity = HttpEntity(ContentTypes.`application/json`, serverHealth))
// Allows you to determine routes to expose according to external settings.
lazy val routes: Route = concat(