Skip to content

Commit

Permalink
Merge pull request #8 from scalableminds/health-endpoint
Browse files Browse the repository at this point in the history
add health endpoint
  • Loading branch information
fm3 authored Dec 4, 2017
2 parents ef85680 + 84c4317 commit a459523
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/protobuf/fossildbapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ syntax = "proto2";

package com.scalableminds.fossildb.proto;

message HealthRequest {}
message HealthReply {
required bool success = 1;
optional string errorMessage = 2;
}

message GetRequest {
required string collection = 1;
required string key = 2;
Expand Down Expand Up @@ -124,6 +130,7 @@ message RestoreFromBackupReply {


service FossilDB {
rpc Health (HealthRequest) returns (HealthReply) {}
rpc Get (GetRequest) returns (GetReply) {}
rpc GetMultipleVersions (GetMultipleVersionsRequest) returns (GetMultipleVersionsReply) {}
rpc GetMultipleKeys (GetMultipleKeysRequest) returns (GetMultipleKeysReply) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import scala.concurrent.Future

class FossilDBGrpcImpl(storeManager: StoreManager) extends FossilDBGrpc.FossilDB with LazyLogging {

override def health(req: HealthRequest) = withExceptionHandler(req) {
HealthReply(true)
} {errorMsg => HealthReply(false, errorMsg)}

override def get(req: GetRequest) = withExceptionHandler(req) {
val store = storeManager.getStore(req.collection)
val versionedKeyValuePairOpt = store.get(req.key, req.version)
Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/com/scalableminds/fossildb/FossilDBSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class FossilDBSuite extends FlatSpec with BeforeAndAfterEach {
deleteRecursively(new File(testTempDir))
}

"Health" should "reply" in {
val reply = client.health(HealthRequest())
assert(reply.success)
}

"Put" should "overwrite old value" in {
client.put(PutRequest(collectionA, aKey, 0, testData1))
Expand Down

0 comments on commit a459523

Please sign in to comment.