How Finagle Works
Finagle emphasizes modularity by stacking independent components together. Each component can be swapped in or out depending on the provided configuration. For example, tracers all implement the same interface. Thus, a tracer can be created to send tracing data to a local file, hold it in memory and expose a read endpoint, or write out to the network.
At the bottom of a Finagle stack is a Transport. A Transport represents a stream of objects that can be asynchronously read from and written to. Transports are implemented as Netty ChannelHandlers and inserted into the end of a ChannelPipeline. Finagle’s ChannelHandlerTransport manages Netty interest ops to propagate back pressure. When Finagle indicates that the service is ready to read, Netty reads data off the wire and runs it through the ChannelPipeline where they’re interpreted by a codec then sent to the Finagle Transport. From there, Finagle sends the message through its own stack.
For client connections, Finagle maintains a pool of transports across which it balances load. Depending on the semantics of the provided connection pool Finagle either requests a new connection from Netty or re-uses an existing one if it’s idle. When a new connection is requested, a Netty ChannelPipeline is created based on the client’s codec. Extra ChannelHandlers are added to the ChannelPipeline for stats, logging, and SSL. The connection is then handed to a channel transport which Finagle can write to and read from. If all connections are busy requests will be queued according to configurable queueing policies.
On the server side Netty manages the codec, stats, timeouts, and logging via a provided ChannelPipelineFactory. The last ChannelHandler in a server’s ChannelPipeline is a Finagle bridge. The bridge will watch for new incoming connections and create a new Transport for each one. The Transport wraps the new channel before it’s handed to a server implementation. Messages are then read out of the ChannelPipeline and sent to the implemented server instance.
Finagle วิธีการทำงานFinagle เน้น modularity โดยอิสระประกอบซ้อนกัน แต่ละส่วนสามารถจะสลับ หรือออกตามการกำหนดค่าให้ ตัวอย่าง tracers ทั้งหมดใช้อินเทอร์เฟซเดียวกัน ดังนั้น สามารถสร้างติดตามการส่งสืบค้นข้อมูลเป็นแฟ้มในเครื่อง เก็บไว้ในหน่วยความจำ และแสดงปลายทางอ่าน หรือเขียนออกไปยังเครือข่ายที่ด้านล่างของ Finagle มี กองเป็นการขนส่ง การขนส่งหมายถึงกระแสของวัตถุที่สามารถแบบอะซิงโครนัสอ่านจาก และเขียนไป ขนส่งจะนำมาใช้เป็น Netty ChannelHandlers และแทรกจุดสิ้นสุดของ ChannelPipeline Finagle ของ ChannelHandlerTransport จัดการดอกเบี้ย Netty ops สืบความดันย้อนกลับ เมื่อ Finagle บ่งชี้ว่า บริการพร้อมอ่าน Netty อ่านข้อมูลออกจากสาย และทำงานผ่าน ChannelPipeline ที่พวกเขากำลังตีความ โดยตัวแปลงสัญญาณแล้ว ส่งไปที่ขนส่ง Finagle จาก Finagle ส่งข้อความผ่านกองของตัวเองFor client connections, Finagle maintains a pool of transports across which it balances load. Depending on the semantics of the provided connection pool Finagle either requests a new connection from Netty or re-uses an existing one if it’s idle. When a new connection is requested, a Netty ChannelPipeline is created based on the client’s codec. Extra ChannelHandlers are added to the ChannelPipeline for stats, logging, and SSL. The connection is then handed to a channel transport which Finagle can write to and read from. If all connections are busy requests will be queued according to configurable queueing policies.On the server side Netty manages the codec, stats, timeouts, and logging via a provided ChannelPipelineFactory. The last ChannelHandler in a server’s ChannelPipeline is a Finagle bridge. The bridge will watch for new incoming connections and create a new Transport for each one. The Transport wraps the new channel before it’s handed to a server implementation. Messages are then read out of the ChannelPipeline and sent to the implemented server instance.
การแปล กรุณารอสักครู่..
