Skip to content

Stream Admin Index Endpoint output to response #562

Open
@maxceem

Description

@maxceem

We have endpoint /v5/projects/admin/es/project/index which we call to index multiple projects from DB to ES by defining a range of projects ids from projectIdStart to projectIdEnd.

At the moment this endpoint only responds after we prepare data for indexing and it doesn't wait until the actual indexing is finished. So we have to see the console of the server to see the logs if we want to understand when the indexing is ready and if there were any errors during indexing or no.

  • We want to see the progress with log when we run this endpoint in response. But we don't want to wait until everything is done, so the response hangs for a long time and only after all is done we can see the log. Response should be returned in parts using streams see https://stackoverflow.com/questions/38788721/how-do-i-stream-response-in-express, so we would see the constant update of response when we are calling this endpoint.

The can be implemented the next way:

  • create a new logger which would do 2 things:
  • this new logger might have a special method to mark the stream end so we can close the connection when everything is done.
  • while we log to console in JSON format, in the response we should return in the next format:
    <log_type>: <message>, examples:
    • INFO: Getting user details.
    • ERROR: Cannot get user details.
    • DEBUG: User details: {"id:"11232,"name":"Test"}.
    • WARNING: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions