-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Change client tracing signatures #2686
Comments
Definitly I wil go for something explicit that incorporates documentation. What about thr idea of custom data classes but based on simple namedtuples? |
I think deriving from SimpleNamespace makes no sense.
|
so, lets try it with derivating namedtuples? or you are keen on make it
even more explicit, that IMHO might be to much verbose.
|
Do you have objections against attrs library? |
I didnt know about attrts, looks great. But just for simplicity and consistence - current aiohttp code usage - and taking into account that the use case is just a need of having a explicit way to declare our data params. Do you believe that right now the features that this library gives are gonna make a difference from the begining? |
That's true that after the acceptation of the data classes PEP, at some point this usage of But for the sake of consistency don't you believe that we must stick to just one pattern in Aiohttp? |
Replacing namedtuples with attrs is my old big secret plan, tracing classes is a good point to start implementing it :) |
Oks, let's go for |
Just a POC [1] that should be enough to have some feedback from you @asvetlov and see if this is what are you expecting after moving to [1] pfreixes@00061ce |
Please wait for #2690 landing. |
Working on that ... just to avoid race conditions. |
This will allow aiohttp development add new parameters in the future without break the signals signature.
* Use custom classes to pass client signals parameters #2686 This will allow aiohttp development add new parameters in the future without break the signals signature. * Fixed tracing uts * Fix import order * Improved documenatation
it can be closed |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Now tracing signal signatures look like
The problem is the approach is has no space for future extensions.
Most likely we will want to add a connection info to
on_send_connection_queued_start
but it is impossible to do without breaking all existing signal handlers: sending additionalconnection
parameter cannot be accepted.Sure, we can enforce users to write handlers with mandatory
*args
and**kwargs
likebut I expect that users will constantly forgot these extra arguments.
As a solution we can change signal signature for all signals to
async def on_sig(session, ctx, data): ...
wherectx
istrace_config_ctx
anddata
is a structure with all signal parameters: url, host, port, headers, connection etc.It allows to add new param to data in backward compatible manner.
Next question is the
data
type.I see several options:
host
andconnection
. It works but looks too old fashion, everybody prefer attributes to string keys.data.url
looks better thandata['url']
SimpleNamespace
at least from documentation perspective: we will need to document every used data structure explicitly.Trace
class already has explicit methods for sending every signal, constructing a data class on call is easy and straightforward.@pfreixes and others, what do you think about?
The text was updated successfully, but these errors were encountered: