B potsbo’s staging cluster @morux2’s Laptop Service C Service A Service B morux2’s staging cluster NG : 1 ਓͣͭʹΫϥελΛ༩͑Δͷ͍ͬͨͳ͍ Service A 2 ਓͱಉ͡ͷΛ༻͍ͯ͠Δ Service B’ Service C’
ͳ request ͷ header ΛಡΈऔΓ module Servicex::Context class RackMiddleware def initialize(app) @app = app end def call(env) env.each do |key, value| next unless Servicex::Context.should_propagate?(key) Servicex::Context::Store.save(key, value) end @app.call(env) ensure Servicex::Context::Store.clear! end end end ϦΫΤετฦ٫࣌ʹফ͢ Thread.current ͷ wrapper ʹΛอଘ
initialize(app) @app = app end def call(env) Servicex::Context::Store.keys.each do |k| env[:request_headers][k] = Servicex::Context::Store.get(k) end @app.call(env) end end end ϔομൖ - Ruby Faraday Middleware Ͱ outgoing ͳ request ʹ header Λ༩
ͷྫ֎ରԠ͕Γ͍ͯͳ͍ ඇಉظ job ͳͲͰϔομʔ్͕ΕΔࣄ͕͋Δ ΫϥελڥมΛ͏ͱRAILS_ENV Λ͏·͘Βͳ͍ͱ dev server ͕ىಈ͠ͳ͍ ࢁੵΈͳͷͰࣾάϩʔε׆ಈத Ͳͷ service ʹର͢Δ virtual service Λఆٛͨ͠ΒΑ͍͔Λ͍ͬͯΔඞཁ͕͋Δ