Skip to content
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

http: deprecate more of coding infrastructure #3294

Merged
merged 9 commits into from
Jun 25, 2020

Conversation

jrudolph
Copy link
Member

@jrudolph jrudolph commented Jun 24, 2020

Refs #2916

Previously, we exposed Scala objects as API directly which exposes implementation
details and makes it hard to evolve the implementation. Instances in coders
are upcasted to Coder so that implementation details are not leaked any more.

@jrudolph jrudolph requested a review from raboof June 24, 2020 14:42
@jrudolph jrudolph force-pushed the 2916-deprecate-more-compression-infra branch from 269cf49 to 90dd6a4 Compare June 24, 2020 14:43
@akka-ci akka-ci added the validating PR that is currently being validated by Jenkins label Jun 24, 2020
…zip etc

Refs akka#2916

Previously, we exposed Scala objects as API directly which exposes implementation
details and makes it hard to evolve the implementation. Instances in coders
are upcasted to `Coder` so that implementation details are not leaked any more.
@jrudolph jrudolph force-pushed the 2916-deprecate-more-compression-infra branch from 90dd6a4 to 2718dee Compare June 24, 2020 14:44
@akka-ci akka-ci added needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins and removed validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) labels Jun 24, 2020
@akka-ci
Copy link

akka-ci commented Jun 24, 2020

Test FAILed.

!!! Couldn't read commit file !!!

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Jun 24, 2020
@akka-ci
Copy link

akka-ci commented Jun 24, 2020

Test FAILed.

!!! Couldn't read commit file !!!

Copy link
Member

@ennru ennru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) labels Jun 24, 2020
@ennru
Copy link
Member

ennru commented Jun 24, 2020

The doc examples show Gzip.withLevel(9) which I silenced for now.

@akka-ci akka-ci added needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed validating PR that is currently being validated by Jenkins labels Jun 24, 2020
@akka-ci
Copy link

akka-ci commented Jun 24, 2020

Test FAILed.

Pull request validation report

Failed Test Suites

Test result for 'akka-http-tests / Pr-validation / ./ executeTests'

[info] ScalaTest
[info] Run completed in 3 minutes, 21 seconds.
[info] Total number of tests run: 1243
[info] Suites: completed 63, aborted 0
[info] Tests: succeeded 1237, failed 6, canceled 0, ignored 0, pending 39
[info] *** 6 TESTS FAILED ***
[error] Failed: Total 1400, Failed 8, Errors 0, Passed 1392, Pending 39
[error] Failed tests:
[error] 	akka.http.scaladsl.server.directives.CodingDirectivesSpec
[error] 	akka.http.javadsl.server.directives.CodingDirectivesTest
[error] 	akka.http.scaladsl.coding.GzipSpec

Test result for 'docs / Pr-validation / ./ executeTests'

[info] ScalaTest
[info] Run completed in 3 minutes, 20 seconds.
[info] Total number of tests run: 291
[info] Suites: completed 60, aborted 0
[info] Tests: succeeded 289, failed 2, canceled 0, ignored 0, pending 0
[info] *** 2 TESTS FAILED ***
[error] Failed: Total 511, Failed 4, Errors 0, Passed 494, Skipped 13
[error] Failed tests:
[error] 	docs.http.javadsl.server.directives.CodingDirectivesExamplesTest
[error] 	docs.http.scaladsl.server.directives.CodingDirectivesExamplesSpec

import scala.collection.immutable

