-
Notifications
You must be signed in to change notification settings - Fork 104
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
Name clashes with NIOHTTP1 #118
Comments
What's wrong with using the NIOPHTTP1 versions of these objects, they are already imported by AWSLambdaRuntimeCore? |
nio's versions are a bit different from the ones in AWSLambdaEvents, the latter are designed for JSON payload decoding/encoding we could consider adding a prefix to more easily disambiguate. |
I'd add prefixes too. |
@weissi Do you have any recommendations in mind? |
|
Of course that makes the type names a bit ugly. How are the users most commonly interfacing with those types? |
normally we namespace under the |
sounds good |
well i'd put them in but that's not really the point since they are not connected to the lambda runtime but to the aws event. Maybe we should namespace them in |
@fabianfett There isnt any |
what? :-) Apart from all the duping, wouldn’t you want to use the NIO types in the public API? This is not about things like a V2.Request but about the basic http types. Note that this even has functional implications (and duping), e.g. header lookup is not CI? |
@helje5 IIRC the main issues was that we would need to be extending these types to add functionality to them (Codable conformance mainly IIRC). rule of thumb we have been following in library development is to avoid extending public types from other libraries (SwiftNIO in this case) as it may lead to conflicts with other libraries that may do the same. |
You don't need to extend the types to decode them (yes, Codable can only be added to the original type itself, but that is not required here). You can decode the necessary data in init(decoder:) and then construct the actual model. Kinda similar to this: As mentioned in the Slack, a reasonable argument for the duping is that NIO isn't actually necessary for Lambdas. Don't know. |
I guess if we decide to adopt the NIO types after all we could also use property wrappers
that too. personally, I don't love leaking types where not necessary. there is the argument of copying so we need to trade that off in the case of HTTPHeaders, there is also a set of mutability functionality that comes with that type that may not makes sense to expose in the Lambda request use case which is more immutable in nature |
Wrt HTTPHeaders, the NIO ones are actually better than the plain Dict you have in AWS because the latter doesn't account for the header case insensitivity. I don't get the mutability thing. NIOHeaders are a regular CoW struct just like Dictionary, right? In the end it really depends on whether you consider NIO a must have dependency or not. If it is, it's weird not to use its HTTP header types. If not (and they are good arguments for dropping it IMO for this specific thing), I think it's OK to keep it the way it is. |
@adam-fowler now that we adopted Swift HTTP Types in Lambda Events, is this still an issue ? |
|
Currently AWSLambdaEvents defines public symbols
HTTPHeaders
,HTTPMethod
andHTTPResponseStatus
. These clash with the symbols of the same name in NIOHTTP1. While you can differentiate between the two sets by prependingNIOHTTP1.
, I'm not sure modules should be defining symbols with the same name as NIO equivalents.The text was updated successfully, but these errors were encountered: