Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

implement new streamwriter api#291

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
artemredkin wants to merge2 commits intoswift-server:main
base:main
Choose a base branch
Loading
fromartemredkin:revamp_stream_writer

Conversation

@artemredkin
Copy link
Collaborator

@artemredkinartemredkin commentedAug 6, 2020
edited
Loading

🚧 This is slightly WIP.
RevampsStreamWriter.

Motivation:
There are two issues with currentStreamWriter API:

  1. no access to allocator
  2. writer completion is super confusing, it will be considered finished when the returnedEventLoopFuture is completed, which is not ideal.

Modifications:

  1. Deprecate oldStreamWriter API
  2. Introduce new typeStreamWriter2 (really need help with the naming here) with the following API:
letbody:HTTPClient.Body=.stream2(length:8){ writer in    writer.write(writer.allocator.buffer(string:"1234").whenComplete{ _ in        writer.write(writer.allocator.buffer(string:"1234").whenComplete{ _in            writer.end()}}}

Result:
Closes#194
Closes#264

@artemredkinartemredkin added this to the1.2.0 milestoneAug 6, 2020
@artemredkinartemredkinforce-pushed therevamp_stream_writer branch 2 times, most recently from5924d12 to0cb498aCompareAugust 6, 2020 16:09
/// - length: Body size. Request validation will be failed with `HTTPClientErrors.contentLengthMissing` if nil,
/// unless `Transfer-Encoding: chunked` header is set.
/// - stream: Body chunk provider.
publicstaticfunc stream2(length:Int?=nil, _ stream:@escaping(StreamWriter2)->Void)->Body{
Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

I we add method with the same name but different type we will break compilation, because some calls could become ambiguous 😢

Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that there is discussion about possibly breaking API in the nearish futureanyway, we may find we want to delay this until then to resolve this problem.

@artemredkinartemredkin modified the milestones:1.2.0,1.3.0Aug 7, 2020
publicstructStreamWriter2{
publicletallocator:ByteBufferAllocator
letonChunk:(IOData)->EventLoopFuture<Void>
letonComplete:EventLoopPromise<Void>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason we're writing this as a callback-taking type rather than just holding onto the task object?

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

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

and "forward" all write requests to it's channel? that might be a good idea, will try that, thanks!

/// - length: Body size. Request validation will be failed with `HTTPClientErrors.contentLengthMissing` if nil,
/// unless `Transfer-Encoding: chunked` header is set.
/// - stream: Body chunk provider.
publicstaticfunc stream2(length:Int?=nil, _ stream:@escaping(StreamWriter2)->Void)->Body{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that there is discussion about possibly breaking API in the nearish futureanyway, we may find we want to delay this until then to resolve this problem.

@ktosoktoso changed the base branch frommaster tomainAugust 20, 2020 01:31
@ktoso
Copy link
Contributor

Just as a heads up, the main development branch has been changed tomain, following theSwift policy on this.

This PR has been re-targeted to main and should just work. However when performing rebases etc please keep this in mind -- you may want to fetch the main branch and rebase onto themain branch from now on since master is not up-to-date anymore and is going to be deleted shortly.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@LukasaLukasaLukasa left review comments

@ktosoktosoAwaiting requested review from ktoso

@weissiweissiAwaiting requested review from weissi

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

1.3.0

Development

Successfully merging this pull request may close these issues.

StreamWriter API revamp: access to ByteBufferAllocator unclear docs: How to signal to StreamWriter that body is done?

3 participants

@artemredkin@ktoso@Lukasa

[8]ページ先頭

©2009-2025 Movatter.jp