Skip to content

Commit c8f0c65

Browse files
committed
Buffer implementation
1 parent 0f15c3f commit c8f0c65

File tree

10 files changed

+20
-65
lines changed

10 files changed

+20
-65
lines changed

runtime/auth/aws-signing-default/common/src/aws/smithy/kotlin/runtime/auth/awssigning/Canonicalizer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import aws.smithy.kotlin.runtime.http.request.HttpRequest
1212
import aws.smithy.kotlin.runtime.http.request.HttpRequestBuilder
1313
import aws.smithy.kotlin.runtime.http.request.toBuilder
1414
import aws.smithy.kotlin.runtime.io.*
15-
import aws.smithy.kotlin.runtime.io.internal.SdkDispatchers
1615
import aws.smithy.kotlin.runtime.net.url.QueryParameters
1716
import aws.smithy.kotlin.runtime.net.url.Url
1817
import aws.smithy.kotlin.runtime.net.url.UrlPath
1918
import aws.smithy.kotlin.runtime.text.encoding.Encodable
2019
import aws.smithy.kotlin.runtime.text.encoding.PercentEncoding
2120
import aws.smithy.kotlin.runtime.text.encoding.encodeToHex
2221
import aws.smithy.kotlin.runtime.time.TimestampFormat
22+
import kotlinx.coroutines.Dispatchers
23+
import kotlinx.coroutines.IO
2324
import kotlinx.coroutines.withContext
2425

2526
/**
@@ -162,7 +163,7 @@ internal class DefaultCanonicalizer(private val sha256Supplier: HashSupplier = :
162163
}
163164
is HttpBody.SourceContent -> {
164165
val source = readFrom()
165-
withContext(SdkDispatchers.IO) {
166+
withContext(Dispatchers.IO) {
166167
source.sha256().encodeToHex()
167168
}
168169
}

runtime/protocol/http-client-engines/http-client-engine-crt/jvmAndNative/src/aws/smithy/kotlin/runtime/http/engine/crt/CrtHttpEngine.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
1111
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngineBase
1212
import aws.smithy.kotlin.runtime.http.engine.callContext
1313
import aws.smithy.kotlin.runtime.http.request.HttpRequest
14-
import aws.smithy.kotlin.runtime.io.internal.SdkDispatchers
1514
import aws.smithy.kotlin.runtime.operation.ExecutionContext
1615
import aws.smithy.kotlin.runtime.telemetry.logging.logger
1716
import aws.smithy.kotlin.runtime.time.Instant
@@ -84,7 +83,7 @@ public class CrtHttpEngine(public override val config: CrtHttpEngineConfig) : Ht
8483
}
8584

8685
if (request.isChunked) {
87-
withContext(SdkDispatchers.IO) {
86+
withContext(Dispatchers.IO) {
8887
stream.sendChunkedBody(request.body)
8988
}
9089
}

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/content/ByteStream.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
package aws.smithy.kotlin.runtime.content
66

77
import aws.smithy.kotlin.runtime.io.*
8-
import aws.smithy.kotlin.runtime.io.internal.SdkDispatchers
98
import kotlinx.coroutines.CoroutineScope
9+
import kotlinx.coroutines.Dispatchers
10+
import kotlinx.coroutines.IO
1011
import kotlinx.coroutines.flow.*
1112
import kotlinx.coroutines.launch
1213

@@ -119,7 +120,7 @@ public fun ByteStream.cancel() {
119120
public fun ByteStream.toFlow(bufferSize: Long = 8192): Flow<ByteArray> = when (this) {
120121
is ByteStream.Buffer -> flowOf(bytes())
121122
is ByteStream.ChannelStream -> readFrom().toFlow(bufferSize)
122-
is ByteStream.SourceStream -> readFrom().toFlow(bufferSize).flowOn(SdkDispatchers.IO)
123+
is ByteStream.SourceStream -> readFrom().toFlow(bufferSize).flowOn(Dispatchers.IO)
123124
}
124125

125126
/**

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/io/SdkByteReadChannel.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
*/
55
package aws.smithy.kotlin.runtime.io
66

7-
import aws.smithy.kotlin.runtime.io.internal.SdkDispatchers
7+
import kotlinx.coroutines.Dispatchers
8+
import kotlinx.coroutines.IO
89
import kotlinx.coroutines.withContext
910

1011
/**
@@ -104,7 +105,7 @@ public suspend fun SdkByteReadChannel.readToBuffer(): SdkBuffer {
104105
/**
105106
* Read all bytes from this channel into [sink]. Returns the total number of bytes written.
106107
*/
107-
public suspend fun SdkByteReadChannel.readAll(sink: SdkSink): Long = withContext(SdkDispatchers.IO) {
108+
public suspend fun SdkByteReadChannel.readAll(sink: SdkSink): Long = withContext(Dispatchers.IO) {
108109
val bufferedSink = sink.buffer()
109110
var totalWritten = 0L
110111
while (true) {
@@ -120,7 +121,7 @@ public suspend fun SdkByteReadChannel.readAll(sink: SdkSink): Long = withContext
120121
/**
121122
* Removes all bytes from [source] and writes them to this channel. Returns the total number of bytes read.
122123
*/
123-
public suspend fun SdkByteWriteChannel.writeAll(source: SdkSource): Long = withContext(SdkDispatchers.IO) {
124+
public suspend fun SdkByteWriteChannel.writeAll(source: SdkSource): Long = withContext(Dispatchers.IO) {
124125
val buffer = SdkBuffer()
125126
var totalRead = 0L
126127
while (true) {

runtime/runtime-core/common/src/aws/smithy/kotlin/runtime/io/internal/SdkDispatchers.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

runtime/runtime-core/jvm/src/aws/smithy/kotlin/runtime/io/internal/SdkDispatchersJVM.kt

Lines changed: 0 additions & 15 deletions
This file was deleted.

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/io/BufferedSinkAdapterNative.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
*/
55
package aws.smithy.kotlin.runtime.io
66

7-
internal actual class BufferedSinkAdapter actual constructor(sink: okio.BufferedSink) : SdkBufferedSink, AbstractBufferedSinkAdapter(sink)
7+
internal actual class BufferedSinkAdapter actual constructor(sink: okio.BufferedSink) :
8+
AbstractBufferedSinkAdapter(sink),
9+
SdkBufferedSink

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/io/BufferedSourceAdapterNative.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
*/
55
package aws.smithy.kotlin.runtime.io
66

7-
internal actual class BufferedSourceAdapter actual constructor(source: okio.BufferedSource) : SdkBufferedSource, AbstractBufferedSourceAdapter(source)
7+
internal actual class BufferedSourceAdapter actual constructor(source: okio.BufferedSource) :
8+
AbstractBufferedSourceAdapter(source),
9+
SdkBufferedSource

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/io/SdkBufferNative.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public actual class SdkBuffer :
5959

6060
actual override fun flush(): Unit = commonFlush()
6161

62-
actual override fun emit() { inner.emit() }
62+
actual override fun emit() {
63+
inner.emit()
64+
}
6365

6466
actual override fun skip(byteCount: Long): Unit = commonSkip(byteCount)
6567

runtime/runtime-core/native/src/aws/smithy/kotlin/runtime/io/internal/SdkDispatchersNative.kt

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)