socotecio / django-socio-grpc-example

Simple examples of how to use DSG
Apache License 2.0
1 stars 2 forks source link

about @grpc_action #1

Closed lzy350593418 closed 1 year ago

lzy350593418 commented 1 year ago
@grpc_action(
    request=[
        {
            "name": "question_text",
            "type": "string",
        }
    ],
    response=[
        {
            "name": "response",
            "type": "string",
        }
    ],
    request_stream=True,
    response_stream=True,
)

What is the use of this decorator? Is it used to define the format of the request response? Or is it only used for stream methods?

lzy350593418 commented 1 year ago

Currently, I am not quite sure about the purpose of this decorator. It would be helpful to have a usage guide to make it easier to get started. Additionally, the configuration of the logging module is not specified in the dependency documentation. Also, there is no clear explanation on how to configure the configuration file when adding more than two sub-applications for GRPC services. It would be helpful if this could be added and improved upon.

lzy350593418 commented 1 year ago

I’m not quite sure about the stream method you mentioned. Is this method used for long connection chat scenarios? But when I tested it with Postman, I found that there was occasionally a delay of several seconds in the response, and it was not possible to achieve one-to-one Q&A. It is possible that I made a request and entered the response content on the server side. Due to the fast response, the entered content could not be responded in time and responded with a null value, resulting in the response content being responded one by one in the next request.

lzy350593418 commented 1 year ago

Also, when I was testing, I found that when calling the stream interface and then calling other create or list interfaces, there would be a delay. What could be the cause of this? However, the response time returned to Postman is very fast, about 1ms, but it takes several seconds to display, which is very strange.

lzy350593418 commented 1 year ago

Please tell me why, when I modify the contents of app_example and then use the python manage.py generateproto command, it reverts back to its original state. Is this generateproto command based on the model class or something else? Could you explain?

AMontagu commented 1 year ago

Hello

This is the future documentation we are working on. You can find more details about grpc_action: https://socio-django-grpc.readthedocs.io/en/latest/features/grpc-action.html

The delay can be because of your code exectution time if you are doing a heavy request in database for example.

generateproto based on service and serializer. You should not edit protobuf file manually DSG do that for you

lzy350593418 commented 1 year ago

Hello

This is the future documentation we are working on. You can find more details about grpc_action: https://socio-django-grpc.readthedocs.io/en/latest/features/grpc-action.html

The delay can be because of your code exectution time if you are doing a heavy request in database for example.

generateproto based on service and serializer. You should not edit protobuf file manually DSG do that for you

Thanks