Skip to content

Commit

Permalink
Add deprecation warnings for package-internal APIs
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Rebello <[email protected]>
  • Loading branch information
rebello95 committed Oct 16, 2024
1 parent 69661a2 commit d13d949
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Libraries/Connect/PackageInternal/ConnectError+GRPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ extension ConnectError {
/// passed in the headers block for gRPC-Web.
///
/// - returns: A tuple containing the gRPC status code and an optional error.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public static func parseGRPCHeaders(
_ headers: Headers?, trailers: Trailers?
) -> (grpcCode: Code, error: ConnectError?) {
Expand Down
30 changes: 30 additions & 0 deletions Libraries/Connect/PackageInternal/Envelope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ import SwiftProtobuf
/// to change. When the compiler supports it, this should be package-internal.**
///
/// Provides functionality for packing and unpacking (headers and length prefixed) messages.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public enum Envelope {
/// The total number of bytes that will prefix a message.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public static var prefixLength: Int {
return 5 // Header flags (1 byte) + message length (4 bytes)
}
Expand All @@ -35,6 +45,11 @@ public enum Envelope {
/// - parameter compression: Configuration to use for compressing the message.
///
/// - returns: Serialized/enveloped data for transmission.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public static func packMessage(
_ source: Data, using compression: ProtocolClientConfig.RequestCompression?
) -> Data {
Expand Down Expand Up @@ -70,6 +85,11 @@ public enum Envelope {
///
/// - returns: A tuple that includes the header byte and the un-prefixed and decompressed
/// message.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public static func unpackMessage(
_ source: Data, compressionPool: CompressionPool?
) throws -> (headerByte: UInt8, unpacked: Data) {
Expand All @@ -96,6 +116,11 @@ public enum Envelope {
/// - parameter packedData: The packed data to analyze.
///
/// - returns: True if the data is compressed.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public static func isCompressed(_ packedData: Data) -> Bool {
return !packedData.isEmpty && (0b00000001 & packedData[0] != 0)
}
Expand All @@ -111,6 +136,11 @@ public enum Envelope {
/// - returns: The length of the next expected message in the packed data. If multiple chunks
/// are specified, this will return the length of the first. Returns -1 if there is
/// not enough prefix data to determine the message length.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public static func messageLength(forPackedData data: Data) -> Int {
guard data.count >= self.prefixLength else {
return -1
Expand Down
5 changes: 5 additions & 0 deletions Libraries/Connect/PackageInternal/Headers+GRPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ extension Headers {
/// - parameter grpcWeb: Should be true if using gRPC-Web, false if gRPC.
///
/// - returns: A set of updated headers.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public func addingGRPCHeaders(using config: ProtocolClientConfig, grpcWeb: Bool) -> Self {
var headers = self
headers[HeaderConstants.grpcAcceptEncoding] = config
Expand Down
5 changes: 5 additions & 0 deletions Libraries/Connect/PackageInternal/Trailers+gRPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ extension Trailers {
/// Identifies the status code from gRPC and gRPC-Web trailers.
///
/// - returns: The gRPC status code, if specified.
@available(
swift,
deprecated: 100.0,
message: "This is an internal-only API which will be made package-private in Swift 6."
)
public func grpcStatus() -> Code? {
return self[HeaderConstants.grpcStatus]?
.first
Expand Down

0 comments on commit d13d949

Please sign in to comment.