soto-project / soto-core

Core framework of Soto the Swift SDK for AWS
https://soto.codes
Apache License 2.0
111 stars 51 forks source link

Remove dependency on Foundation #344

Open pokryfka opened 4 years ago

pokryfka commented 4 years ago

Is your feature request related to a problem? Please describe. Dependency on Foundation affects significantly cold start.

Describe the solution you'd like

Additional context

pokryfka commented 4 years ago

CC @fabianfett

adam-fowler commented 4 years ago

I think you need to break this up into separate tasks. This is a huge task which would require us to replace

URL, Date, DateFormatter, NSRegularExpression, JSONEncoder, CharacterSet, UUID, ContiguousBytes, DataProtocol

You would also need a FoundationCompat library to provide the interfaces that require Foundation. eg AWSPayload conversion to and from Data

One thing that might hold all of this back though is swift-crypto pulls in Foundation, I'm not sure how you want to resolve that one.

There is an argument for doing some of this work still. We could look at replacing the JSONEncoder. I'm sure @fabianfett would be really keen on this.

fabianfett commented 4 years ago

One thing that might hold all of this back though is swift-crypto pulls in Foundation, I'm not sure how you want to resolve that one.

Same is true for AsyncHTTPClient

There is an argument for doing some of this work still. We could look at replacing the JSONEncoder. I'm sure @fabianfett would be really keen on this.

I think it would be enough to make the default JSONEncoder and JSONDecoder replaceable.

Also I have an offering to replace UUID: https://github.com/fabianfett/swift-extras-uuid

adam-fowler commented 4 years ago

Same is true for AsyncHTTPClient

Good point. Removing Foundation from AHC would be a good starting point but someone needs to do an implementation of Date first and that would be a huge undertaking. And getting SSWG to accept it would be even harder. I think it would be enough to make the default JSONEncoder and JSONDecoder replaceable.

Should be easy enough. Also I have an offering to replace UUID: https://github.com/fabianfett/swift-extras-uuid

You can go ahead, although given we can't remove Foundation in the foreseeable future is this necessary? What do we gain, except less exposure.

pokryfka commented 4 years ago

@adam-fowler @fabianfett

thank you for your feedback and identifying the main problems.

Good point. Removing Foundation from AHC would be a good starting point but someone needs to do an implementation of Date first and that would be a huge undertaking. And getting SSWG to accept it would be even harder.

Had a (very) quick lock at AsyncHTTPClient and it seems:

So technically its some work but probably not a huge effort - dumping a timestamp is much smaller task than rewriting Date; I will play with in spare time (low priority), this should give me a better understanding of the "not using Foundation" challenges. I understand that such PR could be never approved...

adam-fowler commented 4 years ago

I understand that such PR could be never approved...

I wouldn't be so sure of that. If you can produce a PR which removes Foundation I think there will be people sympathetic to it.

adam-fowler commented 4 years ago

https://github.com/swift-server/async-http-client/issues/299