Skip to content

Commit

Permalink
Increase stream payload delay to 20ms.
Browse files Browse the repository at this point in the history
  • Loading branch information
jshier committed Aug 18, 2023
1 parent e5adbe5 commit 3cca255
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/async-kit.git",
"state" : {
"revision" : "a61da00d404ec91d12766f1b9aac7d90777b484d",
"version" : "1.17.0"
"revision" : "eab9edff78e8ace20bd7cb6e792ab46d54f59ab9",
"version" : "1.18.0"
}
},
{
Expand All @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/routing-kit.git",
"state" : {
"revision" : "611bc45c5dfb1f54b84d99b89d1f72191fb6b71b",
"version" : "4.7.2"
"revision" : "e0539da5b60a60d7381f44cdcf04036f456cee2f",
"version" : "4.8.0"
}
},
{
Expand Down Expand Up @@ -86,17 +86,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "33a20e650c33f6d72d822d558333f2085effa3dc",
"version" : "2.5.0"
"revision" : "60f13f60c4d093691934dc6cfdf5f508ada1f894",
"version" : "2.6.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
}
},
{
Expand All @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "a2e487b77f17edbce9a65f2b7415f2f479dc8e48",
"version" : "2.57.0"
"revision" : "cf281631ff10ec6111f2761052aa81896a83a007",
"version" : "2.58.0"
}
},
{
Expand All @@ -140,17 +140,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "e866a626e105042a6a72a870c88b4c531ba05f83",
"version" : "2.24.0"
"revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version" : "2.25.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "41f4098903878418537020075a4d8a6e20a0b182",
"version" : "1.17.0"
"revision" : "e7403c35ca6bb539a7ca353b91cc2d8ec0362d58",
"version" : "1.19.0"
}
},
{
Expand All @@ -167,8 +167,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "6b96684e150d3b3afcd53df12fe66e6bd9b67a04",
"version" : "4.78.0"
"revision" : "1bb4a2ed94bec7a92f92e82896408c785d068f5c",
"version" : "4.79.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Sources/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func createDataRoutes(for app: Application) throws {

let response = Response(body: .init(stream: { writer in
var bytesToSend = count
request.eventLoop.scheduleRepeatedTask(initialDelay: .seconds(0), delay: .milliseconds(1)) { task in
request.eventLoop.scheduleRepeatedTask(initialDelay: .seconds(0), delay: .milliseconds(20)) { task in
guard bytesToSend > 0 else { task.cancel(); _ = writer.write(.end); return }

_ = writer.write(.buffer(.init(integer: UInt8(bytesToSend))))
Expand All @@ -104,7 +104,7 @@ func createDataRoutes(for app: Application) throws {
let encodedReply = try encoder.encodeAsByteBuffer(reply, allocator: app.allocator)
let response = Response(body: .init(stream: { writer in
var payloadsToSend = count
request.eventLoop.scheduleRepeatedTask(initialDelay: .seconds(0), delay: .milliseconds(1)) { task in
request.eventLoop.scheduleRepeatedTask(initialDelay: .seconds(0), delay: .milliseconds(20)) { task in
guard payloadsToSend > 0 else { task.cancel(); _ = writer.write(.end); return }

_ = writer.write(.buffer(encodedReply))
Expand Down

0 comments on commit 3cca255

Please sign in to comment.