Coder Social home page Coder Social logo

Comments (15)

adam-fowler avatar adam-fowler commented on June 29, 2024 2

What's wrong with using the NIOPHTTP1 versions of these objects, they are already imported by AWSLambdaRuntimeCore?

from swift-aws-lambda-runtime.

tomerd avatar tomerd commented on June 29, 2024 1

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.

from swift-aws-lambda-runtime.

weissi avatar weissi commented on June 29, 2024

I'd add prefixes too.

from swift-aws-lambda-runtime.

fabianfett avatar fabianfett commented on June 29, 2024

@weissi Do you have any recommendations in mind?

from swift-aws-lambda-runtime.

weissi avatar weissi commented on June 29, 2024

ALR* [A]WS [L]amba [R]untime? Maybe you already have some sort of common prefix? In SwiftNIO of course we use NIO for that purpose.

from swift-aws-lambda-runtime.

weissi avatar weissi commented on June 29, 2024

Of course that makes the type names a bit ugly. How are the users most commonly interfacing with those types?

from swift-aws-lambda-runtime.

fabianfett avatar fabianfett commented on June 29, 2024

normally we namespace under the Lambda

from swift-aws-lambda-runtime.

weissi avatar weissi commented on June 29, 2024

sounds good Lambda*?

from swift-aws-lambda-runtime.

fabianfett avatar fabianfett commented on June 29, 2024

well i'd put them in Lambda.* then

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 AWSHTTPTypes. But this could also create a naming conflict with the AWS SDK.

from swift-aws-lambda-runtime.

adam-fowler avatar adam-fowler commented on June 29, 2024

@fabianfett There isnt any AWSHTTPTypes and I'm not intending to add any. Even if I did, we'll be able to discriminate between them using the framework name. I'm trying to use the NIO types as much as possible

from swift-aws-lambda-runtime.

helje5 avatar helje5 commented on June 29, 2024

the latter are designed for JSON payload decoding/encoding

what? :-)

Apart from all the duping, wouldn’t you want to use the NIO types in the public API?
(not that this is necessary, but if you want, you could still use those types internally)

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?

from swift-aws-lambda-runtime.

tomerd avatar tomerd commented on June 29, 2024

@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.

cc @weissi @fabianfett

from swift-aws-lambda-runtime.

helje5 avatar helje5 commented on June 29, 2024

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:

https://github.com/SwiftBlocksUI/SwiftBlocksUI/blob/develop/Sources/SlackBlocksModel/InteractiveRequest/BlockActions.swift#L92

As mentioned in the Slack, a reasonable argument for the duping is that NIO isn't actually necessary for Lambdas. Don't know.

from swift-aws-lambda-runtime.

tomerd avatar tomerd commented on June 29, 2024

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:

I guess if we decide to adopt the NIO types after all we could also use property wrappers

As mentioned in the Slack, a reasonable argument for the duping is that NIO isn't actually necessary for Lambdas. Don't know.

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

from swift-aws-lambda-runtime.

helje5 avatar helje5 commented on June 29, 2024

there is the argument of copying so we need to trade that off
They are not even plain copies, e.g. the AWS method is a struct (which is actually the better choice), while the NIO one is an enum w/ an associated type. It's crap and weird if you need to convert them back.

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.
Yes, AWS breaks out headers in weird ways (single/multi value), but there is no real reason to not combine them back into NIO headers after decoding.

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.

from swift-aws-lambda-runtime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.