django_socio_grpc.settings
Settings for gRPC framework are all namespaced in the GRPC_FRAMEWORK setting.
For example your project’s settings.py file might look like this:
GRPC_FRAMEWORK = { “ROOT_HANDLERS_HOOK”: “path.to.your.handler.function” … }
To see all options see documentation: https://django-socio-grpc.readthedocs.io/en/stable/
This module provides the grpc_setting object, that is used to access
gRPC framework settings, checking for user settings first, then falling
back to the defaults.
Module Contents
Classes
FilterAndPaginationBehaviorOptions is an StrEnum that present the congiguration possibilities for PAGINATION_BEHAVIOR and FILTER_BEHAVIOR. |
|
A settings object that allows gRPC Framework settings to be accessed as properties. For example: |
Functions
If the given setting is a string import notation, then perform the necessary import or imports. |
|
Attempt to import a class from a string representation. |
|
Data
API
- django_socio_grpc.settings.__all__
[‘grpc_settings’]
- class django_socio_grpc.settings.FilterAndPaginationBehaviorOptions
-
FilterAndPaginationBehaviorOptions is an StrEnum that present the congiguration possibilities for PAGINATION_BEHAVIOR and FILTER_BEHAVIOR.
The mains differences between metadata and request are:
Metadata are not specified in the proto file so adding or removing a filter in a new version is not documented and may cause breaking changes.
Requests allows helping developpers understand which endpoint accept filtering and automatically document it
Requests are serialized so it can improve performance when filtering large amount of data
Initialization
Initialize self. See help(type(self)) for accurate signature.
- METADATA_STRICT
‘METADATA_STRICT’
Only allow the element choosen against metadata. This is the default behavior as it’s the legacy way of pagination. This will change for 1.0.0. This mode doesn’t add additional fields into the messages.
- REQUEST_STRUCT_STRICT
‘REQUEST_STRUCT_STRICT’
Only allow to use the element choosen against request field (
_filtersor_pagination). This mode add the specifis key (_filtersor_pagination) in every message except if service specifically disable it.
- METADATA_AND_REQUEST_STRUCT
‘METADATA_AND_REQUEST_STRUCT’
Allow pagination against metadata and request field (
_filtersor_pagination). This mode add the specific key (_filtersor_pagination) in every message except if service specifically disable it. If filter is present in both metadata and request field, the one in request field have priority. You should only use this mode when transitionning from metadata to request as having both is not recommended and could bring clarity issues
- django_socio_grpc.settings.DEFAULTS
None
- django_socio_grpc.settings.IMPORT_STRINGS
[‘ROOT_HANDLERS_HOOK’, ‘DEFAULT_AUTHENTICATION_CLASSES’, ‘DEFAULT_PERMISSION_CLASSES’, ‘DEFAULT_PAGI…
- django_socio_grpc.settings.MERGE_DEFAULTS
[‘MAP_METADATA_KEYS’]
- django_socio_grpc.settings.perform_import(val, setting_name)
If the given setting is a string import notation, then perform the necessary import or imports.
- django_socio_grpc.settings.import_from_string(val, setting_name)
Attempt to import a class from a string representation.
- class django_socio_grpc.settings.GRPCSettings(user_settings=None, defaults=None, import_strings=None)
A settings object that allows gRPC Framework settings to be accessed as properties. For example:
from django_socio_grpc.settings import grpc_settings print(grpc_settings.ROOT_HANDLERS_HOOK)
Any setting with string import paths will be automatically resolved and return the class, rather than the string literal.
Initialization
- property user_settings
- __getattr__(attr)
- reload()
- django_socio_grpc.settings.grpc_settings
‘GRPCSettings(…)’
- django_socio_grpc.settings.reload_grpc_settings(*args, **kwargs)