FgForrest / evitaDB

evitaDB is a specialized database with an easy-to-use API for e-commerce systems. It is a low-latency NoSQL in-memory engine that handles all the complex tasks that e-commerce systems have to deal with on a daily basis. evitaDB is expected to act as a fast secondary lookup/search index used by front stores.
https://evitadb.io
Other
61 stars 7 forks source link

Extends status endpoint to provide useful info about APIs #645

Closed lukashornych closed 1 month ago

lukashornych commented 1 month ago

Now the /system/status/ exposes basic urls for each API:

{
   "serverName": "evitaDB-4e7478b20c95ed51",
   "version": "2024.10-SNAPSHOT",
   "startedAt": "2024-08-09T07:31:24.835051862Z",
   "uptime": 269608,
   "uptimeForHuman": "3d 2h 53m 28s",
   "catalogsCorrupted": 0,
   "catalogsOk": 1,
   "healthProblems": [],
   "apis": [
      {
         "system": [
            "http://127.0.0.1:6555/system/"
         ]
      },
      {
         "graphQL": [
            "https://127.0.0.1:6555/gql/"
         ]
      },
      {
         "rest": [
            "https://127.0.0.1:6555/rest/"
         ]
      },
      {
         "gRPC": [
            "https://127.0.0.1:6555/"
         ]
      },
      {
         "lab": [
            "https://127.0.0.1:6558/lab/"
         ]
      },
      {
         "observability": [
            "http://127.0.0.1:6555/observability/"
         ]
      }
   ]
}

But this is fairly limited info, specifically for status page in evitaLab https://github.com/lukashornych/evitalab/issues/103. We need following data for each API:

For system API we would like following extra data:

The status response could then look like this:

{
   "serverName": "evitaDB-4e7478b20c95ed51",
   "version": "2024.10-SNAPSHOT",
   "startedAt": "2024-08-09T07:31:24.835051862Z",
   "uptime": 269608,
   "uptimeForHuman": "3d 2h 53m 28s",
   "catalogsCorrupted": 0,
   "catalogsOk": 1,
   "healthProblems": [],
   "apis": {
        "system": {
            "readiness": "ready",
            "baseUrls": ["http://127.0.0.1:6555/system/"],
            "exposedOn": "http://demo.evitadb.io/system",
            "serverCertificate": "/server-cert.crt",
            "clientCertificate": "/client-cert.crt",
            "clientCertificatePrivateKey": "/client-key.key"
        },
        "graphQL": {
            "readiness": "ready",
            "baseUrls": ["http://127.0.0.1:6555/gql/"],
            "exposedOn": "http://demo.evitadb.io/gql"
        }
        /* ... rest of APIs ... */
   }
}
lukashornych commented 1 month ago

Primarily, we need this data in gRPC server status operation, this system/status endpoint can stay as is.

novoj commented 1 month ago

I don't differentiate between classic url and exposeOn url. Could it be:

"graphQL": {
   "readiness": "ready",
   "baseUrls": ["http://127.0.0.1:6555/gql/", "http://demo.evitadb.io/gql"]
}
lukashornych commented 1 month ago

That could be even better, we would do the same in the lab

novoj commented 1 month ago

I have half work done, but it's not so easy as it sounds, because part of the information is not easily available. I will finish it tommorrow.

novoj commented 1 month ago

API is done - the output looks like this:

{
  "version": "2024.10-SNAPSHOT",
  "startedAt": {
    "timestamp": "2024-08-13T15:09:37.919285949Z",
    "offset": "+02:00"
  },
  "uptime": "51",
  "instanceId": "evitaDB-21cca988f15cfea7",
  "catalogsOk": 2,
  "readiness": "API_READY",
  "api": {
    "graphQL": {
      "enabled": true,
      "ready": true,
      "baseUrl": [
        "http://0.0.0.0:5555/gql/"
      ]
    },
    "rest": {
      "enabled": true,
      "ready": true,
      "baseUrl": [
        "http://0.0.0.0:5555/rest/"
      ]
    },
    "gRPC": {
      "enabled": true,
      "ready": true,
      "baseUrl": [
        "https://0.0.0.0:5555/"
      ]
    },
    "system": {
      "enabled": true,
      "ready": true,
      "baseUrl": [
        "http://0.0.0.0:5555/system/"
      ],
      "endpoints": [
        {
          "name": "serverNameUrl",
          "url": [
            "http://0.0.0.0:5555/system/server-name"
          ]
        },
        {
          "name": "rootCertificateUrl",
          "url": [
            "http://0.0.0.0:5555/system/evitaDB-CA-selfSigned.crt"
          ]
        },
        {
          "name": "serverCertificateUrl",
          "url": [
            "http://0.0.0.0:5555/system/server.crt"
          ]
        }
      ]
    },
    "lab": {
      "enabled": true,
      "ready": true,
      "baseUrl": [
        "http://0.0.0.0:5555/lab/"
      ]
    },
    "observability": {
      "enabled": true,
      "ready": true,
      "baseUrl": [
        "http://0.0.0.0:5555/observability/"
      ]
    }
  }
}

It always returns all available APIs (even those disabled), for the system API it returns endpoints with variable size depending on the configuration (not all are available - or present in various configuration variants). Full endpoint listing is:

When exposeOn argument is used during startup, the first URL should be those using this exposeOn argument.

lukashornych commented 1 month ago

@novoj awesome 👍 will this structure be available in the gRPC server status operation later?

novoj commented 1 month ago

This is already an output of the gRPC serverStatus method.

lukashornych commented 1 month ago

@novoj excellent, thanks. We'll integrate it into the evitaLab