Skip to content

Commit

Permalink
Make the router's API public for use in benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Joannis committed May 13, 2024
1 parent 3a7a2f5 commit ee0dce5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Benchmarks/Benchmarks/Router/RouterBenchmarks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import HTTPTypes
import Hummingbird
import NIOEmbedded
import NIOHTTPTypes
@_spi(Internal) import HummingbirdCore
import HummingbirdCore
import Logging
import NIOCore
import NIOPosix
Expand Down
7 changes: 4 additions & 3 deletions Sources/Hummingbird/Router/Trie/RouterTrie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ struct Trie: Sendable {
init() {}
}

@usableFromInline
internal final class RouterTrie<Value: Sendable>: Sendable {
@_documentation(visibility: internal)
public final class RouterTrie<Value: Sendable>: Sendable {
@usableFromInline
let trie: Trie

@usableFromInline
let values: [Value?]

internal init(base: RouterPathTrieBuilder<Value>) {
@_documentation(visibility: internal)
public init(base: RouterPathTrieBuilder<Value>) {
var trie = Trie()
var values: [Value?] = []

Expand Down
4 changes: 2 additions & 2 deletions Sources/Hummingbird/Router/Trie/Trie+resolve.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import NIOCore

extension RouterTrie {
/// Resolve a path to a `Value` if available
@usableFromInline
internal func resolve(_ path: String) -> (value: Value, parameters: Parameters)? {
@inlinable
public func resolve(_ path: String) -> (value: Value, parameters: Parameters)? {
let pathComponents = path.split(separator: "/", omittingEmptySubsequences: true)
var pathComponentsIterator = pathComponents.makeIterator()
var parameters = Parameters()
Expand Down
7 changes: 5 additions & 2 deletions Sources/Hummingbird/Router/TrieRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import HummingbirdCore

/// URI Path Trie Builder
@_spi(Internal) public struct RouterPathTrieBuilder<Value: Sendable> {
@_documentation(visibility: internal)
public struct RouterPathTrieBuilder<Value: Sendable> {
@usableFromInline
var root: Node

@_documentation(visibility: internal)
public init() {
self.root = Node(key: .null, output: nil)
}
Expand Down Expand Up @@ -50,7 +52,8 @@ import HummingbirdCore
}

/// Trie Node. Each node represents one component of a URI path
@_spi(Internal) public final class Node {
@_documentation(visibility: internal)
public final class Node {
@usableFromInline
let key: RouterPath.Element

Expand Down
2 changes: 1 addition & 1 deletion Tests/HummingbirdTests/TrieRouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

@_spi(Internal) import Hummingbird
@testable import Hummingbird
import XCTest

class TrieRouterTests: XCTestCase {
Expand Down

0 comments on commit ee0dce5

Please sign in to comment.