Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept filters from request arguments and not only metadata #247

Open
AMontagu opened this issue Dec 18, 2023 · 2 comments
Open

Accept filters from request arguments and not only metadata #247

AMontagu opened this issue Dec 18, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@AMontagu
Copy link
Collaborator

In DSG metadata is what used to replace the query parameters systems. It is very flexible as it's not in the proto file.

The main inconvenients are:

  • The metadata are not binary serialized so passing a lot of data as filters may result in poor performance
  • They not exported in the proto so not documented by default.

To contourn that we want to look about best practices and implement it.

Think to update doc after.

@markdoerr
Copy link
Contributor

@AMontagu,
I fully support this reature request.

Right now, I am using a "decorator" workaround, e.g.:

# filter_decorator.py
import functools
import json

import lara_django_samples_grpc.v1.lara_django_samples_pb2 as lara_django_samp_pb2

def dict_filter(func):
    @functools.wraps(func)
    def wrapper_filter(filter_dict : dict={}, **kwargs):
        metadata = (("filters", (json.dumps(filter_dict))),)
        return func.List(lara_django_samp_pb2.SampleListRequest(), metadata=metadata, **kwargs)
    return wrapper_filter


and then I can do something like:

from filter_decorator import dict_filter

channel = grpc.insecure_channel(f'{grpc_server_host}:{grpc_server_port}')
sample_client = lara_django_samp_pb2_grpc.SampleControllerStub(channel)
list_filter = dict_filter(sample_client)

filter_dict = { "name__contains": "term-to-search"}
res = list_filter(filter_dict=filter_dict)
print(res)

Which is more readable, but still has the problem of using metadata to send the filter.

@AMontagu AMontagu mentioned this issue Feb 14, 2024
10 tasks
@AMontagu
Copy link
Collaborator Author

The first part of this issue is completed.
The second part is to precisely detailled the filters and pagination fields names and types instead of using a struct.
This improvement may happen in late 2024.

@legau legau moved this to In Progress in 1.0.0 Tasks Mar 29, 2024
@legau legau added the enhancement New feature or request label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

3 participants