Skip to content
Snippets Groups Projects
Select Git revision
  • 19e3f04cad4bbfee9c07c010af42014a74ee4cbb
  • release default
  • master protected
  • XX-4441
  • Jakub/rootless-CI
  • Anne/CI-Test
  • waitingRoundsRewrite
  • quantumSecure
  • fullRateLimit
  • XX-3564/TlsCipherSuite
  • hotfix/groupNotification
  • Josh/RateLimiting
  • debug/sourceOfErrors
  • XX-3540/TestCert
  • f76/error
  • notls
  • url-repo-rename
  • feature/dynamicAuthRemoval
  • jono/yaml
  • version-2_5_3
  • hotfix/signing
  • v3.13.0
  • v3.11.0
  • v3.10.0
  • v3.9.0
  • v3.7.0
  • v3.6.0
  • v3.5.0
  • v3.1.0
  • v2.2.8
  • v2.2.7
  • v2.1.0
  • v2.0.0
  • v1.7.0
  • v1.6.0
  • v1.5.0
  • v1.4.2
  • v1.4.1
  • v1.4.0
  • v1.3.2
  • v1.3.1
41 results

metrics.go

Blame
  • ServiceProcessor.swift 1.42 KiB
    import Bindings
    import XCTestDynamicOverlay
    
    public struct ServiceProcessor {
      public typealias Process = (
        _ message: Data,
        _ receptionId: Data,
        _ ephemeralId: Int64,
        _ roundId: Int64
      ) -> Void
    
      public init(serviceTag: String, process: @escaping Process) {
        self.serviceTag = serviceTag
        self.process = process
      }
    
      public var serviceTag: String
      public var process: Process
    }
    
    extension ServiceProcessor {
      public static let unimplemented = ServiceProcessor(
        serviceTag: "unimplemented",
        process: XCTUnimplemented("\(Self.self).process")
      )
    }
    
    extension ServiceProcessor {
      func makeBindingsProcessor() -> BindingsProcessorProtocol {
        class Processor: NSObject, BindingsProcessorProtocol {
          init(_ serviceProcessor: ServiceProcessor) {
            self.serviceProcessor = serviceProcessor
          }
    
          let serviceProcessor: ServiceProcessor
    
          func process(_ message: Data?, receptionId: Data?, ephemeralId: Int64, roundId: Int64) {
            guard let message = message else {
              fatalError("BindingsProcessor.process received `nil` message")
            }
            guard let receptionId = receptionId else {
              fatalError("BindingsProcessor.process received `nil` receptionId")
            }
            serviceProcessor.process(message, receptionId, ephemeralId, roundId)
          }
    
          func string() -> String {
            serviceProcessor.serviceTag
          }
        }
    
        return Processor(self)
      }
    }