Sha256: 949e73f4884f0fa5986bbd60064198d7942466eb9b2d862f81f90cd70005bcc6
Contents?: true
Size: 1.55 KB
Versions: 4
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true module GrpcKit module Interceptors module Client class Streaming def initialize(interceptors) @interceptors = interceptors end def intercept(call, metadata, &block) if @interceptors && !@interceptors.empty? do_intercept(@interceptors.dup, call, metadata, &block) else yield(call, metadata) end end private def do_intercept(interceptors, call, metadata) if interceptors.empty? return yield(call, metadata) end interceptor = interceptors.pop invoke(interceptor, call, metadata) do |inter_call, meta| do_intercept(interceptors, inter_call, meta) do |c, m| yield(c, m) end end end end end module Server class Streaming def initialize(interceptors) @interceptors = interceptors end def intercept(call, &block) if @interceptors && !@interceptors.empty? do_intercept(@interceptors.dup, call, &block) else yield(call) end end private def do_intercept(interceptors, call) if interceptors.empty? return yield(call) end interceptor = interceptors.pop invoke(interceptor, call) do |inter_call| do_intercept(interceptors, inter_call) do |c| yield(c) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
grpc_kit-0.1.8 | lib/grpc_kit/interceptors.rb |
grpc_kit-0.1.7 | lib/grpc_kit/interceptors.rb |
grpc_kit-0.1.6 | lib/grpc_kit/interceptors.rb |
grpc_kit-0.1.5 | lib/grpc_kit/interceptors.rb |