@silent("in package coding is deprecated")
object Coders {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure follows the javadsl more closely. However, on the java side, they part of enum Coder (singular term). Should we move those into the Coder companion object as well? In other parts of the (model) API, we tried to put those instances into a plural-named object, so that's why I went with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to be consistent with e.g. StatusCodes I think, indeed

def encode(input: ByteString): ByteString = newCompressor.compressAndFinish(input)

def encodeAsync(input: ByteString)(implicit mat: Materializer): Future[ByteString] =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the non-async version is already taken, so it's slightly inconsistent between decoding and encoding side.

@jrudolph
Copy link
Member Author

The doc examples show Gzip.withLevel(9) which I silenced for now.

Thanks, I tried to go through the warnings, but it seems adding a deprecation didn't recompile dependencies so I missed all of those.

@akka-ci akka-ci removed the validating PR that is currently being validated by Jenkins label Jun 25, 2020
@akka-ci
Copy link

akka-ci commented Jun 25, 2020

Test FAILed.

Pull request validation report

Failed Test Suites

Test result for 'akka-http-tests / Pr-validation / ./ executeTests'

[info] ScalaTest
[info] Run completed in 3 minutes, 23 seconds.
[info] Total number of tests run: 1243
[info] Suites: completed 63, aborted 0
[info] Tests: succeeded 1237, failed 6, canceled 0, ignored 0, pending 39
[info] *** 6 TESTS FAILED ***
[error] Failed: Total 1400, Failed 8, Errors 0, Passed 1392, Pending 39
[error] Failed tests:
[error] 	akka.http.scaladsl.server.directives.CodingDirectivesSpec
[error] 	akka.http.javadsl.server.directives.CodingDirectivesTest
[error] 	akka.http.scaladsl.coding.GzipSpec

Test result for 'docs / Pr-validation / ./ executeTests'

[info] ScalaTest
[info] Run completed in 3 minutes, 22 seconds.
[info] Total number of tests run: 291
[info] Suites: completed 60, aborted 0
[info] Tests: succeeded 289, failed 2, canceled 0, ignored 0, pending 0
[info] *** 2 TESTS FAILED ***
[error] Failed: Total 511, Failed 4, Errors 0, Passed 494, Skipped 13
[error] Failed tests:
[error] 	docs.http.javadsl.server.directives.CodingDirectivesExamplesTest
[error] 	docs.http.scaladsl.server.directives.CodingDirectivesExamplesSpec

It seems `encodeAsync` which is now used for comparison is slightly
less efficient than the previous sync version
def Gzip: Coder = akka.http.scaladsl.coding.Gzip
def Gzip(messageFilter: HttpMessage => Boolean): Coder = new Gzip(messageFilter)

def Deflate: Coder = akka.http.scaladsl.coding.Gzip
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Jun 25, 2020
@akka-ci
Copy link

akka-ci commented Jun 25, 2020

Test FAILed.

!!! Couldn't read commit file !!!

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR that is currently being validated by Jenkins labels Jun 25, 2020
@akka-ci
Copy link

akka-ci commented Jun 25, 2020

Test PASSed.

import scala.collection.immutable

@silent("in package coding is deprecated")
object Coders {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to be consistent with e.g. StatusCodes I think, indeed

import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers.HttpEncodings

class Gzip private (compressionLevel: Int, val messageFilter: HttpMessage => Boolean) extends Coder with StreamDecoder {
@InternalApi
@deprecated("Actual implementation of Gzip is internal, use Coders.Gzip instead", since = "10.2.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit strange to mark internal API as deprecated, but indeed as it used to be public API I guess it makes sense 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, guess I went over the top with deprecating stuff, just to be sure. Maybe we can create an internal copy later as the future version while keeping that one around only for compatibility.

@ennru
Copy link
Member

ennru commented Jun 25, 2020

I did another round on this to use the non-deprecated variants in the tests.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR that is currently being validated by Jenkins labels Jun 25, 2020
@akka-ci
Copy link

akka-ci commented Jun 25, 2020

Test PASSed.

@jrudolph
Copy link
Member Author

I did another round on this to use the non-deprecated variants in the tests.

Thanks, much appreciated :)

I'm planning to do a more thorough review of warnings and documentation for 10.2.0 next week.

@jrudolph jrudolph changed the title http: deprecate more of coding infrastructure, coders now in Coders.Gzip etc http: deprecate more of coding infrastructure Jun 25, 2020
@jrudolph jrudolph merged commit bd818e2 into akka:master Jun 25, 2020
@jrudolph jrudolph deleted the 2916-deprecate-more-compression-infra branch June 25, 2020 11:31
@jrudolph jrudolph added this to the 10.2.0 milestone Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants