1414 * limitations under the License.
1515 */
1616
17- /// A `ServerInterceptorOperation ` describes to which RPCs a server interceptor should be applied.
17+ /// A `ServerInterceptorPipelineOperation ` describes to which RPCs a server interceptor should be applied.
1818///
1919/// You can configure a server interceptor to be applied to:
2020/// - all RPCs and services;
2121/// - requests directed only to specific services registered with your server; or
2222/// - requests directed only to specific methods (of a specific service).
2323///
2424/// - SeeAlso: ``ServerInterceptor`` for more information on server interceptors, and
25- /// ``ClientInterceptorOperation `` for the client-side version of this type.
26- public struct ServerInterceptorOperation : Sendable {
27- /// The subject of a ``ServerInterceptorOperation ``.
25+ /// ``ClientInterceptorPipelineOperation `` for the client-side version of this type.
26+ public struct ServerInterceptorPipelineOperation : Sendable {
27+ /// The subject of a ``ServerInterceptorPipelineOperation ``.
2828 /// The subject of an interceptor can either be all services and methods, only specific services, or only specific methods.
2929 public struct Subject : Sendable {
3030 internal enum Wrapped : Sendable {
3131 case all
32- case services( [ ServiceDescriptor ] )
33- case methods( [ MethodDescriptor ] )
32+ case services( Set < ServiceDescriptor > )
33+ case methods( Set < MethodDescriptor > )
3434 }
3535
3636 private let wrapped : Wrapped
@@ -41,19 +41,20 @@ public struct ServerInterceptorOperation: Sendable {
4141 /// An operation subject specifying an interceptor that will be applied only to RPCs directed to the specified services.
4242 /// - Parameters:
4343 /// - services: The list of service names for which this interceptor should intercept RPCs.
44- /// - Returns: A ``ServerInterceptorOperation ``.
45- public static func services( _ services: [ ServiceDescriptor ] ) -> Self {
44+ /// - Returns: A ``ServerInterceptorPipelineOperation ``.
45+ public static func services( _ services: Set < ServiceDescriptor > ) -> Self {
4646 Self ( wrapped: . services( services) )
4747 }
4848
4949 /// An operation subject specifying an interceptor that will be applied only to RPCs directed to the specified service methods.
5050 /// - Parameters:
5151 /// - methods: The list of method descriptors for which this interceptor should intercept RPCs.
52- /// - Returns: A ``ServerInterceptorOperation ``.
53- public static func methods( _ methods: [ MethodDescriptor ] ) -> Self {
52+ /// - Returns: A ``ServerInterceptorPipelineOperation ``.
53+ public static func methods( _ methods: Set < MethodDescriptor > ) -> Self {
5454 Self ( wrapped: . methods( methods) )
5555 }
5656
57+ @usableFromInline
5758 internal func applies( to descriptor: MethodDescriptor ) -> Bool {
5859 switch self . wrapped {
5960 case . all:
@@ -71,7 +72,8 @@ public struct ServerInterceptorOperation: Sendable {
7172 /// The interceptor specified for this operation.
7273 public let interceptor : any ServerInterceptor
7374
74- private let subject : Subject
75+ @usableFromInline
76+ internal let subject : Subject
7577
7678 private init ( interceptor: any ServerInterceptor , appliesTo: Subject ) {
7779 self . interceptor = interceptor
@@ -82,15 +84,16 @@ public struct ServerInterceptorOperation: Sendable {
8284 /// - Parameters:
8385 /// - interceptor: The ``ServerInterceptor`` to register with the server.
8486 /// - subject: The ``Subject`` to which the `interceptor` applies.
85- /// - Returns: A ``ServerInterceptorOperation ``.
87+ /// - Returns: A ``ServerInterceptorPipelineOperation ``.
8688 public static func apply( _ interceptor: any ServerInterceptor , to subject: Subject ) -> Self {
8789 Self ( interceptor: interceptor, appliesTo: subject)
8890 }
8991
90- /// Returns whether this ``ServerInterceptorOperation `` applies to the given `descriptor`.
92+ /// Returns whether this ``ServerInterceptorPipelineOperation `` applies to the given `descriptor`.
9193 /// - Parameter descriptor: A ``MethodDescriptor`` for which to test whether this interceptor applies.
9294 /// - Returns: `true` if this interceptor applies to the given `descriptor`, or `false` otherwise.
93- public func _applies( to descriptor: MethodDescriptor ) -> Bool {
95+ @inlinable
96+ internal func applies( to descriptor: MethodDescriptor ) -> Bool {
9497 self . subject. applies ( to: descriptor)
9598 }
9699}
0 commit comments